Fixed crash with closing: since logoed studs are now loaded, the first file in g_loadedFiles is not explicit anymore. the closing code assumed this

Wed, 21 Aug 2013 11:09:39 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 21 Aug 2013 11:09:39 +0300
changeset 470
e41b6e1e3299
parent 469
f2faed654633
child 471
fc58b67d445c

Fixed crash with closing: since logoed studs are now loaded, the first file in g_loadedFiles is not explicit anymore. the closing code assumed this

src/file.cpp file | annotate | diff | comparison | revisions
--- a/src/file.cpp	Wed Aug 21 10:54:33 2013 +0300
+++ b/src/file.cpp	Wed Aug 21 11:09:39 2013 +0300
@@ -130,10 +130,16 @@
 	// file as something else.
 	if (this == LDFile::current()) {
 		// If we closed the last file, create a blank one.
-		if (g_loadedFiles.size() == 0)
+		if (countExplicitFiles() == 0)
 			newFile();
-		else
-			LDFile::setCurrent (g_loadedFiles[0]);
+		else {
+			// Find the first explicit file loaded
+			int idx = 0;
+			while (g_loadedFiles[idx]->implicit())
+				idx++;
+			
+			LDFile::setCurrent (g_loadedFiles[idx]);
+		}
 	}
 	
 	g_win->updateFileList();

mercurial