sd/source/ui/view/Outliner.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
New commits: commit b4d5f54ed4af520d22f52cf4c12299d2db9fb066 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Jun 6 20:55:28 2021 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Jun 15 09:31:37 2021 +0200 tdf#142478 fix crash when searching and a viewshell change occurs When searching a impress document for a word, and the word is in notes as welll as in the document, a crash happens (only when searching with "find all"). The regressing commit changed that the search is now bound to a view (and to a viewshell). When searching for words in notes and document, at the transition from "standard" to "notes" page kind mode, the view and viewshells are destroyed and the new one created again. The problem lies here as when we destroy the viewshell, we also destroy the search context and FuSearch objects, but we are still executing the search -> crash. The solution for this is that when we change the page kind, we take the FuSearch object from the old viewshell and put it into the newly created viewshell, so that we keep the FuSearch object alive and don't throw away the search context too. Change-Id: I50931cca2a20c5704f7450e3cc8b3466af4c5a3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116758 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 3b75f9add7ed80e803b0771d86892d6ca0f47e71) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117145 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index 2a6a41998e71..f7981cf4940b 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -61,6 +61,7 @@ #include <comphelper/lok.hxx> #include <comphelper/scopeguard.hxx> #include <VectorGraphicSearchContext.hxx> +#include <fusearch.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1550,6 +1551,11 @@ void SdOutliner::SetViewMode (PageKind ePageKind) bool bMatchMayExist = mbMatchMayExist; sd::ViewShellBase& rBase = pViewShell->GetViewShellBase(); + + rtl::Reference<sd::FuSearch> xFuSearch; + if (pViewShell->GetView()) + xFuSearch = pViewShell->GetView()->getSearchContext().getFunctionSearch(); + SetViewShell(std::shared_ptr<sd::ViewShell>()); sd::framework::FrameworkHelper::Instance(rBase)->RequestView( sViewURL, @@ -1560,7 +1566,11 @@ void SdOutliner::SetViewMode (PageKind ePageKind) // instead. But that would involve major restructuring of the // Outliner code. sd::framework::FrameworkHelper::Instance(rBase)->RequestSynchronousUpdate(); - SetViewShell(rBase.GetMainViewShell()); + + auto pNewViewShell = rBase.GetMainViewShell(); + SetViewShell(pNewViewShell); + if (xFuSearch.is() && pNewViewShell->GetView()) + pNewViewShell->GetView()->getSearchContext().setSearchFunction(xFuSearch); // Switching to another view shell has intermediatly called // EndSpelling(). A PrepareSpelling() is pending, so call that now. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits