Kaydet (Commit) e3d73711 authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#124579: ensure to provide an event to wake up main loop when notifying

Without that, Request::waitProcessMessages might wait indefinitely for
Application::Yield() to return; while the latter would wait for a message
in GetMessage. If there's no visible LO window, the message might never
arrive by itself.
Co-authored-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>

Change-Id: Ie2622053a8d4467eb1cbd579d8496cb5ddef08aa
Reviewed-on: https://gerrit.libreoffice.org/70346Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
Tested-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 5c32ba63
......@@ -19,6 +19,7 @@
#include "asyncrequests.hxx"
#include <vcl/svapp.hxx>
#include <vcl/winscheduler.hxx>
#include <osl/mutex.hxx>
namespace fpicker{
......@@ -56,6 +57,10 @@ void Request::waitProcessMessages()
void Request::notify()
{
m_aJoiner.set();
// Make sure that main loop receives at least this message to return from GetMessage and recheck
// the condition, even in case when there's no visible application windows present, and thus no
// other messages might arrive to the main loop.
WinScheduler::PostDummyMessage();
}
AsyncRequests::AsyncRequests(const RequestHandlerRef& rHandler)
......
......@@ -31,6 +31,11 @@ struct VCL_DLLPUBLIC WinScheduler final
/// Hack for Windows native dialogs, which run the main loop, so we can't
/// use the direct processing shortcut.
static void SetForceRealTimer();
// Posting a dummy messages might be needed to ensure that main loop eventually returns from
// GetMessage ("wakes up") in modes without a visible window. This, e.g., might be needed to
// let main thread recheck a condition set from another thread.
static void PostDummyMessage();
};
#endif // _WIN32
......
......@@ -25,12 +25,18 @@
#include <win/saldata.hxx>
#include <win/salinst.h>
void WinScheduler::SetForceRealTimer()
namespace
{
BOOL const ret
= PostMessageW(GetSalData()->mpInstance->mhComWnd, SAL_MSG_FORCE_REAL_TIMER, 0, 0);
void PostMessageToComWnd(UINT nMsg)
{
BOOL const ret = PostMessageW(GetSalData()->mpInstance->mhComWnd, nMsg, 0, 0);
SAL_WARN_IF(0 == ret, "vcl.schedule", "ERROR: PostMessage() failed!");
}
}
void WinScheduler::SetForceRealTimer() { PostMessageToComWnd(SAL_MSG_FORCE_REAL_TIMER); }
void WinScheduler::PostDummyMessage() { PostMessageToComWnd(SAL_MSG_DUMMY); }
#endif // _WIN32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment