summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-12-20 16:12:12 +0100
committerAndras Timar <andras.timar@collabora.com>2024-01-15 15:39:08 +0100
commit3e64b53e22d2e37d2e7b52bb8d81e827ce620c28 (patch)
treea3479891fa604812f2c54239a37915dccf1a8d11 /include
parentf1bc25d441137fce1b5a075ab4c905801e8f3d10 (diff)
cool#7865 sfx2 lok: fix bad view id on async command dispatch
If you try hard enough, it's possible to request an "add conditional format" dialog in one view and have the dialog pop up in an other view. This is related to cool#7853 but it focuses on the wider problem. What happens is that sometimes we do want to execute an uno command in an async way, e.g. one dialog opening an other dialog in its response handler: making sure the dialog is not manually / synchronously spinning the main loop while it's running is wanted. Also fixing each & every async command dispatch manually would be a lot of work. Fix the problem by remembering the current view in SfxHintPoster::Post() as it posts events to the main loop and restoring that view if necessary in SfxHintPoster::DoEvent_Impl(). Other comments: - An alternative would be to just dispatch all these UNO commands synchronously, but see above, there are cases where we want to stay async, a nested main loop would be worse. - An even more general fix would be to handle all calls to Application::PostUserEvent(), but vcl doesn't know what is the current view and would have trouble switching to that view (only sfx2 and higher up knows that), so do this only at a SfxHintPoster::Post() level, this is already meant to fix all async uno commands. - There was a single case in sd/ where we tried to dispatch an async event while switching views, so switch to a sync command dispatch there to avoid the problem. CppunitTest_sd_tiledrendering would hang without this and would emit a warning in SfxHintPoster::Post(). - Restore the sc/ code to do its async dispatch as it used to, so now CppunitTest_sc_tiledrendering's testOpenURL is a test case that covers this change. Change-Id: I765e618f55caad791aa1fe7569a32bcc31622525 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161071 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'include')
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--include/sfx2/request.hxx5
2 files changed, 7 insertions, 0 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 98eeccb74476..dc144503b8dd 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -93,6 +93,8 @@ public:
static void destroyView(int nId);
/// Set a view shell as current one.
static void setView(int nId);
+ /// Determines if a call to setView() is in progress or not.
+ static bool isSettingView();
/// Set the edit mode for a document with callbacks disabled.
static void setEditMode(int nMode, vcl::ITiledRenderable* pDoc);
/// Get view shell with id
diff --git a/include/sfx2/request.hxx b/include/sfx2/request.hxx
index 63c6544bfe43..0d846ec80fff 100644
--- a/include/sfx2/request.hxx
+++ b/include/sfx2/request.hxx
@@ -119,6 +119,11 @@ public:
/** Return the window that should be used as the parent for any dialogs this request creates
*/
weld::Window* GetFrameWeld() const;
+
+ void SetLokViewId(int nId);
+
+ int GetLokViewId() const;
+
private:
const SfxRequest& operator=(const SfxRequest &) = delete;
};