[Libreoffice-commits] core.git: Branch 'feature/vclptr' - 2 commits - include/sfx2 sc/source sfx2/source svx/source sw/source

Michael Meeks michael.meeks at collabora.com
Wed Apr 15 13:54:31 PDT 2015


 include/sfx2/ctrlitem.hxx                            |    1 
 include/sfx2/sidebar/ControllerItem.hxx              |    3 ++
 sc/source/ui/sidebar/AlignmentPropertyPanel.cxx      |    8 ++++++
 sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx |    8 ++++++
 sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx   |    4 +++
 sfx2/source/control/ctrlitem.cxx                     |    9 +++++--
 sfx2/source/sidebar/ControllerItem.cxx               |    8 ++++++
 sfx2/source/sidebar/Deck.cxx                         |   15 ++++++++++++
 sfx2/source/sidebar/Deck.hxx                         |    2 -
 sfx2/source/sidebar/SidebarController.cxx            |   22 +++++++------------
 svx/source/sidebar/area/AreaPropertyPanel.cxx        |   12 ++++++++++
 svx/source/sidebar/graphic/GraphicPropertyPanel.cxx  |   10 ++++++++
 svx/source/sidebar/line/LinePropertyPanel.cxx        |   12 ++++++++++
 svx/source/sidebar/paragraph/ParaPropertyPanel.cxx   |    9 +++++++
 svx/source/sidebar/possize/PosSizePropertyPanel.cxx  |   15 ++++++++++++
 svx/source/sidebar/text/TextPropertyPanel.cxx        |    5 ++++
 sw/source/uibase/sidebar/PagePropertyPanel.cxx       |   11 +++++++++
 sw/source/uibase/sidebar/WrapPropertyPanel.cxx       |    8 ++++++
 18 files changed, 144 insertions(+), 18 deletions(-)

New commits:
commit d3d2453432a59fbba3a8f8c44260982bf67ec939
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Apr 15 21:56:23 2015 +0100

    Unregister sidebar ControllerItems at the right time.
    
    Otherwise they linger post-dispose, wreaking havoc.
    
    Change-Id: I6d0981ee15e82111bc825c75d28b703e5a5d266b

diff --git a/include/sfx2/ctrlitem.hxx b/include/sfx2/ctrlitem.hxx
index aa38dc0..24f64d9 100644
--- a/include/sfx2/ctrlitem.hxx
+++ b/include/sfx2/ctrlitem.hxx
@@ -56,6 +56,7 @@ public:
                         SfxControllerItem(); // for arrays
                         SfxControllerItem( sal_uInt16 nId, SfxBindings & );
     virtual             ~SfxControllerItem();
+    virtual void        dispose();
 
     void                Bind( sal_uInt16 nNewId, SfxBindings * = 0);    // Register in SfxBindings
     void                UnBind();
diff --git a/include/sfx2/sidebar/ControllerItem.hxx b/include/sfx2/sidebar/ControllerItem.hxx
index f06ae5e..025106e 100644
--- a/include/sfx2/sidebar/ControllerItem.hxx
+++ b/include/sfx2/sidebar/ControllerItem.hxx
@@ -80,6 +80,9 @@ public:
         SfxBindings &rBindings,
         ItemUpdateReceiverInterface& rItemUpdateReceiver);
 
