[Libreoffice-commits] core.git: sfx2/source
Michael Stahl
mstahl at redhat.com
Tue Dec 1 15:14:03 PST 2015
sfx2/source/sidebar/SidebarController.cxx | 59 ++++++++++++++++--------------
1 file changed, 33 insertions(+), 26 deletions(-)
New commits:
commit 02f2c2f8a160133731d707a8359f5cd576bff434
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Dec 1 23:59:19 2015 +0100
tdf#96162: sfx2: avoid re-creating existing sidebar Panels
Writer's naviagtor crashes when you click on a frame to select it,
because the SwContent* that is passed to SwContentTree::GotoContent()
is deleted because SidebarController::CreatePanels() re-creates
every single panel and then ResetPanels() disposes the existing ones,
which deletes the naviagtor's SwContent instances.
(regression from 536c259cb9644971d0eb0cdfb7d823c5383a5481)
Change-Id: I8f875df816a2d5948026a1d3f30b86bb2418acda
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index aad709f..55f4d0b 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -573,35 +573,43 @@ void SidebarController::CreatePanels(const ::rtl::OUString& rDeckId)
// init panels bounded to that deck, do not wait them being displayed as may be accessed through API
- VclPtr<Deck> pDeck = pDeckDescriptor->mpDeck;
+ VclPtr<Deck> pDeck = pDeckDescriptor->mpDeck;
- ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors;
+ ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors;
- css::uno::Reference<css::frame::XController> xController = mxCurrentController.is() ? mxCurrentController : mxFrame->getController();
+ css::uno::Reference<css::frame::XController> xController = mxCurrentController.is() ? mxCurrentController : mxFrame->getController();
- mpResourceManager->GetMatchingPanels(
- aPanelContextDescriptors,
- maCurrentContext,
- rDeckId,
- xController);
+ mpResourceManager->GetMatchingPanels(
+ aPanelContextDescriptors,
+ maCurrentContext,
+ rDeckId,
+ xController);
- // Update the panel list.
- const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
- SharedPanelContainer aNewPanels;
+ // Update the panel list.
+ const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
+ SharedPanelContainer aNewPanels;
- aNewPanels.resize(nNewPanelCount);
- sal_Int32 nWriteIndex (0);
+ aNewPanels.resize(nNewPanelCount);
+ sal_Int32 nWriteIndex (0);
- for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex)
- {
- const ResourceManager::PanelContextDescriptor& rPanelContexDescriptor (
- aPanelContextDescriptors[nReadIndex]);
+ for (sal_Int32 nReadIndex=0; nReadIndex<nNewPanelCount; ++nReadIndex)
+ {
+ const ResourceManager::PanelContextDescriptor& rPanelContexDescriptor (
+ aPanelContextDescriptors[nReadIndex]);
- // Determine if the panel can be displayed.
- const bool bIsPanelVisible (!mbIsDocumentReadOnly || rPanelContexDescriptor.mbShowForReadOnlyDocuments);
- if ( ! bIsPanelVisible)
- continue;
+ // Determine if the panel can be displayed.
+ const bool bIsPanelVisible (!mbIsDocumentReadOnly || rPanelContexDescriptor.mbShowForReadOnlyDocuments);
+ if ( ! bIsPanelVisible)
+ continue;
+ Panel *const pPanel(pDeck->GetPanel(rPanelContexDescriptor.msId));
+ if (pPanel != nullptr)
+ {
+ aNewPanels[nWriteIndex] = pPanel;
+ ++nWriteIndex;
+ }
+ else
+ {
VclPtr<Panel> aPanel = CreatePanel(
rPanelContexDescriptor.msId,
pDeck->GetPanelParentWindow(),
@@ -625,12 +633,11 @@ void SidebarController::CreatePanels(const ::rtl::OUString& rDeckId)
}
}
+ }
- // mpCurrentPanels - may miss stuff (?)
- aNewPanels.resize(nWriteIndex);
- pDeck->ResetPanels(aNewPanels);
-
- pDeckDescriptor->mpDeck = pDeck;
+ // mpCurrentPanels - may miss stuff (?)
+ aNewPanels.resize(nWriteIndex);
+ pDeck->ResetPanels(aNewPanels);
}
void SidebarController::SwitchToDeck (
More information about the Libreoffice-commits
mailing list