[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/sfx2 sfx2/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 16 09:27:00 UTC 2021
include/sfx2/sidebar/SidebarController.hxx | 2 ++
sfx2/source/sidebar/SidebarController.cxx | 10 ++++++----
sfx2/source/sidebar/Theme.cxx | 6 +++++-
3 files changed, 13 insertions(+), 5 deletions(-)
New commits:
commit a2e2994a634cd78df851f37798a41061e2540d22
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Jul 15 10:35:24 2021 +0200
Commit: Pranam Lashkari <lpranam at collabora.com>
CommitDate: Fri Jul 16 11:26:25 2021 +0200
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 at gmail.com>
Reviewed-by: Pranam Lashkari <lpranam at collabora.com>
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index f1d874141382..f4e116cab5df 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -29,6 +29,7 @@
#include <sfx2/sidebar/TabBar.hxx>
#include <sfx2/viewfrm.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/frame/XFrameActionListener.hpp>
@@ -194,6 +195,7 @@ private:
OUString msCurrentDeckId;
AsynchronousCall maPropertyChangeForwarder;
AsynchronousCall maContextChangeUpdate;
+ css::uno::Reference<css::beans::XPropertySet> mxThemePropertySet;
/** Two flags control whether the deck is displayed or if only the
tab bar remains visible.
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 64dbe4343b14..266a69f5dcbe 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -170,7 +170,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()));
@@ -305,9 +306,10 @@ void SAL_CALL SidebarController::disposing()
mpParentWindow = nullptr;
}
- Theme::GetPropertySet()->removePropertyChangeListener(
- "",
- static_cast<css::beans::XPropertyChangeListener*>(this));
+ if (mxThemePropertySet.is())
+ mxThemePropertySet->removePropertyChangeListener(
+ "",
+ static_cast<css::beans::XPropertyChangeListener*>(this));
maContextChangeUpdate.CancelRequest();
}
diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx
index dbbcabeadd55..b3a35c078011 100644
--- a/sfx2/source/sidebar/Theme.cxx
+++ b/sfx2/source/sidebar/Theme.cxx
@@ -34,6 +34,7 @@ namespace sfx2::sidebar {
Theme& Theme::GetCurrentTheme()
{
+ OSL_ASSERT(SfxGetpApp());
return SfxGetpApp()->GetSidebarTheme();
}
@@ -198,7 +199,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()
More information about the Libreoffice-commits
mailing list