diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-01-06 10:49:31 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-01-06 11:29:17 +0100 |
commit | afa6a774936c34b09b37ab8539193ac529681798 (patch) | |
tree | 98bd8f03d627800dc57ac436907119febe3e5d12 /sc | |
parent | 499bfe4584ea3334cda1501daa9aa3026edd45be (diff) |
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>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/prevwsh.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx index 493ce87228ce..fe3688abdd43 100644 --- a/sc/source/ui/view/prevwsh.cxx +++ b/sc/source/ui/view/prevwsh.cxx @@ -160,7 +160,7 @@ ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame, auto& pNotebookBar = pViewFrame->GetWindow().GetSystemWindow()->GetNotebookBar(); if (pNotebookBar) - pNotebookBar->ControlListener(true); + pNotebookBar->ControlListenerForCurrentController(false); // stop listening if ( auto pTabViewShell = dynamic_cast<ScTabViewShell*>( pOldSh) ) { @@ -189,7 +189,7 @@ ScPreviewShell::~ScPreviewShell() mpFrameWindow->SetCloseHdl(Link<SystemWindow&,void>()); // Remove close handler. if (auto& pBar = GetViewFrame()->GetWindow().GetSystemWindow()->GetNotebookBar()) - pBar->ControlListener(false); + pBar->ControlListenerForCurrentController(true); // let it start listening now // #108333#; notify Accessibility that Shell is dying and before destroy all BroadcastAccessibility( SfxHint( SfxHintId::Dying ) ); |