src/ldDocument.cc

changeset 656
2a1c204df14d
parent 655
b376645315ab
child 662
2f1bd9112408
child 707
c89b58ba266b
--- a/src/ldDocument.cc	Sat Mar 29 05:26:10 2014 +0200
+++ b/src/ldDocument.cc	Sun Apr 06 01:26:04 2014 +0300
@@ -1151,9 +1151,13 @@
 //
 void LDDocument::closeUnused()
 {
-	for (LDDocument* file : g_loadedFiles)
+	for (int i = 0; i < g_loadedFiles.size(); ++i)
+	{
+		LDDocument* file = g_loadedFiles[i];
+
 		if (file->isImplicit() && file->references().isEmpty())
-			delete file;
+			delete g_loadedFiles[i--];
+	}
 }
 
 // =============================================================================

mercurial