summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-01-28 08:43:12 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2021-01-28 17:08:47 +0100
commitd249bd5a3dfe13052ce9aa91bad94ec7d60604d4 (patch)
treebac7543b6d1f7c85ae449c10d2d6f7ab78ea9180 /vcl/win
parent33656a6c7500d0f799b0e4ed97bda0a9e58a7010 (diff)
WIN handle GetMessageW return values
GetMessageW returns a BOOL with three defined return values; a bit unexpected (-1 = error, 0 = WM_QUIT, * = dispatch message). So this tries to handle the non-dispatch results in some way. It's not clear for me, if there is some sensible way to "recover" from an error, but from all I've read it doesn't look like it. "Recover" means in this case, that the last call failed but next call may still succeed without changing the parameters. Change-Id: Ib1f366c7ce8b48158d1935938b49d8da991b30e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110043 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/dtrans/MtaOleClipb.cxx23
-rw-r--r--vcl/win/dtrans/target.cxx10
2 files changed, 25 insertions, 8 deletions
diff --git a/vcl/win/dtrans/MtaOleClipb.cxx b/vcl/win/dtrans/MtaOleClipb.cxx
index 6fc789e27d9d..f6e471925516 100644
--- a/vcl/win/dtrans/MtaOleClipb.cxx
+++ b/vcl/win/dtrans/MtaOleClipb.cxx
@@ -45,6 +45,8 @@
#include <systools/win32/comtools.hxx>
+#include <comphelper/windowserrorstring.hxx>
+
// namespace directives
using osl::MutexGuard;
@@ -642,22 +644,29 @@ unsigned int CMtaOleClipboard::run( )
createMtaOleReqWnd( );
- unsigned int nRet;
+ unsigned int nRet = ~0U; // = error
if ( IsWindow( m_hwndMtaOleReqWnd ) )
{
if ( nullptr != m_hEvtThrdReady )
SetEvent( m_hEvtThrdReady );
+ nRet = 0;
+
// pumping messages
MSG msg;
- while( GetMessageW( &msg, nullptr, 0, 0 ) )
- DispatchMessageW( &msg );
-
- nRet = 0;
+ BOOL bRet;
+ while ((bRet = GetMessageW(&msg, nullptr, 0, 0)) != 0)
+ {
+ if (-1 == bRet)
+ {
+ SAL_WARN("vcl.win.dtrans", "GetMessageW failed: " << WindowsErrorString(GetLastError()));
+ nRet = ~0U;
+ break;
+ }
+ DispatchMessageW(&msg);
+ }
}
- else
- nRet = ~0U;
OleUninitialize( );
diff --git a/vcl/win/dtrans/target.cxx b/vcl/win/dtrans/target.cxx
index adddabab7038..45a8515bd414 100644
--- a/vcl/win/dtrans/target.cxx
+++ b/vcl/win/dtrans/target.cxx
@@ -30,6 +30,8 @@
#include "targetdragcontext.hxx"
#include <rtl/ustring.h>
#include <osl/thread.h>
+#include <sal/log.hxx>
+#include <comphelper/windowserrorstring.hxx>
#include "DOTransferable.hxx"
@@ -206,8 +208,14 @@ DWORD WINAPI DndTargetOleSTAFunc(LPVOID pParams)
DWORD threadId= GetCurrentThreadId();
// We force the creation of a thread message queue. This is necessary
// for a later call to AttachThreadInput
- while( GetMessageW(&msg, nullptr, 0, 0) )
+ BOOL bRet;
+ while ((bRet = GetMessageW(&msg, nullptr, 0, 0)) != 0)
{
+ if (-1 == bRet)
+ {
+ SAL_WARN("vcl.win.dtrans", "GetMessageW failed: " << WindowsErrorString(GetLastError()));
+ break;
+ }
if( msg.message == WM_REGISTERDRAGDROP)
{
DropTarget *pTarget= reinterpret_cast<DropTarget*>(msg.wParam);