summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-11-17 12:29:56 +0100
committerJan Holesovsky <kendy@collabora.com>2014-11-17 23:19:48 +0100
commitbb92f43374d09206151c9640811bc28dfb2d94e4 (patch)
treee178437bb8ba46efb1ef05886237c703b2b9e071
parent4c85f9a370e4dfc1ffde4f1b6a54c98a0d7ece79 (diff)
windows: Improve logging.
Change-Id: I15e6d240b3c94af07e9b39cc16efb581869729f2
-rw-r--r--vcl/inc/win/saldata.hxx2
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx21
-rw-r--r--vcl/win/source/window/salframe.cxx73
3 files changed, 35 insertions, 61 deletions
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index e1ae8cc06ff2..2c0731eaa623 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -183,7 +183,7 @@ LRESULT CALLBACK SalFrameWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM l
void EmitTimerCallback();
void SalTestMouseLeave();
-bool ImplWriteLastError( DWORD lastError, const char *szApiCall );
+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/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index b803fd6ba4f2..cc1264b01e7d 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -23,6 +23,10 @@
#include <postmac.h>
#endif
+#if defined( WNT )
+#include <win/saldata.hxx>
+#endif
+
using namespace com::sun::star;
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
@@ -200,8 +204,6 @@ bool WGLisExtensionSupported(const char *extension)
if ((p==supported || p[-1]==' ') && (p[extlen]=='\0' || p[extlen]==' '))
return 1; // Match
}
-
- CHECK_GL_ERROR();
}
bool InitMultisample(PIXELFORMATDESCRIPTOR pfd, int& rPixelFormat,
@@ -767,7 +769,8 @@ bool OpenGLContext::init(HDC hDC, HWND hWnd)
bool OpenGLContext::ImplInit()
{
SAL_INFO("vcl.opengl", "OpenGLContext::ImplInit----start");
- PIXELFORMATDESCRIPTOR PixelFormatFront = // PixelFormat Tells Windows How We Want Things To Be
+ // PixelFormat tells Windows how we want things to be
+ PIXELFORMATDESCRIPTOR PixelFormatFront =
{
sizeof(PIXELFORMATDESCRIPTOR),
1, // Version Number
@@ -815,17 +818,25 @@ bool OpenGLContext::ImplInit()
return false;
}
- SetPixelFormat(m_aGLWin.hDC, WindowPix, &PixelFormatFront);
+ if (!SetPixelFormat(m_aGLWin.hDC, WindowPix, &PixelFormatFront))
+ {
+ ImplWriteLastError(GetLastError(), "SetPixelFormat in OpenGLContext::ImplInit");
+ SAL_WARN("vcl.opengl", "SetPixelFormat failed");
+ return false;
+ }
+
m_aGLWin.hRC = wglCreateContext(m_aGLWin.hDC);
if (m_aGLWin.hRC == NULL)
{
+ ImplWriteLastError(GetLastError(), "wglCreateContext in OpenGLContext::ImplInit");
SAL_WARN("vcl.opengl", "wglCreateContext failed");
return false;
}
if (!wglMakeCurrent(m_aGLWin.hDC, m_aGLWin.hRC))
{
- SAL_WARN("vcl.opengl", "wglMakeCurrent failed: " << GetLastError());
+ ImplWriteLastError(GetLastError(), "wglMakeCurrent in OpenGLContext::ImplInit");
+ SAL_WARN("vcl.opengl", "wglMakeCurrent failed");
return false;
}
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index d42b0f540a4d..d2fef8fc0903 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -5974,64 +5974,27 @@ bool ImplHandleGlobalMsg( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, LR
return bResult;
}
-bool ImplWriteLastError( DWORD lastError, const char *szApiCall )
+void ImplWriteLastError(DWORD lastError, const char *szApiCall)
{
- static int first=1;
- // if VCL_LOGFILE_ENABLED is set, Win32 API error messages can be written
- // to %TMP%/vcl.log or %TEMP%/vcl.log
- static char *logEnabled = getenv("VCL_LOGFILE_ENABLED");
- if( logEnabled )
- {
- bool bSuccess = FALSE;
- static char *szTmp = getenv("TMP");
- if( !szTmp || !*szTmp )
- szTmp = getenv("TEMP");
- if( szTmp && *szTmp )
- {
- char fname[5000];
- strcpy( fname, szTmp );
- if( fname[strlen(fname) - 1] != '\\' )
- strcat( fname, "\\");
- strcat( fname, "vcl.log" );
- FILE *fp = fopen( fname, "a" ); // always append
- if( fp )
- {
- if( first )
- {
- first = 0;
- fprintf( fp, "Process ID: %ld (0x%lx)\n", GetCurrentProcessId(), GetCurrentProcessId() );
- }
- time_t aclock;
- time( &aclock ); // Get time in seconds
- struct tm *newtime = localtime( &aclock ); // Convert time to struct tm form
- fprintf( fp, asctime( newtime ) ); // print time stamp
-
- fprintf( fp, "%s returned %lu (0x%lx)\n", szApiCall, lastError, lastError );
- bSuccess = TRUE; // may be FormatMessage fails but we wrote at least the error code
-
- LPVOID lpMsgBuf;
- if (FormatMessageA(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- lastError,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPSTR) &lpMsgBuf,
- 0,
- NULL ))
- {
- fprintf( fp, " %s\n", (LPSTR)lpMsgBuf );
- LocalFree( lpMsgBuf );
- }
-
- fclose( fp );
- }
- }
- return bSuccess;
+#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
- return TRUE;
+ SAL_WARN("vcl", "API call: " << szApiCall << " returned " << lastError << " (0x" << std::hex << lastError << ")");
+#endif
}
#ifdef _WIN32