+    /// releases our action listener
+    virtual void dispose() SAL_OVERRIDE;
+
     virtual ~ControllerItem();
 
     /** Returns </TRUE> when the slot/command has not been disabled.
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index 75d054c..c9d7d4af 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -81,6 +81,14 @@ void AlignmentPropertyPanel::dispose()
     mpCtrlDial.clear();
     mpMtrAngle.clear();
     mpCbStacked.clear();
+
+    maAlignHorControl.dispose();
+    maLeftIndentControl.dispose();
+    maMergeCellControl.dispose();
+    maWrapTextControl.dispose();
+    maAngleControl.dispose();
+    maStackControl.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
index 4410c79..5dae73b 100644
--- a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
+++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx
@@ -151,6 +151,14 @@ void CellAppearancePropertyPanel::dispose()
     mpTBLineStyle.clear();
     mpTBLineColor.clear();
     mpCBXShowGrid.clear();
+
+    maLineStyleControl.dispose();
+    maBorderOuterControl.dispose();
+    maBorderInnerControl.dispose();
+    maGridShowControl.dispose();
+    maBorderTLBRControl.dispose();
+    maBorderBLTRControl.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
index 6efc79d..035b65b 100644
--- a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx
@@ -81,6 +81,10 @@ void NumberFormatPropertyPanel::dispose()
     mpEdLeadZeroes.clear();
     mpBtnNegRed.clear();
     mpBtnThousand.clear();
+
+    maNumFormatControl.dispose();
+    maFormatControl.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/sfx2/source/control/ctrlitem.cxx b/sfx2/source/control/ctrlitem.cxx
index c1fa162..0be5e36 100644
--- a/sfx2/source/control/ctrlitem.cxx
+++ b/sfx2/source/control/ctrlitem.cxx
@@ -218,16 +218,19 @@ SfxControllerItem::SfxControllerItem( sal_uInt16 nID, SfxBindings &rBindings ):
 }
 
 
-// unregisteres the item in the bindings
+// unregisters the item in the bindings
 
 SfxControllerItem::~SfxControllerItem()
 {
+    dispose();
+}
+
+void SfxControllerItem::dispose()
+{
     if ( IsBound() )
         pBindings->Release(*this);
 }
 
-
-
 void SfxControllerItem::StateChanged
 (
     sal_uInt16,          // <SID> of the triggering slot
diff --git a/sfx2/source/sidebar/ControllerItem.cxx b/sfx2/source/sidebar/ControllerItem.cxx
index db7f155..b91c383 100644
--- a/sfx2/source/sidebar/ControllerItem.cxx
+++ b/sfx2/source/sidebar/ControllerItem.cxx
@@ -117,8 +117,16 @@ ControllerItem::ControllerItem (
 
 ControllerItem::~ControllerItem (void)
 {
+    dispose();
+}
+
+void ControllerItem::dispose()
+{
     if (mxFrameActionListener.is())
         mxFrameActionListener->dispose();
+    mxFrameActionListener.clear();
+
+    SfxControllerItem::dispose();
 }
 
 void ControllerItem::StateChanged (
diff --git a/svx/source/sidebar/area/AreaPropertyPanel.cxx b/svx/source/sidebar/area/AreaPropertyPanel.cxx
index bc731f9..2232e5f2 100644
--- a/svx/source/sidebar/area/AreaPropertyPanel.cxx
+++ b/svx/source/sidebar/area/AreaPropertyPanel.cxx
@@ -128,6 +128,18 @@ void AreaPropertyPanel::dispose()
     mpLBTransType.clear();
     mpMTRTransparent.clear();
     mpBTNGradient.clear();
+
+    maStyleControl.dispose();
+    maColorControl.dispose();
+    maGradientControl.dispose();
+    maHatchControl.dispose();
+    maBitmapControl.dispose();
+    maGradientListControl.dispose();
+    maHatchListControl.dispose();
+    maBitmapListControl.dispose();
+    maFillTransparenceController.dispose();
+    maFillFloatTransparenceController.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx b/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
index 933b5f3..d048416 100644
--- a/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
+++ b/svx/source/sidebar/graphic/GraphicPropertyPanel.cxx
@@ -81,6 +81,16 @@ void GraphicPropertyPanel::dispose()
     mpMtrGreen.clear();
     mpMtrBlue.clear();
     mpMtrGamma.clear();
+
+    maBrightControl.dispose();
+    maContrastControl.dispose();
+    maTransparenceControl.dispose();
+    maRedControl.dispose();
+    maGreenControl.dispose();
+    maBlueControl.dispose();
+    maGammaControl.dispose();
+    maModeControl.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx b/svx/source/sidebar/line/LinePropertyPanel.cxx
index 12b0f33..f05c92a 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanel.cxx
@@ -212,6 +212,18 @@ void LinePropertyPanel::dispose()
     mpLBEdgeStyle.clear();
     mpFTCapStyle.clear();
     mpLBCapStyle.clear();
+
+    maStyleControl.dispose();
+    maDashControl.dispose();
+    maWidthControl.dispose();
+    maStartControl.dispose();
+    maEndControl.dispose();
+    maLineEndListControl.dispose();
+    maLineStyleListControl.dispose();
+    maTransControl.dispose();
+    maEdgeStyle.dispose();
+    maCapStyle.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
index 8ba3f99..7dfb3f6 100644
--- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
+++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
@@ -765,6 +765,15 @@ void ParaPropertyPanel::dispose()
     mpLeftIndent.clear();
     mpRightIndent.clear();
     mpFLineIndent.clear();
+
+    maLRSpaceControl.dispose();
+    maULSpaceControl.dispose();
+    maOutLineLeftControl.dispose();
+    maOutLineRightControl.dispose();
+    maDecIndentControl.dispose();
+    maIncIndentControl.dispose();
+    m_aMetricCtl.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index b352332..c9684c6 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -136,6 +136,21 @@ void PosSizePropertyPanel::dispose()
     mpDial.clear();
     mpFtFlip.clear();
     mpFlipTbx.clear();
+
+    maTransfPosXControl.dispose();
+    maTransfPosYControl.dispose();
+    maTransfWidthControl.dispose();
+    maTransfHeightControl.dispose();
+
+    maSvxAngleControl.dispose();
+    maRotXControl.dispose();
+    maRotYControl.dispose();
+    maProPosControl.dispose();
+    maProSizeControl.dispose();
+    maAutoWidthControl.dispose();
+    maAutoHeightControl.dispose();
+    m_aMetricCtl.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx
index 57ebb7d..af7c2b6 100644
--- a/svx/source/sidebar/text/TextPropertyPanel.cxx
+++ b/svx/source/sidebar/text/TextPropertyPanel.cxx
@@ -128,6 +128,11 @@ void TextPropertyPanel::dispose()
     mpToolBoxSpacing.clear();
     mpToolBoxFontColorSw.clear();
     mpToolBoxFontColor.clear();
+
+    maFontSizeControl.dispose();
+    maUnderlineControl.dispose();
+    maSpacingControl.dispose();
+
     PanelLayout::dispose();
 }
 
diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.cxx b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
index 53fd3af..d35ac67 100644
--- a/sw/source/uibase/sidebar/PagePropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
@@ -221,6 +221,14 @@ void PagePropertyPanel::dispose()
     mpToolBoxMargin.clear();
     mpToolBoxSize.clear();
     mpToolBoxColumn.clear();
+
+    m_aSwPagePgULControl.dispose();
+    m_aSwPagePgLRControl.dispose();
+    m_aSwPagePgSizeControl.dispose();
+    m_aSwPagePgControl.dispose();
+    m_aSwPageColControl.dispose();
+    m_aSwPagePgMetricControl.dispose();
+
     PanelLayout::dispose();
 }
 
@@ -482,6 +490,9 @@ void PagePropertyPanel::NotifyItemUpdate(
 {
     (void)bIsEnabled;
 
+    if (IsDisposed())
+        return;
+
     switch( nSId )
     {
     case SID_ATTR_PAGE_COLUMN:
diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
index 39f68c3..a388d42 100644
--- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
@@ -102,6 +102,14 @@ void WrapPropertyPanel::dispose()
     mpRBWrapParallel.clear();
     mpRBWrapThrough.clear();
     mpRBIdealWrap.clear();
+
+    maSwNoWrapControl.dispose();
+    maSwWrapLeftControl.dispose();
+    maSwWrapRightControl.dispose();
+    maSwWrapParallelControl.dispose();
+    maSwWrapThroughControl.dispose();
+    maSwWrapIdealControl.dispose();
+
     PanelLayout::dispose();
 }
 
commit 389d3e6f01264b8d94b0f40cd8faecc4c954a838
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Apr 15 21:41:43 2015 +0100

    Properly dispose old sidebar Panels when we switch panel.
    
    Introduced in:
         "vclwidget: convert lots more sites to use VclPtr"
    
    Change-Id: I1a3741b8a0369a90d71885e9cbfa4a2b1408c410

diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index bbdac3e..ec1a127 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -202,8 +202,21 @@ bool Deck::ProcessWheelEvent(CommandEvent* pCommandEvent)
     return true;
 }
 
-void Deck::SetPanels (const SharedPanelContainer& rPanels)
+/**
+ * This container may contain existing panels that are
+ * being re-used, and new ones too.
+ */
+void Deck::ResetPanels (const SharedPanelContainer& rPanels)
 {
+    // First dispose old panels we no longer need.
+    for (size_t i = 0; i < maPanels.size(); i++)
+    {
+        bool bFound = false;
+        for (size_t j = 0; j < rPanels.size(); j++)
+            bFound = bFound || (maPanels[i].get() == rPanels[j].get());
+        if (!bFound) // this one didn't survive.
+            maPanels[i].disposeAndClear();
+    }
     maPanels = rPanels;
 
     RequestLayout();
diff --git a/sfx2/source/sidebar/Deck.hxx b/sfx2/source/sidebar/Deck.hxx
index d4416ab..b2f35af 100644
--- a/sfx2/source/sidebar/Deck.hxx
+++ b/sfx2/source/sidebar/Deck.hxx
@@ -52,7 +52,7 @@ public:
     const ::rtl::OUString& GetId (void) const { return msId;}
     DeckTitleBar* GetTitleBar (void) const;
     Rectangle GetContentArea (void) const;
-    void SetPanels (const SharedPanelContainer& rPanels);
+    void ResetPanels (const SharedPanelContainer& rPanels);
     const SharedPanelContainer& GetPanels (void) const { return maPanels;}
     void RequestLayout (void);
     vcl::Window* GetPanelParentWindow (void);
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 35cf2a9..569ef73 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -527,7 +527,6 @@ void SidebarController::SwitchToDeck (
 
     const bool bForceNewDeck ((mnRequestedForceFlags&SwitchFlag_ForceNewDeck)!=0);
     const bool bForceNewPanels ((mnRequestedForceFlags&SwitchFlag_ForceNewPanels)!=0);
-    mnRequestedForceFlags = SwitchFlag_NoForce;
 
     if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)
         || bForceNewDeck)
