WNT: check result of PostMessage()

... so the next time something overflows the main thread's message queue
it's easier to debug.

Change-Id: I90a35e46f3b2cab190c7da5e53024ec549159ac6
This commit is contained in:
Michael Stahl 2016-04-11 23:15:23 +02:00
parent 3bbd98301a
commit 6f047b5866
9 changed files with 111 additions and 34 deletions

View file

@ -27,7 +27,7 @@
to problems because they all use the one and only mutex called
SolarMutex.
In order to transfer clipboard requests to our sta thread we use a
hidden window an forward these requests via window messages.
hidden window and forward these requests via window messages.
*/
#ifdef _MSC_VER
@ -37,6 +37,7 @@
//#define UNICODE
#include <osl/diagnose.h>
#include <sal/log.hxx>
#include "MtaOleClipb.hxx"
#include <osl/conditn.hxx>
@ -589,7 +590,9 @@ LRESULT CMtaOleClipboard::sendMessage( UINT msg, WPARAM wParam, LPARAM lParam )
bool CMtaOleClipboard::postMessage( UINT msg, WPARAM wParam, LPARAM lParam )
{
return PostMessageA( m_hwndMtaOleReqWnd, msg, wParam, lParam ) ? true : false;
BOOL const ret = PostMessageA(m_hwndMtaOleReqWnd, msg, wParam, lParam);
SAL_WARN_IF(0 == ret, "dtrans", "ERROR: PostMessage() failed!");
return ret ? true : false;
}
// the window proc

View file

@ -416,11 +416,12 @@ void SAL_CALL CWinFileOpenImpl::cancel()
{
// simulate a mouse click to the
// cancel button
PostMessage(
BOOL const ret = PostMessage(
m_hwndFileOpenDlg,
WM_COMMAND,
MAKEWPARAM(IDCANCEL,BN_CLICKED),
(LPARAM)GetDlgItem(m_hwndFileOpenDlg, IDCANCEL));
SAL_WARN_IF(0 == ret, "fpicker", "ERROR: PostMessage() failed!");
}
}
@ -727,11 +728,12 @@ void SAL_CALL CWinFileOpenImpl::onInitDone()
m_FilePicker->resumeEventNotification();
//#105996 let vcl know that now a system window is active
PostMessage(
BOOL const ret = PostMessage(
HWND_BROADCAST,
RegisterWindowMessage(TEXT("SYSTEM_WINDOW_ACTIVATED")),
0,
0);
SAL_WARN_IF(0 == ret, "fpicker", "ERROR: PostMessage() failed!");
// call the parent function to center the
// dialog to its parent

View file

@ -248,11 +248,12 @@ sal_Bool CMtaFolderPicker::browseForFolder( )
}
// marshall request into the sta thread
PostMessageA(
BOOL const ret = PostMessageA(
m_hwndStaRequestWnd,
MSG_BROWSEFORFOLDER,
0,
reinterpret_cast< LPARAM >( &aReqCtx ) );
SAL_WARN_IF(0 == ret, "fpicker", "ERROR: PostMessage() failed!");
// waiting for the event to be signaled or
// window messages so that we don't block
@ -350,11 +351,12 @@ void SAL_CALL CMtaFolderPicker::cancel( )
{
// simulate a mouse click to the
// cancel button
PostMessageA(
BOOL const ret = PostMessageA(
m_hwnd,
WM_COMMAND,
MAKEWPARAM( IDCANCEL, BN_CLICKED ),
(LPARAM)GetDlgItem( m_hwnd, IDCANCEL ) );
SAL_WARN_IF(0 == ret, "fpicker", "ERROR: PostMessage() failed!");
}
}

View file

@ -305,8 +305,11 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
switch( lParam )
{
case WM_LBUTTONDBLCLK:
PostMessage( aExecuterWindow, WM_COMMAND, IDM_TEMPLATE, (LPARAM)hWnd );
{
BOOL const ret = PostMessage(aExecuterWindow, WM_COMMAND, IDM_TEMPLATE, (LPARAM)hWnd);
SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!");
break;
}
case WM_RBUTTONDOWN:
{
@ -322,7 +325,8 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
EnableMenuItem( popupMenu, IDM_TEMPLATE, MF_BYCOMMAND | (ShutdownIcon::bModalMode ? MF_GRAYED : MF_ENABLED) );
int m = TrackPopupMenuEx( popupMenu, TPM_RETURNCMD|TPM_LEFTALIGN|TPM_RIGHTBUTTON,
pt.x, pt.y, hWnd, NULL );
PostMessage( hWnd, 0, 0, 0 );
BOOL const ret = PostMessage( hWnd, 0, 0, 0 );
SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!");
switch( m )
{
case IDM_OPEN:
@ -347,7 +351,8 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
break;
}
PostMessage( aExecuterWindow, WM_COMMAND, m, (LPARAM)hWnd );
BOOL const ret2 = PostMessage(aExecuterWindow, WM_COMMAND, m, (LPARAM)hWnd);
SAL_WARN_IF(0 == ret2, "sfx.appl", "ERROR: PostMessage() failed!");
}
break;
}
@ -372,7 +377,8 @@ LRESULT CALLBACK listenerWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
nid.uID = ID_QUICKSTART;
Shell_NotifyIconA(NIM_DELETE, &nid);
PostMessage( aExecuterWindow, WM_COMMAND, IDM_EXIT, (LPARAM)hWnd );
BOOL const ret = PostMessage(aExecuterWindow, WM_COMMAND, IDM_EXIT, (LPARAM)hWnd);
SAL_WARN_IF(0 == ret, "sfx.appl", "ERROR: PostMessage() failed!");
}
else
return DefWindowProc(hWnd, uMsg, wParam, lParam);

