Kaydet (Commit) ca016934 authored tarafından Michael Stahl's avatar Michael Stahl

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
üst f814795a
...@@ -94,6 +94,9 @@ typedef ::std::vector< SfxMedium* > SfxMediumList; ...@@ -94,6 +94,9 @@ typedef ::std::vector< SfxMedium* > SfxMediumList;
namespace sfx2 namespace sfx2
{ {
class SvLinkSource; class SvLinkSource;
namespace sidebar {
class Theme;
}
} }
//==================================================================== //====================================================================
...@@ -260,6 +263,9 @@ public: ...@@ -260,6 +263,9 @@ public:
/** loads the application logo as used in the impress slideshow pause screen */ /** loads the application logo as used in the impress slideshow pause screen */
static BitmapEx GetApplicationLogo(long nWidth); static BitmapEx GetApplicationLogo(long nWidth);
/** this Theme contains Images so must be deleted before DeInitVCL */
sfx2::sidebar::Theme & GetSidebarTheme();
}; };
#define SFX_APP() SfxGetpApp() #define SFX_APP() SfxGetpApp()
......
...@@ -154,6 +154,8 @@ public: ...@@ -154,6 +154,8 @@ public:
static void HandleDataChange (void); static void HandleDataChange (void);
void InitializeTheme();
Theme (void); Theme (void);
virtual ~Theme (void); virtual ~Theme (void);
...@@ -208,8 +210,7 @@ public: ...@@ -208,8 +210,7 @@ public:
throw(cssu::RuntimeException); throw(cssu::RuntimeException);
private: private:
static ::rtl::Reference<Theme> mpInstance; static Theme& GetCurrentTheme();
static Theme& GetCurrentTheme (void);
::std::vector<Image> maImages; ::std::vector<Image> maImages;
::std::vector<Color> maColors; ::std::vector<Color> maColors;
...@@ -246,7 +247,6 @@ private: ...@@ -246,7 +247,6 @@ private:
}; };
void SetupPropertyMaps (void); void SetupPropertyMaps (void);
void InitializeTheme (void);
void UpdateTheme (void); void UpdateTheme (void);
static PropertyType GetPropertyType (const ThemeItem eItem); static PropertyType GetPropertyType (const ThemeItem eItem);
static cssu::Type GetCppuType (const PropertyType eType); static cssu::Type GetCppuType (const PropertyType eType);
......
...@@ -88,6 +88,7 @@ ...@@ -88,6 +88,7 @@
#include <sfx2/event.hxx> #include <sfx2/event.hxx>
#include "imestatuswindow.hxx" #include "imestatuswindow.hxx"
#include "workwin.hxx" #include "workwin.hxx"
#include <sfx2/sidebar/Theme.hxx>
#include <sfx2/tbxctrl.hxx> #include <sfx2/tbxctrl.hxx>
#include <sfx2/sfxdlg.hxx> #include <sfx2/sfxdlg.hxx>
#include "sfx2/stbitem.hxx" #include "sfx2/stbitem.hxx"
...@@ -636,4 +637,14 @@ ErrCode SfxApplication::CallBasic( const OUString& rCode, BasicManager* pMgr, Sb ...@@ -636,4 +637,14 @@ ErrCode SfxApplication::CallBasic( const OUString& rCode, BasicManager* pMgr, Sb
#endif #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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <sfx2/docfac.hxx> #include <sfx2/docfac.hxx>
#include <sfx2/docfile.hxx> #include <sfx2/docfile.hxx>
#include <sfx2/request.hxx> #include <sfx2/request.hxx>
#include <sfx2/sidebar/Theme.hxx>
#include "referers.hxx" #include "referers.hxx"
#include "app.hrc" #include "app.hrc"
#include "sfx2/sfxresid.hxx" #include "sfx2/sfxresid.hxx"
......
...@@ -62,7 +62,10 @@ class BasicManager; ...@@ -62,7 +62,10 @@ class BasicManager;
class SfxBasicManagerHolder; class SfxBasicManagerHolder;
class SfxBasicManagerCreationListener; class SfxBasicManagerCreationListener;
namespace sfx2 { namespace appl { class ImeStatusWindow; } } namespace sfx2 {
namespace appl { class ImeStatusWindow; }
namespace sidebar { class Theme; }
}
typedef Link* LinkPtr; typedef Link* LinkPtr;
...@@ -130,6 +133,7 @@ public: ...@@ -130,6 +133,7 @@ public:
SfxSlotPool* pSlotPool; SfxSlotPool* pSlotPool;
SfxDispatcher* pAppDispat; // Dispatcher if no document SfxDispatcher* pAppDispat; // Dispatcher if no document
SfxInterface** pInterfaces; SfxInterface** pInterfaces;
::rtl::Reference<sfx2::sidebar::Theme> m_pSidebarTheme;
sal_uInt16 nDocNo; // current Doc-Number (AutoName) sal_uInt16 nDocNo; // current Doc-Number (AutoName)
sal_uInt16 nInterfaces; sal_uInt16 nInterfaces;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "Paint.hxx" #include "Paint.hxx"
#include "SidebarResource.hxx" #include "SidebarResource.hxx"
#include "sfx2/sidebar/Tools.hxx" #include "sfx2/sidebar/Tools.hxx"
#include <sfx2/app.hxx>
#include <tools/svborder.hxx> #include <tools/svborder.hxx>
#include <tools/rc.hxx> #include <tools/rc.hxx>
...@@ -31,25 +32,13 @@ using namespace cssu; ...@@ -31,25 +32,13 @@ using namespace cssu;
namespace sfx2 { namespace sidebar { namespace sfx2 { namespace sidebar {
::rtl::Reference<Theme> Theme::mpInstance;
Theme& Theme::GetCurrentTheme()
Theme& Theme::GetCurrentTheme (void)
{ {
if ( ! mpInstance.is()) return SFX_APP()->GetSidebarTheme();
{
mpInstance.set(new Theme());
mpInstance->InitializeTheme();
}
return *mpInstance;
} }
Theme::Theme()
Theme::Theme (void)
: ThemeInterfaceBase(m_aMutex), : ThemeInterfaceBase(m_aMutex),
maImages(), maImages(),
maColors(), maColors(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment