diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2025-01-02 16:18:03 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2025-01-09 11:55:02 +0100 |
commit | 1e06592574472cea476cf2d505d53c7838004fc0 (patch) | |
tree | 75e9e4a677edc09abce4180625b08c9a7022385f /vcl | |
parent | a7dd6c1503425e1e36993a53a9a2641733412340 (diff) |
cool#10782 vcl lok: avoid changing the current view during Yield
Commit 520cc546e2940bdfbc45eab1e569bb06bab17a9c (cool#10782 sfx2 lok:
fix bad view id on PDF export, 2024-12-20) provided a specific fix for
one case where spinning the main loop can result in callbacks being
emitted on the wrong view.
Hunting down all the SfxViewShell::Current() calls and auditing them if
they are problematic in practice is a large task, so it's desirable to
handle this problem in a more generic way.
Fix the problem by pushing/popping the current LOK view in
Application::Reschedule(), which is what e.g. the framework/ status bar
code uses during PDF export. This keeps the original problem fixed but
is more generic.
This requires storing function pointers in comphelper/, since normally
vcl/ code can't call SfxLokHelper, since sfx2/ already depends on vcl/.
The fix can be tested by reverting the original fix:
git show 520cc546e2940bdfbc45eab1e569bb06bab17a9c -- sfx2|git apply -R
and then running the testcase:
make -C sw -sr CppunitTest_sw_tiledrendering CPPUNIT_TEST_NAME=testPDFExportViewSwitch
which now passes even if the sfx2-level fix is not there. Keep that
specific fix, though: the less time we assume SfxViewShell::Current()
returns the correct view, the better.
Change-Id: Ic1811ff1e67f73fa5066af775d31589136b8502a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179993
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/svapp.cxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 06a21d733177..8de62eb4c5d1 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -401,7 +401,22 @@ bool Application::Reschedule( bool i_bAllEvents ) SAL_WARN("vcl.schedule", "Application::Reschedule(" << i_bAllEvents << ")"); return false; } - return ImplYield(false, i_bAllEvents); + int nOldView = -1; + if (comphelper::LibreOfficeKit::isActive()) + { + nOldView = comphelper::LibreOfficeKit::getView(); + } + bool bRet = ImplYield(false, i_bAllEvents); + if (comphelper::LibreOfficeKit::isActive()) + { + int nNewView = comphelper::LibreOfficeKit::getView(); + if (nOldView != -1 && nNewView != -1 && nOldView != nNewView) + { + // Yield changed the current view, restore the old value. + comphelper::LibreOfficeKit::setView(nOldView); + } + } + return bRet; } bool Application::IsUseSystemEventLoop() |