[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - 2 commits - sfx2/source
Stephan Bergmann
sbergman at redhat.com
Wed Oct 8 06:17:11 PDT 2014
sfx2/source/appl/shutdownicon.cxx | 173 ++++++++++-------------------------
sfx2/source/appl/shutdownicon.hxx | 8 -
sfx2/source/appl/shutdowniconunx.cxx | 1
3 files changed, 55 insertions(+), 127 deletions(-)
New commits:
commit 8a6275b0b92d959f0b440a73362c7ec0eea4436e
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Oct 8 12:57:00 2014 +0200
Do not terminate desktop from a Timer
<sberg> kendy, as you recently changed Timer handling on Windows: debugging why
quickstarter no longer works on Windows, I run into the phenomenon that
IdleTerminate::Timeout (sfx2/source/appl/shutdownicon.cxx) executes on the main
thread, and from within the m_xDesktop->terminate() call Timer::ImplDeInitTimer
is called which deletes the pTimerData corresponding to our IldeTerminate, so
that Timer::ImplTimerCallbackProc, after the return from
IdleTerminate::Timeout, will operate on a stale pTimerData and crash; could
that be related to those recent changes?
<kendy> sberg: I think mst told that we were previously never deleting the
timer, and that he did some changes there [...]
<mst__> sberg, IdleTerminate needs a different implementation
<mst__> sberg, does it work to do this via PostUserEvent, as
"Application::Quit()" does?
<sberg> mst__, do you think calling terminate from a Timer did work in the past?
[...]
<mst__> sberg, perhaps it did before [a recent] commit but i would guess it
would be more by accident than by design
Change-Id: I23b14ba59a963cc2209a261a1459d532a88acdc0
(cherry picked from commit d8a0ecc94bfbfc1d9c8403f0e894d3b7e40384f2)
Reviewed-on: https://gerrit.libreoffice.org/11852
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx
index 1ed8c9c..55e1c5e 100644
--- a/sfx2/source/appl/shutdownicon.cxx
+++ b/sfx2/source/appl/shutdownicon.cxx
@@ -63,7 +63,6 @@
#include <unistd.h>
#include <errno.h>
#endif
-#include <vcl/timer.hxx>
#include <sfx2/sfxresid.hxx>
@@ -183,22 +182,6 @@ bool LoadModule()
}
-class IdleTerminate : Timer
-{
- ::com::sun::star::uno::Reference< XDesktop2 > m_xDesktop;
-public:
- IdleTerminate (::com::sun::star::uno::Reference< XDesktop2 > xDesktop)
- {
- m_xDesktop = xDesktop;
- Start();
- }
- virtual void Timeout() SAL_OVERRIDE
- {
- m_xDesktop->terminate();
- delete this;
- }
-};
-
void ShutdownIcon::initSystray()
{
if (m_bInitialized)
@@ -564,7 +547,7 @@ void ShutdownIcon::terminateDesktop()
// terminate desktop only if no tasks exist
::com::sun::star::uno::Reference< XIndexAccess > xTasks ( xDesktop->getFrames(), UNO_QUERY );
if( xTasks.is() && xTasks->getCount() < 1 )
- new IdleTerminate( xDesktop );
+ Application::Quit();
// remove the instance pointer
ShutdownIcon::pShutdownIcon = 0;
commit 658afeab6e956dc5093d25d734c22327aed3dc60
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Oct 7 17:57:10 2014 +0200
Don't even attempt to unload libqstart_gtklo.so again
...for no apparent gain. IdleUnloader introduced in
a8b42ddd66bba4b6f26a4d2d793051752989938e "Fix i#101245#" was probably a
misguided reaction to osl::Module's dtor starting to call dlclose back then.
(cherry picked from commit 73aaa3cf5e18d008268f4b67bbb60070b2cafc6a)
Conflicts:
sfx2/source/appl/shutdownicon.cxx
sfx2/source/appl/shutdowniconunx.cxx
Change-Id: I9a5e99d8cfba13e3750331597d64f58135537e9b
Reviewed-on: https://gerrit.libreoffice.org/11851
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx
index 11058e2..1ed8c9c 100644
--- a/sfx2/source/appl/shutdownicon.cxx
+++ b/sfx2/source/appl/shutdownicon.cxx
@@ -17,8 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <config_folders.h>
+#include <sal/config.h>
+
+#include <cassert>
+#include <boost/logic/tribool.hpp>
+#include <config_folders.h>
#include <shutdownicon.hxx>
#include <app.hrc>
#include <sfx2/app.hxx>
@@ -80,10 +84,6 @@ extern "C" { static void SAL_CALL thisModule() {} }
# endif
#endif
-#if defined(UNX) && defined(ENABLE_SYSTRAY_GTK) && !defined(PLUGIN_NAME)
-#define PLUGIN_NAME "libqstart_gtklo.so"
-#endif
-
class SfxNotificationListener_Impl : public cppu::WeakImplHelper1< XDispatchResultListener >
{
public:
@@ -123,7 +123,7 @@ css::uno::Sequence<OUString> SAL_CALL ShutdownIcon::getSupportedServiceNames()
bool ShutdownIcon::bModalMode = false;
ShutdownIcon* ShutdownIcon::pShutdownIcon = NULL;
-#if !defined( ENABLE_QUICKSTART_APPLET ) || defined( UNX )
+#if !defined( ENABLE_QUICKSTART_APPLET )
// To remove conditionals
extern "C" {
static void disabled_initSystray() { }
@@ -131,100 +131,57 @@ extern "C" {
}
#endif
-bool ShutdownIcon::LoadModule( osl::Module **pModule,
- oslGenericFunction *pInit,
- oslGenericFunction *pDeInit )
+namespace {
+
+boost::logic::tribool loaded(boost::logic::indeterminate);
+oslGenericFunction pInitSystray(0);
+oslGenericFunction pDeInitSystray(0);
+
+bool LoadModule()
{
- if ( pModule )
+ if (boost::logic::indeterminate(loaded))
{
- OSL_ASSERT ( pInit && pDeInit );
- *pInit = *pDeInit = NULL;
- *pModule = NULL;
- }
-
#ifdef ENABLE_QUICKSTART_APPLET
# ifdef WIN32
- if ( pModule )
- {
- *pInit = win32_init_sys_tray;
- *pDeInit = win32_shutdown_sys_tray;
- }
- return true;
+ pInitSystray = win32_init_sys_tray;
+ pDeInitSystray = win32_shutdown_sys_tray;
+ loaded = true;
# elif defined MACOSX
- *pInit = aqua_init_systray;
- *pDeInit = aqua_shutdown_systray;
- return true;
+ pInitSystray = aqua_init_systray;
+ pDeInitSystray = aqua_shutdown_systray;
+ loaded = true;
# else // UNX
- osl::Module *pPlugin;
- pPlugin = new osl::Module();
-
- oslGenericFunction pTmpInit = NULL;
- oslGenericFunction pTmpDeInit = NULL;
-
-#define DOSTRING( x ) #x
-#define STRING( x ) DOSTRING( x )
-
- if ( pPlugin->loadRelative( &thisModule, OUString (STRING( PLUGIN_NAME ) ) ) )
- {
- pTmpInit = pPlugin->getFunctionSymbol(
- OUString( "plugin_init_sys_tray" ) );
- pTmpDeInit = pPlugin->getFunctionSymbol(
- OUString( "plugin_shutdown_sys_tray" ) );
- }
- if ( !pTmpInit || !pTmpDeInit )
- {
- delete pPlugin;
- pPlugin = NULL;
- }
- if ( pModule )
- {
- *pModule = pPlugin;
- *pInit = pTmpInit;
- *pDeInit = pTmpDeInit;
- }
- else
- {
- bool bRet = pPlugin != NULL;
- delete pPlugin;
- return bRet;
- }
+ osl::Module plugin;
+ oslGenericFunction pTmpInit = NULL;
+ oslGenericFunction pTmpDeInit = NULL;
+ if ( plugin.loadRelative( &thisModule, "libqstart_gtklo.so" ) )
+ {
+ pTmpInit = plugin.getFunctionSymbol( "plugin_init_sys_tray" );
+ pTmpDeInit = plugin.getFunctionSymbol( "plugin_shutdown_sys_tray" );
+ }
+ if ( !pTmpInit || !pTmpDeInit )
+ {
+ loaded = false;
+ }
+ else
+ {
+ plugin.release();
+ pInitSystray = pTmpInit;
+ pDeInitSystray = pTmpDeInit;
+ loaded = true;
+ }
# endif // UNX
+#else
+ pInitSystray = disabled_initSystray;
+ pDeInitSystray = disabled_deInitSystray
+ loaded = false;
#endif // ENABLE_QUICKSTART_APPLET
-
-#if !defined( ENABLE_QUICKSTART_APPLET ) || defined( UNX )
- // Avoid unreachable code. In the ENABLE_QUICKSTART_APPLET && !UNX
- // case, we have already returned.
- if ( pModule )
- {
- if ( !*pInit )
- *pInit = disabled_initSystray;
- if ( !*pDeInit )
- *pDeInit = disabled_deInitSystray;
}
-
- return true;
-#endif // !ENABLE_QUICKSTART_APPLET || UNX
+ assert(!boost::logic::indeterminate(loaded));
+ return loaded;
}
-// These two timeouts are necessary to avoid there being
-// plugin frames still on the stack, after unloading that
-// code, causing a crash during disabling / termination.
-class IdleUnloader : Timer
-{
- ::osl::Module *m_pModule;
-public:
- IdleUnloader (::osl::Module **pModule) :
- m_pModule (*pModule)
- {
- *pModule = NULL;
- Start();
- }
- virtual void Timeout() SAL_OVERRIDE
- {
- delete m_pModule;
- delete this;
- }
-};
+}
class IdleTerminate : Timer
{
@@ -248,9 +205,9 @@ void ShutdownIcon::initSystray()
return;
m_bInitialized = true;
- (void) LoadModule( &m_pPlugin, &m_pInitSystray, &m_pDeInitSystray );
+ (void) LoadModule();
m_bVeto = true;
- m_pInitSystray();
+ pInitSystray();
}
void ShutdownIcon::deInitSystray()
@@ -258,13 +215,12 @@ void ShutdownIcon::deInitSystray()
if (!m_bInitialized)
return;
- if (m_pDeInitSystray)
- m_pDeInitSystray();
+ if (pDeInitSystray)
+ pDeInitSystray();
m_bVeto = false;
- m_pInitSystray = 0;
- m_pDeInitSystray = 0;
- new IdleUnloader (&m_pPlugin);
+ pInitSystray = 0;
+ pDeInitSystray = 0;
delete m_pFileDlg;
m_pFileDlg = NULL;
@@ -280,9 +236,6 @@ ShutdownIcon::ShutdownIcon( const ::com::sun::star::uno::Reference< XComponentCo
m_pResMgr( NULL ),
m_pFileDlg( NULL ),
m_xContext( rxContext ),
- m_pInitSystray( 0 ),
- m_pDeInitSystray( 0 ),
- m_pPlugin( 0 ),
m_bInitialized( false )
{
m_bSystemDialogs = SvtMiscOptions().UseSystemFileDialog();
@@ -291,7 +244,6 @@ ShutdownIcon::ShutdownIcon( const ::com::sun::star::uno::Reference< XComponentCo
ShutdownIcon::~ShutdownIcon()
{
deInitSystray();
- new IdleUnloader (&m_pPlugin);
}
@@ -774,7 +726,7 @@ bool ShutdownIcon::IsQuickstarterInstalled()
return false;
#else // !ENABLE_QUICKSTART_APPLET
#ifdef UNX
- return LoadModule( NULL, NULL, NULL);
+ return LoadModule();
#endif // UNX
#endif // !ENABLE_QUICKSTART_APPLET
}
diff --git a/sfx2/source/appl/shutdownicon.hxx b/sfx2/source/appl/shutdownicon.hxx
index d91ded5..d09bcab3 100644
--- a/sfx2/source/appl/shutdownicon.hxx
+++ b/sfx2/source/appl/shutdownicon.hxx
@@ -29,7 +29,6 @@
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
#include <osl/mutex.hxx>
-#include <osl/module.hxx>
#include <sfx2/sfxuno.hxx>
#include <cppuhelper/compbase4.hxx>
#include <sfx2/dllapi.h>
@@ -69,17 +68,10 @@ class SFX2_DLLPUBLIC ShutdownIcon : public ShutdownIconServiceBase
static ShutdownIcon *pShutdownIcon; // one instance
- oslGenericFunction m_pInitSystray;
- oslGenericFunction m_pDeInitSystray;
- ::osl::Module *m_pPlugin;
-
bool m_bInitialized;
void initSystray();
void deInitSystray();
- static bool LoadModule( osl::Module **pModule,
- oslGenericFunction *pInit,
- oslGenericFunction *pDeInit );
static void EnterModalMode();
static void LeaveModalMode();
static OUString getShortcutName();
diff --git a/sfx2/source/appl/shutdowniconunx.cxx b/sfx2/source/appl/shutdowniconunx.cxx
index d48b5b1..3a24ca0 100644
--- a/sfx2/source/appl/shutdowniconunx.cxx
+++ b/sfx2/source/appl/shutdowniconunx.cxx
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <glib.h>
+#include <osl/module.hxx>
#include <osl/mutex.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/bmpacc.hxx>
More information about the Libreoffice-commits
mailing list