[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - include/svx reportdesign/source svx/source

Caolán McNamara caolanm at redhat.com
Mon Nov 20 08:45:53 UTC 2017


 include/svx/colorbox.hxx                 |    2 -
 include/svx/colorwindow.hxx              |    4 +-
 include/svx/tbcontrl.hxx                 |    2 -
 reportdesign/source/ui/dlg/Condition.cxx |    3 +-
 reportdesign/source/ui/dlg/Condition.hxx |    2 -
 svx/source/tbxctrls/PaletteManager.cxx   |    4 ++
 svx/source/tbxctrls/tbcontrl.cxx         |   42 ++++++++++++++++---------------
 7 files changed, 32 insertions(+), 27 deletions(-)

New commits:
commit e9def9676ba4cfa5a89f823811fff6a2f68e242a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Nov 9 13:32:24 2017 +0000

    Resolves: tdf#113695 crash in color picker after parent is closed
    
    Change-Id: If2217abed784bf24e37e3403fa33cd2663dc51a4
    Reviewed-on: https://gerrit.libreoffice.org/44548
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: David Tardon <dtardon at redhat.com>

diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx
index e2cb74962aad..9a1ed55d5efb 100644
--- a/include/svx/colorbox.hxx
+++ b/include/svx/colorbox.hxx
@@ -39,7 +39,7 @@ private:
     NamedColor m_aSelectedColor;
     sal_uInt16 m_nSlotId;
     bool m_bShowNoneButton;
-    std::unique_ptr<PaletteManager> m_xPaletteManager;
+    std::shared_ptr<PaletteManager> m_xPaletteManager;
     BorderColorStatus m_aBorderColorStatus;
 
     DECL_LINK(MenuActivateHdl, MenuButton *, void);
diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx
index 520a560880d1..05a3beb72090 100644
--- a/include/svx/colorwindow.hxx
+++ b/include/svx/colorwindow.hxx
@@ -63,7 +63,7 @@ private:
     OUString            maCommand;
     Link<const NamedColor&, void> maSelectedLink;
 
-    PaletteManager&     mrPaletteManager;
+    std::shared_ptr<PaletteManager> mxPaletteManager;
     BorderColorStatus&  mrBorderColorStatus;
 
     ColorSelectFunction maColorSelectFunction;
@@ -79,7 +79,7 @@ private:
 
 public:
     SvxColorWindow(const OUString& rCommand,
-                   PaletteManager& rPaletteManager,
+                   std::shared_ptr<PaletteManager>& rPaletteManager,
                    BorderColorStatus& rBorderColorStatus,
                    sal_uInt16 nSlotId,
                    const css::uno::Reference< css::frame::XFrame >& rFrame,
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 21c21f5e0c10..870a2d816ca9 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -207,7 +207,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public cppu::ImplInheritanceHelper<
                                                                                  css::frame::XSubToolbarController >
 {
     std::unique_ptr<svx::ToolboxButtonColorUpdater> m_xBtnUpdater;
-    std::unique_ptr<PaletteManager> m_xPaletteManager;
+    std::shared_ptr<PaletteManager> m_xPaletteManager;
     BorderColorStatus m_aBorderColorStatus;
     bool m_bSplitButton;
     ColorSelectFunction m_aColorSelectFunction;
diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx
index f93326f6eaec..40e5de78c7fa 100644
--- a/reportdesign/source/ui/dlg/Condition.cxx
+++ b/reportdesign/source/ui/dlg/Condition.cxx
@@ -105,6 +105,7 @@ void ConditionColorWrapper::operator()(const OUString& /*rCommand*/, const Named
 
 Condition::Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController )
     : VclHBox(_pParent)
+    , m_xPaletteManager(new PaletteManager)
     , m_aColorWrapper(this)
     , m_rController(_rController)
     , m_rAction(_rAction)
@@ -231,7 +232,7 @@ IMPL_LINK(Condition, DropdownClick, ToolBox*, pToolBox, void)
     m_aColorWrapper.SetSlotId(nSlotId);
     m_pColorFloat = VclPtr<SvxColorWindow>::Create(
                            OUString() /*m_aCommandURL*/,
-                           m_aPaletteManager,
+                           m_xPaletteManager,
                            m_aBorderColorStatus,
                            nSlotId,
                            nullptr,
diff --git a/reportdesign/source/ui/dlg/Condition.hxx b/reportdesign/source/ui/dlg/Condition.hxx
index 8fdfa0ad87ea..32d4a84584e0 100644
--- a/reportdesign/source/ui/dlg/Condition.hxx
+++ b/reportdesign/source/ui/dlg/Condition.hxx
@@ -87,7 +87,7 @@ namespace rptui
         sal_uInt16                  m_nBackgroundColorId;
         sal_uInt16                  m_nFontColorId;
         sal_uInt16                  m_nFontDialogId;
-        PaletteManager              m_aPaletteManager;
+        std::shared_ptr<PaletteManager> m_xPaletteManager;
         BorderColorStatus           m_aBorderColorStatus;
         ConditionColorWrapper       m_aColorWrapper;
 
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 2e181a10ed53..d85fbeb89f74 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -57,6 +57,7 @@ PaletteManager::PaletteManager() :
         pColorList = XColorList::CreateStdColorList();
     LoadPalettes();
     mnNumOfPalettes += m_Palettes.size();
+
 }
 
 PaletteManager::~PaletteManager()
@@ -290,7 +291,8 @@ void PaletteManager::AddRecentColor(const Color& rRecentColor, const OUString& r
 void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater)
 {
     mpBtnUpdater = pBtnUpdater;
-    mLastColor = mpBtnUpdater->GetCurrentColor();
+    if (mpBtnUpdater)
+        mLastColor = mpBtnUpdater->GetCurrentColor();
 }
 
 void PaletteManager::SetColorSelectFunction(const std::function<void(const OUString&, const NamedColor&)>& aColorSelectFunction)
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 61b56a852447..628bacad7065 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1255,7 +1255,7 @@ void SvxFontNameBox_Impl::Select()
 
 
 SvxColorWindow::SvxColorWindow(const OUString&            rCommand,
-                               PaletteManager&            rPaletteManager,
+                               std::shared_ptr<PaletteManager>& rPaletteManager,
                                BorderColorStatus&         rBorderColorStatus,
                                sal_uInt16                 nSlotId,
                                const Reference< XFrame >& rFrame,
@@ -1267,7 +1267,7 @@ SvxColorWindow::SvxColorWindow(const OUString&            rCommand,
                     rFrame ),
     theSlotId( nSlotId ),
     maCommand( rCommand ),
-    mrPaletteManager( rPaletteManager ),
+    mxPaletteManager( rPaletteManager ),
     mrBorderColorStatus( rBorderColorStatus ),
     maColorSelectFunction(aFunction)
 {
@@ -1326,7 +1326,7 @@ SvxColorWindow::SvxColorWindow(const OUString&            rCommand,
     mpPaletteListBox->SetStyle( mpPaletteListBox->GetStyle() | WB_BORDER | WB_AUTOSIZE );
     mpPaletteListBox->SetSelectHdl( LINK( this, SvxColorWindow, SelectPaletteHdl ) );
     mpPaletteListBox->AdaptDropDownLineCountToMaximum();
-    std::vector<OUString> aPaletteList = mrPaletteManager.GetPaletteList();
+    std::vector<OUString> aPaletteList = mxPaletteManager->GetPaletteList();
     for( std::vector<OUString>::iterator it = aPaletteList.begin(); it != aPaletteList.end(); ++it )
     {
         mpPaletteListBox->InsertEntry( *it );
@@ -1335,7 +1335,7 @@ SvxColorWindow::SvxColorWindow(const OUString&            rCommand,
     mpPaletteListBox->SelectEntry( aPaletteName );
     const sal_Int32 nSelectedEntry(mpPaletteListBox->GetSelectEntryPos());
     if (nSelectedEntry != LISTBOX_ENTRY_NOTFOUND)
-        mrPaletteManager.SetPalette(nSelectedEntry);
+        mxPaletteManager->SetPalette(nSelectedEntry);
 
     mpButtonAutoColor->SetClickHdl( LINK( this, SvxColorWindow, AutoColorClickHdl ) );
     mpButtonNoneColor->SetClickHdl( LINK( this, SvxColorWindow, AutoColorClickHdl ) );
@@ -1346,14 +1346,14 @@ SvxColorWindow::SvxColorWindow(const OUString&            rCommand,
     SetHelpId( HID_POPUP_COLOR );
     mpColorSet->SetHelpId( HID_POPUP_COLOR_CTRL );
 
-    mrPaletteManager.ReloadColorSet(*mpColorSet);
+    mxPaletteManager->ReloadColorSet(*mpColorSet);
     const sal_uInt32 nMaxItems(SvxColorValueSet::getMaxRowCount() * SvxColorValueSet::getColumnCount());
     Size aSize = mpColorSet->layoutAllVisible(nMaxItems);
     mpColorSet->set_height_request(aSize.Height());
     mpColorSet->set_width_request(aSize.Width());
 
-    mrPaletteManager.ReloadRecentColorSet(*mpRecentColorSet);
-    aSize = mpRecentColorSet->layoutAllVisible(mrPaletteManager.GetRecentColorCount());
+    mxPaletteManager->ReloadRecentColorSet(*mpRecentColorSet);
+    aSize = mpRecentColorSet->layoutAllVisible(mxPaletteManager->GetRecentColorCount());
     mpRecentColorSet->set_height_request(aSize.Height());
     mpRecentColorSet->set_width_request(aSize.Width());
 
@@ -1467,9 +1467,9 @@ IMPL_LINK(SvxColorWindow, SelectHdl, ValueSet*, pColorSet, void)
 
     if ( pColorSet != mpRecentColorSet )
     {
-         mrPaletteManager.AddRecentColor(aNamedColor.first, aNamedColor.second);
+         mxPaletteManager->AddRecentColor(aNamedColor.first, aNamedColor.second);
          if ( !IsInPopupMode() )
-            mrPaletteManager.ReloadRecentColorSet( *mpRecentColorSet );
+            mxPaletteManager->ReloadRecentColorSet(*mpRecentColorSet);
     }
 
     if ( IsInPopupMode() )
@@ -1483,9 +1483,9 @@ IMPL_LINK(SvxColorWindow, SelectHdl, ValueSet*, pColorSet, void)
 IMPL_LINK_NOARG(SvxColorWindow, SelectPaletteHdl, ListBox&, void)
 {
     sal_Int32 nPos = mpPaletteListBox->GetSelectEntryPos();
-    mrPaletteManager.SetPalette( nPos );
-    mrPaletteManager.ReloadColorSet(*mpColorSet);
-    mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount());
+    mxPaletteManager->SetPalette( nPos );
+    mxPaletteManager->ReloadColorSet(*mpColorSet);
+    mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mxPaletteManager->GetColorCount());
 }
 
 NamedColor SvxColorWindow::GetAutoColor() const
@@ -1515,7 +1515,7 @@ IMPL_LINK_NOARG(SvxColorWindow, OpenPickerClickHdl, Button*, void)
 
     if ( IsInPopupMode() )
         EndPopupMode();
-    mrPaletteManager.PopupColorPicker(maCommand, GetSelectEntryColor().first);
+    mxPaletteManager->PopupColorPicker(maCommand, GetSelectEntryColor().first);
 }
 
 void SvxColorWindow::StartSelection()
@@ -1543,10 +1543,10 @@ bool SvxColorWindow::IsNoSelection() const
 void SvxColorWindow::statusChanged( const css::frame::FeatureStateEvent& rEvent )
 {
     if ( rEvent.IsEnabled && rEvent.FeatureURL.Complete == ".uno:ColorTableState"
-         && mrPaletteManager.GetPalette() == 0)
+         && mxPaletteManager->GetPalette() == 0)
     {
-        mrPaletteManager.ReloadColorSet(*mpColorSet);
-        mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount());
+        mxPaletteManager->ReloadColorSet(*mpColorSet);
+        mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mxPaletteManager->GetColorCount());
     }
     else
     {
@@ -1609,8 +1609,8 @@ void SvxColorWindow::SelectEntry(const NamedColor& rNamedColor)
     if (!bFoundColor)
     {
         const OUString& rColorName = rNamedColor.second;
-        mrPaletteManager.AddRecentColor(rColor, rColorName, false);
-        mrPaletteManager.ReloadRecentColorSet(*mpRecentColorSet);
+        mxPaletteManager->AddRecentColor(rColor, rColorName, false);
+        mxPaletteManager->ReloadRecentColorSet(*mpRecentColorSet);
         SelectValueSetEntry(mpRecentColorSet, rColor);
     }
 }
@@ -2813,6 +2813,8 @@ void SvxColorToolBoxControl::EnsurePaletteManager()
 
 SvxColorToolBoxControl::~SvxColorToolBoxControl()
 {
+    if (m_xPaletteManager)
+        m_xPaletteManager->SetBtnUpdater(nullptr);
 }
 
 void SvxColorToolBoxControl::setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction)
@@ -2828,7 +2830,7 @@ VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow()
 
     VclPtrInstance<SvxColorWindow> pColorWin(
                             m_aCommandURL,
-                            *m_xPaletteManager,
+                            m_xPaletteManager,
                             m_aBorderColorStatus,
                             GetSlotId(),
                             m_xFrame,
@@ -3316,7 +3318,7 @@ void SvxColorListBox::createColorWindow()
 
     m_xColorWindow = VclPtr<SvxColorWindow>::Create(
                             OUString() /*m_aCommandURL*/,
-                            *m_xPaletteManager,
+                            m_xPaletteManager,
                             m_aBorderColorStatus,
                             m_nSlotId,
                             xFrame,


More information about the Libreoffice-commits mailing list