@@ -593,7 +592,7 @@ void SidebarController::SwitchToDeck (
     const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
     SharedPanelContainer aNewPanels;
     const SharedPanelContainer& rCurrentPanels (mpCurrentDeck->GetPanels());
-    // FIXME: concerns wrt. dispose / lifecycle when we re-use panels here...
+
     aNewPanels.resize(nNewPanelCount);
     sal_Int32 nWriteIndex (0);
     bool bHasPanelSetChanged (false);
@@ -609,21 +608,18 @@ void SidebarController::SwitchToDeck (
 
         // Find the corresponding panel among the currently active
         // panels.
-        SharedPanelContainer::const_iterator iPanel;
-        if (bForceNewPanels)
-        {
-            // All panels have to be created in any case.  There is no
-            // point in searching already existing panels.
-            iPanel = rCurrentPanels.end();
-        }
-        else
+        SharedPanelContainer::const_iterator iPanel = rCurrentPanels.end();
+
+        if (!bForceNewPanels)
         {
             iPanel = rCurrentPanels.end();
             for (auto a = rCurrentPanels.begin(); a != rCurrentPanels.end(); ++a)
             {
-                iPanel = a;
-                if ((*iPanel)->HasIdPredicate(rPanelContexDescriptor.msId))
+                if ((*a)->HasIdPredicate(rPanelContexDescriptor.msId))
+                {
+                    iPanel = a;
                     break;
+                }
             }
         }
         if (iPanel != rCurrentPanels.end())
@@ -669,7 +665,7 @@ void SidebarController::SwitchToDeck (
         mpParentWindow->GetSizePixel().Width()-TabBar::GetDefaultWidth() * mpTabBar->GetDPIScaleFactor(),
         mpParentWindow->GetSizePixel().Height());
 
-    mpCurrentDeck->SetPanels(aNewPanels);
+    mpCurrentDeck->ResetPanels(aNewPanels);
     mpCurrentDeck->Show();
 
     mpParentWindow->SetText(rDeckDescriptor.msTitle);


More information about the Libreoffice-commits mailing list