[WIN32] added more logging and some smaller changes
authorwsoltys <wiso@no.way>
Wed, 23 Oct 2013 19:31:39 +0000 (21:31 +0200)
committerwsoltys <wiso@no.way>
Wed, 23 Oct 2013 19:33:47 +0000 (21:33 +0200)
xbmc/windowing/windows/WinSystemWin32.cpp
xbmc/windowing/windows/WinSystemWin32DX.cpp

index e5a981f..d2e13c9 100644 (file)
@@ -79,6 +79,9 @@ bool CWinSystemWin32::CreateNewWindow(const CStdString& name, bool fullScreen, R
 {
   m_hInstance = ( HINSTANCE )GetModuleHandle( NULL );
 
+  if(m_hInstance == NULL)
+    CLog::Log(LOGDEBUG, "%s : GetModuleHandle failed with %d", __FUNCTION__, GetLastError());
+
   m_nWidth  = res.iWidth;
   m_nHeight = res.iHeight;
   m_bFullScreen = fullScreen;
@@ -101,6 +104,7 @@ bool CWinSystemWin32::CreateNewWindow(const CStdString& name, bool fullScreen, R
 
   if( !RegisterClass( &wndClass ) )
   {
+    CLog::Log(LOGERROR, "%s : RegisterClass failed with %d", __FUNCTION__, GetLastError());
     return false;
   }
 
@@ -109,6 +113,7 @@ bool CWinSystemWin32::CreateNewWindow(const CStdString& name, bool fullScreen, R
     NULL, m_hInstance, userFunction );
   if( hWnd == NULL )
   {
+    CLog::Log(LOGERROR, "%s : CreateWindow failed with %d", __FUNCTION__, GetLastError());
     return false;
   }
 
@@ -161,7 +166,11 @@ bool CWinSystemWin32::CreateBlankWindows()
   wcex.hIconSm= 0;
 
   // Now we can go ahead and register our new window class
-  int reg = RegisterClassEx(&wcex);
+  if(!RegisterClassEx(&wcex))
+  {
+    CLog::Log(LOGERROR, "%s : RegisterClass failed with %d", __FUNCTION__, GetLastError());
+    return false;
+  }
 
   // We need as many blank windows as there are screens (minus 1)
   int BlankWindowsCount = m_MonitorsInfo.size() -1;
@@ -172,7 +181,10 @@ bool CWinSystemWin32::CreateBlankWindows()
     CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
 
     if(hBlankWindow ==  NULL)
+    {
+      CLog::Log(LOGERROR, "%s : CreateWindowEx failed with %d", __FUNCTION__, GetLastError());
       return false;
+    }
 
     m_hBlankWindows.push_back(hBlankWindow);
   }
@@ -182,7 +194,7 @@ bool CWinSystemWin32::CreateBlankWindows()
 
 bool CWinSystemWin32::BlankNonActiveMonitors(bool bBlank)
 {
-  if(m_hBlankWindows.size() == 0)
+  if(m_hBlankWindows.empty())
     return false;
 
   if(bBlank == false)
@@ -278,10 +290,14 @@ bool CWinSystemWin32::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool
     // save position of windowed mode
     WINDOWINFO wi;
     wi.cbSize = sizeof(WINDOWINFO);
-    GetWindowInfo(m_hWnd, &wi);
-    m_nLeft = wi.rcClient.left;
-    m_nTop = wi.rcClient.top;
-    m_ValidWindowedPosition = true;
+    if(GetWindowInfo(m_hWnd, &wi))
+    {
+      m_nLeft = wi.rcClient.left;
+      m_nTop = wi.rcClient.top;
+      m_ValidWindowedPosition = true;
+    }
+    else
+      CLog::Log(LOGERROR, "%s : GetWindowInfo failed with %d", __FUNCTION__, GetLastError());
   }
 
   m_bFullScreen = fullScreen;
@@ -343,7 +359,8 @@ RECT CWinSystemWin32::ScreenRect(int screen)
   DEVMODE sDevMode;
   ZeroMemory(&sDevMode, sizeof(DEVMODE));
   sDevMode.dmSize = sizeof(DEVMODE);
-  EnumDisplaySettings(details.DeviceName, ENUM_CURRENT_SETTINGS, &sDevMode);
+  if(!EnumDisplaySettings(details.DeviceName, ENUM_CURRENT_SETTINGS, &sDevMode))
+    CLog::Log(LOGERROR, "%s : EnumDisplaySettings failed with %d", __FUNCTION__, GetLastError());
 
   RECT rc;
   rc.left = sDevMode.dmPosition.x;
@@ -397,7 +414,11 @@ bool CWinSystemWin32::ResizeInternal(bool forceRefresh)
 
   WINDOWINFO wi;
   wi.cbSize = sizeof (WINDOWINFO);
-  GetWindowInfo(m_hWnd, &wi);
+  if(!GetWindowInfo(m_hWnd, &wi))
+  {
+    CLog::Log(LOGERROR, "%s : GetWindowInfo failed with %d", __FUNCTION__, GetLastError());
+    return false;
+  }
   RECT wr = wi.rcWindow;
 
   if (forceRefresh || wr.bottom  - wr.top != rc.bottom - rc.top || wr.right - wr.left != rc.right - rc.left ||
@@ -447,7 +468,7 @@ bool CWinSystemWin32::ChangeResolution(RESOLUTION_INFO res)
     LONG rc = ChangeDisplaySettingsEx(details.DeviceName, &sDevMode, NULL, CDS_FULLSCREEN, NULL);
     if (rc != DISP_CHANGE_SUCCESSFUL)
     {
-      CLog::Log(LOGERROR, "%s: error, code %d", __FUNCTION__, rc);
+      CLog::Log(LOGERROR, "%s : ChangeDisplaySettingsEx failed with %d", __FUNCTION__, rc);
       return false;
     }
     else
index a68e4a0..7f83bfe 100644 (file)
@@ -44,9 +44,7 @@ bool CWinSystemWin32DX::UseWindowedDX(bool fullScreen)
 
 bool CWinSystemWin32DX::CreateNewWindow(CStdString name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction)
 {
-  CWinSystemWin32::CreateNewWindow(name, fullScreen, res, userFunction);
-
-  if(m_hWnd == NULL)
+  if(!CWinSystemWin32::CreateNewWindow(name, fullScreen, res, userFunction))
     return false;
 
   SetFocusWnd(m_hWnd);