gui: if GUIDialogBoxBase first use in xbmc was from non gui thread, it would crash
authorJoakim Plate <elupus@ecce.se>
Thu, 6 Sep 2012 19:42:22 +0000 (21:42 +0200)
committerJoakim Plate <elupus@ecce.se>
Thu, 6 Sep 2012 20:22:11 +0000 (22:22 +0200)
This happened if you enabled PVR without having done anything else.

xbmc/guilib/GUIMessage.h
xbmc/guilib/GUIWindow.cpp

index 28463e0..ae17b1d 100644 (file)
 
 #define GUI_MSG_SET_TEXT        42
 
+#define GUI_MSG_WINDOW_LOAD 43
+
 #define GUI_MSG_USER         1000
 
 /*!
index 458c247..d10f010 100644 (file)
@@ -506,6 +506,13 @@ bool CGUIWindow::OnMessage(CGUIMessage& message)
 {
   switch ( message.GetMessage() )
   {
+  case GUI_MSG_WINDOW_LOAD:
+    {
+      Initialize();
+      return true;
+    }
+    break;
+      
   case GUI_MSG_WINDOW_INIT:
     {
       CLog::Log(LOGDEBUG, "------ Window Init (%s) ------", GetProperty("xmlfile").c_str());
@@ -728,7 +735,15 @@ bool CGUIWindow::Initialize()
 {
   if (!g_windowManager.Initialized())
     return false;     // can't load if we have no skin yet
-  return Load(GetProperty("xmlfile").asString());
+  if(m_windowLoaded)
+    return false;
+  if(g_application.IsCurrentThread())
+    return Load(GetProperty("xmlfile").asString());
+  else
+  {
+    CGUIMessage msg(GUI_MSG_WINDOW_LOAD, 0, 0);
+    g_windowManager.SendThreadMessage(msg, GetID());
+  }
 }
 
 void CGUIWindow::SetInitialVisibility()