Browse Source

Fixed a bug when retrieving layout children that was causing a crash when refreshing list of projects in the project window

BearishSun 10 years ago
parent
commit
5d37714175
2 changed files with 7 additions and 2 deletions
  1. 6 1
      MBansheeEditor/ProjectWindow.cs
  2. 1 1
      SBansheeEngine/Source/BsScriptGUILayout.cpp

+ 6 - 1
MBansheeEditor/ProjectWindow.cs

@@ -219,8 +219,13 @@ namespace BansheeEditor
         private void RefreshRecentProjects()
         {
             GUILayout scrollLayout = recentProjectsArea.Layout;
-            while(scrollLayout.ChildCount > 0)
+            Debug.Log("SCROLL LAYOUT: " + (scrollLayout != null));
+
+            while (scrollLayout.ChildCount > 0)
+            {
+                Debug.Log("COUNT: " + scrollLayout.ChildCount + " - " + (scrollLayout.GetChild(0) != null));
                 scrollLayout.GetChild(0).Destroy();
+            }
 
             RecentProject[] recentProjects = EditorSettings.RecentProjects;
             Array.Sort(recentProjects, (a, b) => a.accessTimestamp.CompareTo(b.accessTimestamp));

+ 1 - 1
SBansheeEngine/Source/BsScriptGUILayout.cpp

@@ -178,7 +178,7 @@ namespace BansheeEngine
 
 	MonoObject* ScriptGUILayout::internal_getChild(ScriptGUILayout* instance, UINT32 index)
 	{
-		if (instance->isDestroyed() || instance->mChildren.size() >= index)
+		if (instance->isDestroyed() || index >= instance->mChildren.size())
 			return nullptr;
 
 		return instance->mChildren[index].element->getManagedInstance();