summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-12-01 23:59:19 +0100
committerMichael Stahl <mstahl@redhat.com>2015-12-02 00:12:20 +0100
commit02f2c2f8a160133731d707a8359f5cd576bff434 (patch)
tree2829093a72eeb794a15a0492fb5e1f58f630337c
parentefe4d5f743df8456f2e9a271898bf0464bd416ad (diff)
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
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx59
1 files changed, 33 insertions, 26 deletions
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index aad709fcf770..55f4d0bcc879 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 (