diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-11-09 13:32:24 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-11-09 21:32:33 +0100 |
commit | ff89d2216a26a57e0682f6a80e5eade6dabd499a (patch) | |
tree | bdad67241b3972d533f988089451f9f0e8809661 | |
parent | 6dc1087b37a9ce5bc9b728d6a23fef69a66bb3d2 (diff) |
Resolves: tdf#113695 crash in color picker after parent is closed
Change-Id: If2217abed784bf24e37e3403fa33cd2663dc51a4
Reviewed-on: https://gerrit.libreoffice.org/44545
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | include/svx/colorbox.hxx | 2 | ||||
-rw-r--r-- | include/svx/colorwindow.hxx | 4 | ||||
-rw-r--r-- | include/svx/tbcontrl.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Condition.cxx | 3 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Condition.hxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 42 |
7 files changed, 32 insertions, 27 deletions
diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx index 7b0f8905249c..f9655b28bc27 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 a782307df9fa..467acf31aaae 100644 --- a/include/svx/colorwindow.hxx +++ b/include/svx/colorwindow.hxx @@ -64,7 +64,7 @@ private: OUString maCommand; Link<const NamedColor&, void> maSelectedLink; - PaletteManager& mrPaletteManager; + std::shared_ptr<PaletteManager> mxPaletteManager; BorderColorStatus& mrBorderColorStatus; ColorSelectFunction maColorSelectFunction; @@ -80,7 +80,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 b9b8eb0db7b1..c5784bba03bc 100644 --- a/include/svx/tbcontrl.hxx +++ b/include/svx/tbcontrl.hxx @@ -209,7 +209,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; sal_uInt16 m_nSlotId; diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index 9545b26cbb16..72f86a5d7ddf 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 6abd8aa07435..f770928ee7e5 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 9a89e6ac4a48..35b376c3839c 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -58,6 +58,7 @@ PaletteManager::PaletteManager() : pColorList = XColorList::CreateStdColorList(); LoadPalettes(); mnNumOfPalettes += m_Palettes.size(); + } PaletteManager::~PaletteManager() @@ -295,7 +296,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 b23170484d7b..ceb6b4af4b77 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1245,7 +1245,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, @@ -1255,7 +1255,7 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand, ToolbarPopup( rFrame, pParentWindow, "palette_popup_window", "svx/ui/colorwindow.ui" ), theSlotId( nSlotId ), maCommand( rCommand ), - mrPaletteManager( rPaletteManager ), + mxPaletteManager( rPaletteManager ), mrBorderColorStatus( rBorderColorStatus ), maColorSelectFunction(aFunction) { @@ -1314,7 +1314,7 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand, mpPaletteListBox->SetStyle( mpPaletteListBox->GetStyle() | WB_BORDER ); 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 ); @@ -1323,7 +1323,7 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand, mpPaletteListBox->SelectEntry( aPaletteName ); const sal_Int32 nSelectedEntry(mpPaletteListBox->GetSelectedEntryPos()); if (nSelectedEntry != LISTBOX_ENTRY_NOTFOUND) - mrPaletteManager.SetPalette(nSelectedEntry); + mxPaletteManager->SetPalette(nSelectedEntry); mpButtonAutoColor->SetClickHdl( LINK( this, SvxColorWindow, AutoColorClickHdl ) ); mpButtonNoneColor->SetClickHdl( LINK( this, SvxColorWindow, AutoColorClickHdl ) ); @@ -1334,14 +1334,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()); @@ -1456,9 +1456,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() ) @@ -1472,9 +1472,9 @@ IMPL_LINK(SvxColorWindow, SelectHdl, ValueSet*, pColorSet, void) IMPL_LINK_NOARG(SvxColorWindow, SelectPaletteHdl, ListBox&, void) { sal_Int32 nPos = mpPaletteListBox->GetSelectedEntryPos(); - 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 @@ -1504,7 +1504,7 @@ IMPL_LINK_NOARG(SvxColorWindow, OpenPickerClickHdl, Button*, void) if ( IsInPopupMode() ) EndPopupMode(); - mrPaletteManager.PopupColorPicker(maCommand, GetSelectEntryColor().first); + mxPaletteManager->PopupColorPicker(maCommand, GetSelectEntryColor().first); } void SvxColorWindow::StartSelection() @@ -1534,10 +1534,10 @@ void SvxColorWindow::statusChanged( const css::frame::FeatureStateEvent& rEvent { if (rEvent.FeatureURL.Complete == ".uno:ColorTableState") { - if (rEvent.IsEnabled && mrPaletteManager.GetPalette() == 0) + if (rEvent.IsEnabled && mxPaletteManager->GetPalette() == 0) { - mrPaletteManager.ReloadColorSet(*mpColorSet); - mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mrPaletteManager.GetColorCount()); + mxPaletteManager->ReloadColorSet(*mpColorSet); + mpColorSet->layoutToGivenHeight(mpColorSet->GetSizePixel().Height(), mxPaletteManager->GetColorCount()); } } else @@ -1601,8 +1601,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); } } @@ -2849,6 +2849,8 @@ void SvxColorToolBoxControl::EnsurePaletteManager() SvxColorToolBoxControl::~SvxColorToolBoxControl() { + if (m_xPaletteManager) + m_xPaletteManager->SetBtnUpdater(nullptr); } void SvxColorToolBoxControl::setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction) @@ -2864,7 +2866,7 @@ VclPtr<vcl::Window> SvxColorToolBoxControl::createPopupWindow( vcl::Window* pPar VclPtrInstance<SvxColorWindow> pColorWin( m_aCommandURL, - *m_xPaletteManager, + m_xPaletteManager, m_aBorderColorStatus, m_nSlotId, m_xFrame, @@ -3380,7 +3382,7 @@ void SvxColorListBox::createColorWindow() m_xColorWindow = VclPtr<SvxColorWindow>::Create( OUString() /*m_aCommandURL*/, - *m_xPaletteManager, + m_xPaletteManager, m_aBorderColorStatus, m_nSlotId, xFrame, |