summaryrefslogtreecommitdiff
path: root/sfx2/source/sidebar
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-07-15 10:35:24 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2021-08-18 13:18:36 +0200
commite34ec3e196b3265ea640e1730c7d42dd6182e65f (patch)
tree61cb7a47b930745b85d317ee0c553248f50d8b09 /sfx2/source/sidebar
parentf926356e1f48a461eb3157c1020de0bd48f76080 (diff)
Don't crash on SidebarController dispose when app is closing
When app is closing it is possible SfxGetpApp() will return null. So GetCurrentTheme() cannot return reference to correct theme. Remember which theme has registered SidebarController to unregister when disposing. Change-Id: If223233f621601f445472b0413a56e9c51e59673 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118970 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Pranam Lashkari <lpranam@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120630 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sfx2/source/sidebar')
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx10
-rw-r--r--sfx2/source/sidebar/Theme.cxx6
2 files changed, 11 insertions, 5 deletions
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 803d1c10a739..c03b2a96acdb 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -157,7 +157,8 @@ rtl::Reference<SidebarController> SidebarController::create(SidebarDockingWindow
instance->mpParentWindow->AddEventListener(LINK(instance.get(), SidebarController, WindowEventHandler));
// Listen for theme property changes.
- Theme::GetPropertySet()->addPropertyChangeListener(
+ instance->mxThemePropertySet = Theme::GetPropertySet();
+ instance->mxThemePropertySet->addPropertyChangeListener(
"",
static_cast<css::beans::XPropertyChangeListener*>(instance.get()));
@@ -312,9 +313,10 @@ void SAL_CALL SidebarController::disposing()
if (mxReadOnlyModeDispatch.is())
mxReadOnlyModeDispatch->removeStatusListener(this, Tools::GetURL(gsReadOnlyCommandName));
- Theme::GetPropertySet()->removePropertyChangeListener(
- "",
- static_cast<css::beans::XPropertyChangeListener*>(this));
+ if (mxThemePropertySet.is())
+ mxThemePropertySet->removePropertyChangeListener(
+ "",
+ static_cast<css::beans::XPropertyChangeListener*>(this));
if (mpParentWindow != nullptr)
{
diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx
index cd4ce36bd658..6d6fe7bc517f 100644
--- a/sfx2/source/sidebar/Theme.cxx
+++ b/sfx2/source/sidebar/Theme.cxx
@@ -32,6 +32,7 @@ namespace sfx2::sidebar {
Theme& Theme::GetCurrentTheme()
{
+ OSL_ASSERT(SfxGetpApp());
return SfxGetpApp()->GetSidebarTheme();
}
@@ -177,7 +178,10 @@ void SAL_CALL Theme::disposing()
Reference<beans::XPropertySet> Theme::GetPropertySet()
{
- return Reference<beans::XPropertySet>(static_cast<XWeak*>(&GetCurrentTheme()), UNO_QUERY);
+ if (SfxGetpApp())
+ return Reference<beans::XPropertySet>(static_cast<XWeak*>(&GetCurrentTheme()), UNO_QUERY);
+ else
+ return Reference<beans::XPropertySet>();
}
Reference<beans::XPropertySetInfo> SAL_CALL Theme::getPropertySetInfo()