summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-01-06 10:49:31 +0300
committerXisco FaulĂ­ <xiscofauli@libreoffice.org>2020-02-07 18:06:21 +0100
commitfb2382ad4f33b885650ad5156ccaec4e90661806 (patch)
tree74aed718b23004361162792592dadc79408bf4d9 /sfx2
parent282cf1507d51573e5e9a4611b1e775b433168ca7 (diff)
tdf#130187: Don't crash on exiting print preview with Notebookbar
Crash caused by this sequence (tested in Writer): 1. Closing print preview, frame is attached to controller; 2. This calls SfxNotebookBar::StateMethod 3. There notebookbar's listener is added to list of the controller's context change event listeners 4. Then in SwPagePreview::~SwPagePreview, notebookbar's listener is added to that list again 5. ContextChangeEventMultiplexer::addContextChangeEventListener detects second addition, and throws an unhandled exception. I don't know why starting listening is needed in SwPagePreview dtor; unfortunately commit d05b7b32d9ecb6fcb4a268eb68cdcee09bafa6dd doesn't say much about context and reasons. ControlListener is renamed to ControlListenerForCurrentController to emphasize that it operates on the current controller of notebookbar's frame; and its bListen parameter meaning was reverted: previously its "true" value awkwardly meant "stop listening". All direct operations with listener of notebookbar are replaced with calls to notebookbar's methods. In ContextChangeEventMultiplexer::addContextChangeEventListener, uno::UNO_QUERY_THROW was replaced with uno::UNO_QUERY, because not only chart controller may appear here, and it's not an error: e.g. SfxBaseController doesn't implement lang::XServiceInfo. Regression after commit d05b7b32d9ecb6fcb4a268eb68cdcee09bafa6dd. Change-Id: Ief1aed188d8f02a6cfe3ea25f4d082dfdf449f32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86257 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87582
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/notebookbar/SfxNotebookBar.cxx15
1 files changed, 3 insertions, 12 deletions
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 538886f202a1..a2d7f1f39b17 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -400,15 +400,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
if(pView)
{
- Reference<XContextChangeEventMultiplexer> xMultiplexer
- = ContextChangeEventMultiplexer::get( xContext );
-
- if(xFrame.is())
- {
- xMultiplexer->addContextChangeEventListener(
- pNotebookBar->getContextChangeEventListener(),
- xFrame->getController());
- }
+ pNotebookBar->ControlListenerForCurrentController(true);
}
}
@@ -430,10 +422,9 @@ void SfxNotebookBar::RemoveListeners(SystemWindow const * pSysWindow)
= ContextChangeEventMultiplexer::get(
::comphelper::getProcessComponentContext());
- if (pSysWindow->GetNotebookBar())
+ if (auto pNotebookBar = pSysWindow->GetNotebookBar())
{
- xMultiplexer->removeAllContextChangeEventListeners(
- pSysWindow->GetNotebookBar()->getContextChangeEventListener());
+ pNotebookBar->StopListeningAllControllers();
}
}