sc/source/ui/view/gridwin.cxx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
New commits: commit 4529a8ce16ef791a4e572898149e831b2b537157 Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Thu Sep 30 14:10:12 2021 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Fri Oct 1 20:16:04 2021 +0200 sc: colorfilter dangling pointer fixed Upper call to aParam.RemoveAllEntriesByField can invalidate pEntry, making further calls to pEntry->SetQueryBy* illegal. Anyway at this branch we are disabling color filter, so this is not required. Change-Id: Ia595649975b659d28056ba3f3658c306e63088f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122822 Tested-by: Jenkins Reviewed-by: Vasily Melenchuk <vasily.melenc...@cib.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122929 Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 37f2ee4e9f72..99e5ca53eec1 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -934,6 +934,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) if (nSelected == nActive) { aParam.RemoveAllEntriesByField(rPos.Col()); + pEntry = nullptr; // invalidated by RemoveAllEntriesByField call // tdf#46184 reset filter options to default values aParam.eSearchType = utl::SearchParam::SearchType::Normal; @@ -941,16 +942,18 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) aParam.bDuplicate = true; aParam.bInplace = true; } - - // Get selected color from set - std::set<Color>::iterator it = aColors.begin(); - std::advance(it, nSelected - 1); - Color selectedColor = *it; - - if (eMode == AutoFilterMode::TextColor) - pEntry->SetQueryByTextColor(selectedColor); else - pEntry->SetQueryByBackgroundColor(selectedColor); + { + // Get selected color from set + std::set<Color>::iterator it = aColors.begin(); + std::advance(it, nSelected - 1); + Color selectedColor = *it; + + if (eMode == AutoFilterMode::TextColor) + pEntry->SetQueryByTextColor(selectedColor); + else + pEntry->SetQueryByBackgroundColor(selectedColor); + } } break;