summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-10-07 17:57:10 +0200
committerAndras Timar <andras.timar@collabora.com>2014-10-08 13:16:25 +0000
commit658afeab6e956dc5093d25d734c22327aed3dc60 (patch)
tree4923e97602b652a7a37ba2e2de2a131241440271
parente5311e010159d79d83b5c1b42bbfbfe9d8df5189 (diff)
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@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sfx2/source/appl/shutdownicon.cxx154
-rw-r--r--sfx2/source/appl/shutdownicon.hxx8
-rw-r--r--sfx2/source/appl/shutdowniconunx.cxx1
3 files changed, 54 insertions, 109 deletions
diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx
index 11058e2bb314..1ed8c9cb53e2 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 d91ded524964..d09bcab373b6 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 d48b5b180d88..3a24ca0fd74b 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>