[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Michael Stahl mstahl at redhat.com
Sat Sep 21 09:21:45 PDT 2013


 include/sfx2/app.hxx           |    6 ++++++
 include/sfx2/sidebar/Theme.hxx |    6 +++---
 sfx2/source/appl/app.cxx       |   11 +++++++++++
 sfx2/source/appl/appdata.cxx   |    1 +
 sfx2/source/inc/appdata.hxx    |    6 +++++-
 sfx2/source/sidebar/Theme.cxx  |   19 ++++---------------
 6 files changed, 30 insertions(+), 19 deletions(-)

New commits:
commit ca0169340c94adc791061e3fb098fa656f22a8c5
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Sep 21 18:01:36 2013 +0200

    sfx2: fix sfx2::sidebar::Theme lifecycle
    
    It's a horrible idea to have global VCL Images, since that will
    inevitably crash on shutdown when the static dtor runs after
    DeInitVCL, which breaks ~every JunitTest now.
    
    0x00002af6750d2d51 in rtl::Reference<sfx2::sidebar::Theme>::~Reference (this=0x2af6756ceb28 <sfx2::sidebar::Theme::mpInstance>, __in_chrg=<optimized out>)
    
    Try to fix that by moving the global sidebar::Theme instance to
    SfxApplication where it can hopefully be deleted before shutdown.
    
    Change-Id: Ia78f1e458699335b53a741b6463ce48af69584a7

diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index f8361f2..d24b40a 100644
--- a/include/sfx2/app.hxx
+++ b/include/sfx2/app.hxx
@@ -94,6 +94,9 @@ typedef ::std::vector< SfxMedium* > SfxMediumList;
 namespace sfx2
 {
     class SvLinkSource;
+    namespace sidebar {
+        class Theme;
+    }
 }
 
 //====================================================================
@@ -260,6 +263,9 @@ public:
 
     /** loads the application logo as used in the impress slideshow pause screen */
     static BitmapEx GetApplicationLogo(long nWidth);
+
+    /** this Theme contains Images so must be deleted before DeInitVCL */
+    sfx2::sidebar::Theme & GetSidebarTheme();
 };
 
 #define SFX_APP() SfxGetpApp()
diff --git a/include/sfx2/sidebar/Theme.hxx b/include/sfx2/sidebar/Theme.hxx
index ae1e6a6..098b63d 100644
--- a/include/sfx2/sidebar/Theme.hxx
+++ b/include/sfx2/sidebar/Theme.hxx
@@ -154,6 +154,8 @@ public:
 
     static void HandleDataChange (void);
 
+    void InitializeTheme();
+
     Theme (void);
     virtual ~Theme (void);
 
@@ -208,8 +210,7 @@ public:
         throw(cssu::RuntimeException);
 
 private:
-    static ::rtl::Reference<Theme> mpInstance;
-    static Theme& GetCurrentTheme (void);
+    static Theme& GetCurrentTheme();
 
     ::std::vector<Image> maImages;
     ::std::vector<Color> maColors;
@@ -246,7 +247,6 @@ private:
     };
 
     void SetupPropertyMaps (void);
-    void InitializeTheme (void);
     void UpdateTheme (void);
     static PropertyType GetPropertyType (const ThemeItem eItem);
     static cssu::Type GetCppuType (const PropertyType eType);
diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index c668842..fb84391 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -88,6 +88,7 @@
 #include <sfx2/event.hxx>
 #include "imestatuswindow.hxx"
 #include "workwin.hxx"
+#include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/tbxctrl.hxx>
 #include <sfx2/sfxdlg.hxx>
 #include "sfx2/stbitem.hxx"
@@ -636,4 +637,14 @@ ErrCode SfxApplication::CallBasic( const OUString& rCode, BasicManager* pMgr, Sb
 #endif
 }
 
+sfx2::sidebar::Theme & SfxApplication::GetSidebarTheme()
+{
+    if (!pAppData_Impl->m_pSidebarTheme.is())
+    {
+        pAppData_Impl->m_pSidebarTheme.set(new sfx2::sidebar::Theme);
+        pAppData_Impl->m_pSidebarTheme->InitializeTheme();
+    }
+    return *pAppData_Impl->m_pSidebarTheme;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx
index a2c79ca..d031fbc 100644
--- a/sfx2/source/appl/appdata.cxx
+++ b/sfx2/source/appl/appdata.cxx
@@ -38,6 +38,7 @@
 #include <sfx2/docfac.hxx>
 #include <sfx2/docfile.hxx>
 #include <sfx2/request.hxx>
+#include <sfx2/sidebar/Theme.hxx>
 #include "referers.hxx"
 #include "app.hrc"
 #include "sfx2/sfxresid.hxx"
diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx
index 00bf7b4..cdd6680 100644
--- a/sfx2/source/inc/appdata.hxx
+++ b/sfx2/source/inc/appdata.hxx
@@ -62,7 +62,10 @@ class BasicManager;
 class SfxBasicManagerHolder;
 class SfxBasicManagerCreationListener;
 
-namespace sfx2 { namespace appl { class ImeStatusWindow; } }
+namespace sfx2 {
+    namespace appl { class ImeStatusWindow; }
+    namespace sidebar { class Theme; }
+}
 
 typedef Link* LinkPtr;
 
@@ -130,6 +133,7 @@ public:
     SfxSlotPool*                pSlotPool;
     SfxDispatcher*              pAppDispat;     // Dispatcher if no document
     SfxInterface**              pInterfaces;
+    ::rtl::Reference<sfx2::sidebar::Theme> m_pSidebarTheme;
 
     sal_uInt16                      nDocNo;             // current Doc-Number (AutoName)
     sal_uInt16                      nInterfaces;
diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx
index d6d95d7..bd191bb 100644
--- a/sfx2/source/sidebar/Theme.cxx
+++ b/sfx2/source/sidebar/Theme.cxx
@@ -20,6 +20,7 @@
 #include "Paint.hxx"
 #include "SidebarResource.hxx"
 #include "sfx2/sidebar/Tools.hxx"
+#include <sfx2/app.hxx>
 
 #include <tools/svborder.hxx>
 #include <tools/rc.hxx>
@@ -31,25 +32,13 @@ using namespace cssu;
 
 namespace sfx2 { namespace sidebar {
 
-::rtl::Reference<Theme> Theme::mpInstance;
 
-
-
-
-Theme& Theme::GetCurrentTheme (void)
+Theme& Theme::GetCurrentTheme()
 {
-    if ( ! mpInstance.is())
-    {
-        mpInstance.set(new Theme());
-        mpInstance->InitializeTheme();
-    }
-    return *mpInstance;
+    return SFX_APP()->GetSidebarTheme();
 }
 
-
-
-
-Theme::Theme (void)
+Theme::Theme()
     : ThemeInterfaceBase(m_aMutex),
       maImages(),
       maColors(),


More information about the Libreoffice-commits mailing list