From 15be0847190fee716689938e70fcb4ade208d97f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 20 Dec 2023 11:21:27 +0200 Subject: tdf#156820 Fix crash in custom color picker which requires (*) keeping ColorPicker alive during the runAsync in ColorPicker::startExecuteModal (*) keeping the PaletteManager alive during the ExecuteAsync in PaletteManager::PopupCOlorPicker Noting that MattK debugged the cause of this. Change-Id: I07efe8e6514f8882b1347c79c6150578c234bb9d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161054 Tested-by: Noel Grandin Reviewed-by: Noel Grandin (cherry picked from commit 78ccae0d42d168f845ddbd7cb694d80dfb04f84d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161161 Tested-by: Jenkins Reviewed-by: Xisco Fauli (cherry picked from commit 97a81fffc1c2ab77749c462b61b3eed860b09d77) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161164 --- svx/source/tbxctrls/PaletteManager.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'svx') diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 1a48c403feb2..cc53c3ab74c8 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -405,15 +405,16 @@ void PaletteManager::PopupColorPicker(weld::Window* pParent, const OUString& aCo m_pColorDlg = std::make_unique(); m_pColorDlg->SetColor(rInitialColor); m_pColorDlg->SetMode(svtools::ColorPickerMode::Modify); - m_pColorDlg->ExecuteAsync(pParent, [this, aCommandCopy] (sal_Int32 nResult) { + std::shared_ptr xSelf(shared_from_this()); + m_pColorDlg->ExecuteAsync(pParent, [xSelf, aCommandCopy] (sal_Int32 nResult) { if (nResult == RET_OK) { - Color aLastColor = m_pColorDlg->GetColor(); + Color aLastColor = xSelf->m_pColorDlg->GetColor(); OUString sColorName = "#" + aLastColor.AsRGBHexString().toAsciiUpperCase(); NamedColor aNamedColor(aLastColor, sColorName); - SetSplitButtonColor(aNamedColor); - AddRecentColor(aLastColor, sColorName); - maColorSelectFunction(aCommandCopy, aNamedColor); + xSelf->SetSplitButtonColor(aNamedColor); + xSelf->AddRecentColor(aLastColor, sColorName); + xSelf->maColorSelectFunction(aCommandCopy, aNamedColor); } }); } -- cgit