From 5764c51f2c9870c91727464c0d889d3554a5663e Mon Sep 17 00:00:00 2001 From: "Uray M. János" Date: Wed, 5 Sep 2012 19:41:42 +0200 Subject: Fix for docking property browser This fixes the crash of 'Basic IDE: Docking property browser under object catalog' commit. The aPropertyBrowser data member was replaced by a new-allocated pointer. We need this because toolkit releases it by delete. When the property browser is closed in the floating state, it tells DialogWindowLayout to null the pointer. If the user clicks the 'property browser' button on the toolbar, it is created again. Change-Id: Ie842a72fe37dfdd2ed5921ffa2f1f41d3f2c51c6 Reviewed-on: https://gerrit.libreoffice.org/568 Tested-by: Noel Power Reviewed-by: Noel Power --- basctl/source/basicide/layout.cxx | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'basctl/source/basicide/layout.cxx') diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx index 5d1be2e2f278..32edb585fdac 100644 --- a/basctl/source/basicide/layout.cxx +++ b/basctl/source/basicide/layout.cxx @@ -56,6 +56,13 @@ Layout::Layout (Window* pParent) : Layout::~Layout() { } +// removes a docking window +void Layout::Remove (DockingWindow* pWin) +{ + aLeftSide.Remove(pWin); + aBottomSide.Remove(pWin); +} + // called by Window when resized void Layout::Resize() { @@ -70,10 +77,18 @@ void Layout::ArrangeWindows () int const nWidth = aSize.Width(), nHeight = aSize.Height(); if (!nWidth || !nHeight) // empty size return; + + // prevent recursion via OnFirstSize() -> Add() -> ArrangeWindows() + static bool bRecursion = false; + if (bRecursion) + return; + bRecursion = true; + + // on first call if (bFirstSize) { - this->OnFirstSize(nWidth, nHeight); // virtual bFirstSize = false; + this->OnFirstSize(nWidth, nHeight); // virtual } // sides @@ -84,6 +99,8 @@ void Layout::ArrangeWindows () Point(aLeftSide.GetSize(), 0), Size(nWidth - aLeftSide.GetSize(), nHeight - aBottomSide.GetSize()) ); + + bRecursion = false; } void Layout::DockaWindow (DockingWindow*) @@ -175,6 +192,30 @@ void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize) } // nLastPos nLastPos += nSize2 + nSplitThickness; + // refresh + rLayout.ArrangeWindows(); +} + +// Remove() -- removes a window from the side (if contains) +void Layout::SplittedSide::Remove (DockingWindow* pWin) +{ + // contains? + std::vector::iterator const itWin = + std::find(vWindows.begin(), vWindows.end(), pWin); + if (itWin == vWindows.end()) + return; + // index + unsigned const iWin = itWin - vWindows.begin(); + // nLastPos + if (iWin == vWindows.size() - 1) // that is the last one + nLastPos = vSplitters.back()->GetSplitPosPixel() + nSplitThickness; + // remove + vWindows.erase(itWin); + // remove a splitter line + if (!vSplitters.empty()) + vSplitters.pop_back(); + // refresh + rLayout.ArrangeWindows(); } // creating a Point or a Size object -- cgit