summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-11-09 13:32:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-11-09 21:32:33 +0100
commitff89d2216a26a57e0682f6a80e5eade6dabd499a (patch)
treebdad67241b3972d533f988089451f9f0e8809661 /svx
parent6dc1087b37a9ce5bc9b728d6a23fef69a66bb3d2 (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>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx4
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx42
2 files changed, 25 insertions, 21 deletions
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,