summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2016-06-03 11:10:58 +0300
committerTor Lillqvist <tml@collabora.com>2016-06-03 11:11:31 +0300
commit90dcb7d3269340542cfed82b4c0133451cc66829 (patch)
tree32fe7c8613767a37c3b66186228f92cb548eb011 /vcl
parent4aee1237a59808cbd58c9c02870063d5a7156710 (diff)
Clean up Windows error reporting a bit
We have comphelper::WindowsErrorString(), so use it, in SAL_WARNs, right where an error happens. Get rid of the fairly unhelpful ImplWriteLastError() function. Avoid duplicated error reporting. Change-Id: I83374a65980b7c0ffa35fc493b4fb1f2e94f0dbb
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/win/saldata.hxx1
-rw-r--r--vcl/opengl/win/gdiimpl.cxx19
-rw-r--r--vcl/win/gdi/salvd.cxx13
-rw-r--r--vcl/win/window/salframe.cxx39
4 files changed, 23 insertions, 49 deletions
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 79ad3fb340e1..bb630da9c2df 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -175,7 +175,6 @@ LRESULT CALLBACK SalFrameWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM l
void EmitTimerCallback();
void SalTestMouseLeave();
-void ImplWriteLastError(DWORD lastError, const char *szApiCall);
long ImplHandleSalObjKeyMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
long ImplHandleSalObjSysCharMsg( HWND hWnd, WPARAM wParam, LPARAM lParam );
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 310eb14b6552..c20e755ab485 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -8,6 +8,8 @@
*/
#include "opengl/win/gdiimpl.hxx"
+
+#include <comphelper/windowserrorstring.hxx>
#include <desktop/exithelper.h>
#include <opengl/zone.hxx>
#include <o3tl/lru_map.hxx>
@@ -94,7 +96,7 @@ void WinOpenGLContext::makeCurrent()
if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC))
{
- SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent(): wglMakeCurrent failed: " << GetLastError());
+ SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << WindowsErrorString(GetLastError()));
return;
}
@@ -522,8 +524,7 @@ bool WinOpenGLContext::ImplInit()
if (!SetPixelFormat(m_aGLWin.hDC, WindowPix, &PixelFormatFront))
{
- ImplWriteLastError(GetLastError(), "SetPixelFormat in OpenGLContext::ImplInit");
- SAL_WARN("vcl.opengl", "SetPixelFormat failed");
+ SAL_WARN("vcl.opengl", "SetPixelFormat failed: " << WindowsErrorString(GetLastError()));
if (bFirstCall)
disableOpenGLAndTerminateForRestart();
bFirstCall = false;
@@ -533,8 +534,7 @@ bool WinOpenGLContext::ImplInit()
HGLRC hTempRC = wglCreateContext(m_aGLWin.hDC);
if (hTempRC == NULL)
{
- ImplWriteLastError(GetLastError(), "wglCreateContext in OpenGLContext::ImplInit");
- SAL_WARN("vcl.opengl", "wglCreateContext failed");
+ SAL_WARN("vcl.opengl", "wglCreateContext failed: "<< WindowsErrorString(GetLastError()));
if (bFirstCall)
disableOpenGLAndTerminateForRestart();
bFirstCall = false;
@@ -543,8 +543,7 @@ bool WinOpenGLContext::ImplInit()
if (!wglMakeCurrent(m_aGLWin.hDC, hTempRC))
{
- ImplWriteLastError(GetLastError(), "wglMakeCurrent in OpenGLContext::ImplInit");
- SAL_WARN("vcl.opengl", "wglMakeCurrent failed");
+ SAL_WARN("vcl.opengl", "wglMakeCurrent failed: "<< WindowsErrorString(GetLastError()));
if (bFirstCall)
disableOpenGLAndTerminateForRestart();
bFirstCall = false;
@@ -585,8 +584,7 @@ bool WinOpenGLContext::ImplInit()
m_aGLWin.hRC = wglCreateContextAttribsARB(m_aGLWin.hDC, hSharedCtx, attribs);
if (m_aGLWin.hRC == 0)
{
- ImplWriteLastError(GetLastError(), "wglCreateContextAttribsARB in OpenGLContext::ImplInit");
- SAL_WARN("vcl.opengl", "wglCreateContextAttribsARB failed");
+ SAL_WARN("vcl.opengl", "wglCreateContextAttribsARB failed: "<< WindowsErrorString(GetLastError()));
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hTempRC);
if (bFirstCall)
@@ -610,8 +608,7 @@ bool WinOpenGLContext::ImplInit()
if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC))
{
- ImplWriteLastError(GetLastError(), "wglMakeCurrent (with shared context) in OpenGLContext::ImplInit");
- SAL_WARN("vcl.opengl", "wglMakeCurrent failed");
+ SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << WindowsErrorString(GetLastError()));
if (bFirstCall)
disableOpenGLAndTerminateForRestart();
bFirstCall = false;
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index 2cfef6f5f770..1253cb87657f 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -19,6 +19,8 @@
#include <svsys.h>
+#include <comphelper/windowserrorstring.hxx>
+
#include <vcl/sysdata.hxx>
#include <win/wincomp.hxx>
@@ -35,6 +37,7 @@ HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY,
if ( nBitCount == 1 )
{
hBitmap = CreateBitmap( (int)nDX, (int)nDY, 1, 1, NULL );
+ SAL_WARN_IF( !hBitmap, "vcl", "CreateBitmap failed: " << WindowsErrorString( GetLastError() ) );
ppData = NULL;
}
else
@@ -61,6 +64,7 @@ HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY,
hBitmap = CreateDIBSection( hDC, &aBitmapInfo,
DIB_RGB_COLORS, ppData, NULL,
0 );
+ SAL_WARN_IF( !hBitmap, "vcl", "CreateDIBSection failed: " << WindowsErrorString( GetLastError() ) );
}
return hBitmap;
@@ -107,19 +111,15 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics,
else
{
hDC = CreateCompatibleDC( pGraphics->getHDC() );
- if( !hDC )
- ImplWriteLastError( GetLastError(), "CreateCompatibleDC in CreateVirtualDevice" );
+ SAL_WARN_IF( !hDC, "vcl", "CreateCompatibleDC failed: " << WindowsErrorString( GetLastError() ) );
void *pDummy;
hBmp = WinSalVirtualDevice::ImplCreateVirDevBitmap(pGraphics->getHDC(), nDX, nDY, nBitCount, &pDummy);
- if( !hBmp )
- ImplWriteLastError( GetLastError(), "ImplCreateVirDevBitmap in CreateVirtualDevice" );
+
// #124826# continue even if hBmp could not be created
// if we would return a failure in this case, the process
// would terminate which is not required
- DBG_ASSERT( hBmp, "WinSalInstance::CreateVirtualDevice(), could not create Bitmap!" );
-
bOk = (hDC != NULL);
}
@@ -247,7 +247,6 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY )
}
else
{
- ImplWriteLastError( GetLastError(), "ImplCreateVirDevBitmap in SetSize" );
mnWidth = 0;
mnHeight = 0;
return FALSE;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 6b5fa26b071c..4aced425f81a 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -31,6 +31,8 @@
#include <svsys.h>
+#include <comphelper/windowserrorstring.hxx>
+
#include <rtl/string.h>
#include <rtl/ustring.h>
@@ -437,8 +439,8 @@ SalFrame* ImplSalCreateFrame( WinSalInstance* pInst,
hWnd = CreateWindowExW( nExSysStyle, pClassName, L"", nSysStyle,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
hWndParent, 0, pInst->mhInst, (void*)pFrame );
- if( !hWnd )
- ImplWriteLastError( GetLastError(), "CreateWindowEx" );
+ SAL_WARN_IF(!hWnd, "vcl", "CreateWindowExW failed: " << WindowsErrorString(GetLastError()));
+
#if OSL_DEBUG_LEVEL > 1
// set transparency value
if( GetWindowExStyle( hWnd ) & WS_EX_LAYERED )
@@ -4381,7 +4383,7 @@ static WinSalMenuItem* ImplGetSalMenuItem( HMENU hMenu, UINT nPos, bool bByPosit
mi.cbSize = sizeof( mi );
mi.fMask = MIIM_DATA;
if( !GetMenuItemInfoW( hMenu, nPos, bByPosition, &mi) )
- ImplWriteLastError( GetLastError(), "ImplGetSalMenuItem" );
+ SAL_WARN("vcl", "GetMenuItemInfoW failed: " << WindowsErrorString(GetLastError()));
return (WinSalMenuItem *) mi.dwItemData;
}
@@ -4399,7 +4401,7 @@ static int ImplGetSelectedIndex( HMENU hMenu )
for(int i=0; i<n; i++ )
{
if( !GetMenuItemInfoW( hMenu, i, TRUE, &mi) )
- ImplWriteLastError( GetLastError(), "ImplGetSelectedIndex" );
+ SAL_WARN( "vcl", "GetMenuItemInfoW faled: " << WindowsErrorString( GetLastError() ) );
else
{
if( mi.fState & MFS_HILITE )
@@ -4543,7 +4545,7 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam )
// Fill background
if(!PatBlt( pDI->hDC, aRect.left, aRect.top, aRect.right-aRect.left, aRect.bottom-aRect.top, PATCOPY ))
- ImplWriteLastError(GetLastError(), "ImplDrawItem");
+ SAL_WARN("vcl", "PatBlt failed: " << WindowsErrorString(GetLastError()));
int lineHeight = aRect.bottom-aRect.top;
@@ -4627,7 +4629,7 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam )
(LPARAM)(LPWSTR) aStr.getStr(),
(WPARAM)0, aRect.left, aRect.top + (lineHeight - strSize.cy)/2, 0, 0,
DST_PREFIXTEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ) )
- ImplWriteLastError(GetLastError(), "ImplDrawItem");
+ SAL_WARN("vcl", "DrawStateW failed: " << WindowsErrorString(GetLastError()));
if( pSalMenuItem->mAccelText.getLength() )
{
@@ -4644,7 +4646,7 @@ static int ImplDrawItem(HWND, WPARAM wParam, LPARAM lParam )
(LPARAM)(LPWSTR) aStr.getStr(),
(WPARAM)0, aRect.right-strSizeA.cx-tm.tmMaxCharWidth, aRect.top + (lineHeight - strSizeA.cy)/2, 0, 0,
DST_TEXT | (fDisabled && !fSelected ? DSS_DISABLED : DSS_NORMAL) ) )
- ImplWriteLastError(GetLastError(), "ImplDrawItem");
+ SAL_WARN("vcl", "DrawStateW failed: " << WindowsErrorString(GetLastError()));
}
// Restore the original font and colors.
@@ -5936,29 +5938,6 @@ bool ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LR
return bResult;
}
-void ImplWriteLastError(DWORD lastError, const char *szApiCall)
-{
-#if OSL_DEBUG_LEVEL > 0
- LPVOID lpMsgBuf;
- if (FormatMessageA(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- lastError & 0xffff,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL ))
- {
- SAL_WARN("vcl", "API call: " << szApiCall << " returned " << lastError << " (0x" << std::hex << lastError << "): " << (LPTSTR) lpMsgBuf);
- LocalFree(lpMsgBuf);
- }
- else
- SAL_WARN("vcl", "API call: " << szApiCall << " returned " << lastError << " (0x" << std::hex << lastError << ")");
-#endif
-}
-
#ifdef _WIN32
bool HasAtHook()
{