View file

@ -869,7 +869,10 @@ void SalTimer::Start( sal_uLong nMS )
if ( pSalData->mpFirstInstance )
{
if ( pSalData->mnAppThreadId != GetCurrentThreadId() )
PostMessageW( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_STARTTIMER, 0, (LPARAM)nMS );
{
BOOL const ret = PostMessageW(pSalData->mpFirstInstance->mhComWnd, SAL_MSG_STARTTIMER, 0, (LPARAM)nMS);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
else
SendMessageW( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_STARTTIMER, 0, (LPARAM)nMS );
}

View file

@ -81,7 +81,10 @@ void WinSalTimer::Start( sal_uLong nMS )
if ( pSalData->mpFirstInstance )
{
if ( pSalData->mnAppThreadId != GetCurrentThreadId() )
PostMessageW( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_STARTTIMER, 0, (LPARAM)nMS );
{
BOOL const ret = PostMessageW(pSalData->mpFirstInstance->mhComWnd, SAL_MSG_STARTTIMER, 0, (LPARAM)nMS);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
else
SendMessageW( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_STARTTIMER, 0, (LPARAM)nMS );
}
@ -124,7 +127,11 @@ void CALLBACK SalTimerProc(PVOID, BOOLEAN)
// always post message when the timer fires, we will remove the ones
// that happened during execution of the callback later directly from
// the message queue
PostMessageW(pSalData->mpFirstInstance->mhComWnd, SAL_MSG_TIMER_CALLBACK, 0, 0);
BOOL const ret = PostMessageW(pSalData->mpFirstInstance->mhComWnd, SAL_MSG_TIMER_CALLBACK, 0, 0);
#if OSL_DEBUG_LEVEL > 0
if (0 == ret) // SEH prevents using SAL_WARN here?
fputs("ERROR: PostMessage() failed!", stderr);
#endif
#if defined ( __MINGW32__ ) && !defined ( _WIN64 )
}

View file

@ -1515,7 +1515,8 @@ bool WinSalPrinter::StartJob( const OUString* pFileName,
bWhile = FALSE;
}
while ( bWhile );
PostMessageW( GetSalData()->mpFirstInstance->mhComWnd, SAL_MSG_DUMMY, 0, 0 );
BOOL const ret = PostMessageW(GetSalData()->mpFirstInstance->mhComWnd, SAL_MSG_DUMMY, 0, 0);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
// bring up a file chooser if printing to file port but no file name given
OUString aOutFileName;

View file

@ -1061,7 +1061,9 @@ void WinSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
bool WinSalFrame::PostEvent(ImplSVEvent* pData)
{
return (bool)PostMessageW( mhWnd, SAL_MSG_USEREVENT, 0, (LPARAM)pData );
BOOL const ret = PostMessageW(mhWnd, SAL_MSG_USEREVENT, 0, (LPARAM)pData);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
return static_cast<bool>(ret);
}
void WinSalFrame::SetTitle( const OUString& rTitle )
@ -1207,7 +1209,10 @@ void WinSalFrame::Show( bool bVisible, bool bNoActivate )
// in the thread of the window, which has create this window.
// We post this message to avoid deadlocks
if ( GetSalData()->mnAppThreadId != GetCurrentThreadId() )
PostMessageW( mhWnd, SAL_MSG_SHOW, bVisible, bNoActivate );
{
BOOL const ret = PostMessageW(mhWnd, SAL_MSG_SHOW, bVisible, bNoActivate);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
else
ImplSalShow( mhWnd, bVisible, bNoActivate );
}
@ -2046,7 +2051,10 @@ void WinSalFrame::ToTop( sal_uInt16 nFlags )
// in the thread of the window, which has create this window.
// We post this message to avoid deadlocks
if ( GetSalData()->mnAppThreadId != GetCurrentThreadId() )
PostMessageW( mhWnd, SAL_MSG_TOTOP, nFlags, 0 );
{
BOOL const ret = PostMessageW( mhWnd, SAL_MSG_TOTOP, nFlags, 0 );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
else
ImplSalToTop( mhWnd, nFlags );
}
@ -3036,7 +3044,8 @@ static long ImplHandleMouseMsg( HWND hWnd, UINT nMsg,
vcl::Window *pWin = pFrame->GetWindow();
if( pWin && pWin->ImplGetWindowImpl()->mpFrameData->mnFocusId )
{
PostMessageW( hWnd, nMsg, wParam, lParam );
BOOL const ret = PostMessageW( hWnd, nMsg, wParam, lParam );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
return 1;
}
}
@ -3769,7 +3778,8 @@ static bool ImplHandlePaintMsg( HWND hWnd )
{
RECT* pRect = new RECT;
CopyRect( pRect, &aUpdateRect );
PostMessageW( hWnd, SAL_MSG_POSTPAINT, (WPARAM)pRect, 0 );
BOOL const ret = PostMessageW(hWnd, SAL_MSG_POSTPAINT, (WPARAM)pRect, 0);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
EndPaint( hWnd, &aPs );
}
@ -3805,7 +3815,10 @@ static void ImplHandlePaintMsg2( HWND hWnd, RECT* pRect )
delete pRect;
}
else
PostMessageW( hWnd, SAL_MSG_POSTPAINT, (WPARAM)pRect, 0 );
{
BOOL const ret = PostMessageW(hWnd, SAL_MSG_POSTPAINT, (WPARAM)pRect, 0);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame, RECT* pParentRect )
@ -3947,7 +3960,10 @@ static void ImplHandleMoveMsg( HWND hWnd )
ImplSalYieldMutexRelease();
}
else
PostMessageW( hWnd, SAL_MSG_POSTMOVE, 0, 0 );
{
BOOL const ret = PostMessageW( hWnd, SAL_MSG_POSTMOVE, 0, 0 );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
static void ImplCallSizeHdl( HWND hWnd )
@ -3968,7 +3984,10 @@ static void ImplCallSizeHdl( HWND hWnd )
ImplSalYieldMutexRelease();
}
else
PostMessageW( hWnd, SAL_MSG_POSTCALLSIZE, 0, 0 );
{
BOOL const ret = PostMessageW( hWnd, SAL_MSG_POSTCALLSIZE, 0, 0 );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
static void ImplHandleSizeMsg( HWND hWnd, WPARAM wParam, LPARAM lParam )
@ -4023,7 +4042,10 @@ static void ImplHandleFocusMsg( HWND hWnd )
ImplSalYieldMutexRelease();
}
else
PostMessageW( hWnd, SAL_MSG_POSTFOCUS, 0, 0 );
{
BOOL const ret = PostMessageW( hWnd, SAL_MSG_POSTFOCUS, 0, 0 );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
static void ImplHandleCloseMsg( HWND hWnd )
@ -4039,7 +4061,10 @@ static void ImplHandleCloseMsg( HWND hWnd )
ImplSalYieldMutexRelease();
}
else
PostMessageW( hWnd, WM_CLOSE, 0, 0 );
{
BOOL const ret = PostMessageW( hWnd, WM_CLOSE, 0, 0 );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
static long ImplHandleShutDownMsg( HWND hWnd )
@ -4122,7 +4147,8 @@ static void ImplHandleForcePalette( HWND hWnd )
{
if ( !ImplSalYieldMutexTryToAcquire() )
{
PostMessageW( hWnd, SAL_MSG_FORCEPALETTE, 0, 0 );
BOOL const ret = PostMessageW( hWnd, SAL_MSG_FORCEPALETTE, 0, 0 );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
return;
}
@ -4172,9 +4198,15 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, UINT nMsg,
if ( ImplSalYieldMutexTryToAcquire() )
bReleaseMutex = TRUE;
else if ( nMsg == WM_QUERYNEWPALETTE )
PostMessageW( hWnd, SAL_MSG_POSTQUERYNEWPAL, wParam, lParam );
{
BOOL const ret = PostMessageW(hWnd, SAL_MSG_POSTQUERYNEWPAL, wParam, lParam);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
else /* ( nMsg == WM_PALETTECHANGED ) */
PostMessageW( hWnd, SAL_MSG_POSTPALCHANGED, wParam, lParam );
{
BOOL const ret = PostMessageW(hWnd, SAL_MSG_POSTPALCHANGED, wParam, lParam);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
WinSalVirtualDevice*pTempVD;
@ -5904,7 +5936,10 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lP
{
MSG aMsg;
if( ! PeekMessageW( &aMsg, 0, WM_PAINT, WM_PAINT, PM_NOREMOVE | PM_NOYIELD ) )
PostMessageW( pSalData->mpFirstInstance->mhComWnd, SAL_MSG_POSTTIMER, 0, nCurTime );
{
BOOL const ret = PostMessageW(pSalData->mpFirstInstance->mhComWnd, SAL_MSG_POSTTIMER, 0, nCurTime);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
}
}

View file

@ -112,7 +112,10 @@ LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
ImplSalYieldMutexRelease();
}
else
PostMessageW( pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
{
BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
}
else if ( pData->message == WM_KILLFOCUS )
@ -129,7 +132,10 @@ LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
ImplSalYieldMutexRelease();
}
else
PostMessageW( pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
{
BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
}
else
pObject->mhLastFocusWnd = (HWND)pData->wParam;
@ -153,7 +159,10 @@ bool ImplSalPreDispatchMsg( MSG* pMsg )
ImplSalYieldMutexAcquireWithWait();
pObject = ImplFindSalObject( pMsg->hwnd );
if ( pObject && !pObject->IsMouseTransparent() )
PostMessageW( pObject->mhWnd, SALOBJ_MSG_TOTOP, 0, 0 );
{
BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_TOTOP, 0, 0);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
ImplSalYieldMutexRelease();
}
@ -288,7 +297,10 @@ LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM l
ImplSalYieldMutexAcquireWithWait();
pSysObj = GetSalObjWindowPtr( hWnd );
if ( pSysObj && !pSysObj->IsMouseTransparent() )
PostMessageW( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
{
BOOL const ret = PostMessageW( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
ImplSalYieldMutexRelease();
}
break;
@ -302,7 +314,10 @@ LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM l
rDef = FALSE;
}
else
PostMessageW( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
{
BOOL const ret = PostMessageW( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
break;
case SALOBJ_MSG_POSTFOCUS:
@ -319,7 +334,10 @@ LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM l
ImplSalYieldMutexRelease();
}
else
PostMessageW( hWnd, SALOBJ_MSG_POSTFOCUS, 0, 0 );
{
BOOL const ret = PostMessageW(hWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
}
rDef = FALSE;
break;