desktop/source/lib/init.cxx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
New commits: commit 4b70d9f1ce77ede9d1caab883aa895bd63f305db Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed Jul 23 20:35:45 2025 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Jul 29 14:47:56 2025 +0200 use SfxLokHelper::getViewId to get current view of this document which avoid two sets of callbacks intended for two different documents getting registered on the same view and trampling on eachother. invalidation events now go to the correct place and typing updates as expected. Change-Id: I36a630997b917efcd9f436522013f22d6a957023 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188346 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 4b1a73fbfc08..648f932631db 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4678,10 +4678,11 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, SetLastExceptionMsg(); LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); - - const int nView = SfxLokHelper::getCurrentView(); - if (nView < 0) + const int nView = SfxLokHelper::getViewId(pDocument->mnDocumentId); + SfxViewShell* pViewShell = SfxLokHelper::getViewOfId(nView); + if (!pViewShell) return; + assert(nView == pViewShell->GetViewShellId().get() && "otherwise we couldn't have found it"); const size_t nId = nView; if (pCallback != nullptr) @@ -4718,11 +4719,8 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, pDocument->mpCallbackFlushHandlers[nView]->addViewStates(pair.first); } - if (SfxViewShell* pViewShell = SfxViewShell::Current()) - { - pDocument->mpCallbackFlushHandlers[nView]->setViewId(pViewShell->GetViewShellId().get()); - pViewShell->setLibreOfficeKitViewCallback(pDocument->mpCallbackFlushHandlers[nView].get()); - } + pDocument->mpCallbackFlushHandlers[nView]->setViewId(nView); + pViewShell->setLibreOfficeKitViewCallback(pDocument->mpCallbackFlushHandlers[nView].get()); if (!pDocument->maFontsMissing.empty()) { @@ -4755,11 +4753,8 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, } else { - if (SfxViewShell* pViewShell = SfxViewShell::Current()) - { - pViewShell->setLibreOfficeKitViewCallback(nullptr); - pDocument->mpCallbackFlushHandlers[nView]->setViewId(-1); - } + pViewShell->setLibreOfficeKitViewCallback(nullptr); + pDocument->mpCallbackFlushHandlers[nView]->setViewId(-1); } }