131 // Clear the cache as well |
131 // Clear the cache as well |
132 for (LDObject* obj : cache()) |
132 for (LDObject* obj : cache()) |
133 delete obj; |
133 delete obj; |
134 |
134 |
135 // Remove this file from the list of files |
135 // Remove this file from the list of files |
136 for (int i = 0; i < g_loadedFiles.size(); ++i) |
136 g_loadedFiles.removeOne (this); |
137 { if (g_loadedFiles[i] == this) |
|
138 { g_loadedFiles.erase (i); |
|
139 break; |
|
140 } |
|
141 } |
|
142 |
137 |
143 // If we just closed the current file, we need to set the current |
138 // If we just closed the current file, we need to set the current |
144 // file as something else. |
139 // file as something else. |
145 if (this == LDFile::current()) |
140 if (this == LDFile::current()) |
146 { bool found = false; |
141 { bool found = false; |
905 // ============================================================================= |
900 // ============================================================================= |
906 // ----------------------------------------------------------------------------- |
901 // ----------------------------------------------------------------------------- |
907 void LDFile::forgetObject (LDObject* obj) |
902 void LDFile::forgetObject (LDObject* obj) |
908 { int idx = obj->getIndex(); |
903 { int idx = obj->getIndex(); |
909 m_history.add (new DelHistory (idx, obj)); |
904 m_history.add (new DelHistory (idx, obj)); |
910 m_objects.erase (idx); |
905 m_objects.removeAt (idx); |
911 obj->setFile (null); |
906 obj->setFile (null); |
912 } |
907 } |
913 |
908 |
914 // ============================================================================= |
909 // ============================================================================= |
915 // ----------------------------------------------------------------------------- |
910 // ----------------------------------------------------------------------------- |
916 bool safeToCloseAll() |
911 bool safeToCloseAll() |
917 { for (LDFile * f : g_loadedFiles) |
912 { for (LDFile* f : g_loadedFiles) |
918 if (!f->safeToClose()) |
913 if (!f->safeToClose()) |
919 return false; |
914 return false; |
920 |
915 |
921 return true; |
916 return true; |
922 } |
917 } |
957 // ----------------------------------------------------------------------------- |
952 // ----------------------------------------------------------------------------- |
958 void LDFile::closeUnused() |
953 void LDFile::closeUnused() |
959 { List<LDFile*> filesUsed = getFilesUsed (LDFile::current()); |
954 { List<LDFile*> filesUsed = getFilesUsed (LDFile::current()); |
960 |
955 |
961 // Anything that's explicitly opened must not be closed |
956 // Anything that's explicitly opened must not be closed |
962 for (LDFile * file : g_loadedFiles) |
957 for (LDFile* file : g_loadedFiles) |
963 if (!file->implicit()) |
958 if (!file->implicit()) |
964 filesUsed << file; |
959 filesUsed << file; |
965 |
960 |
966 // Remove duplicated entries |
961 // Remove duplicated entries |
967 filesUsed.makeUnique(); |
962 removeDuplicates (filesUsed); |
968 |
963 |
969 // Close all open files that aren't in filesUsed |
964 // Close all open files that aren't in filesUsed |
970 for (LDFile * file : g_loadedFiles) |
965 for (LDFile* file : g_loadedFiles) |
971 { bool isused = false; |
966 { bool isused = false; |
972 |
967 |
973 for (LDFile * usedFile : filesUsed) |
968 for (LDFile* usedFile : filesUsed) |
974 { if (file == usedFile) |
969 { if (file == usedFile) |
975 { isused = true; |
970 { isused = true; |
976 break; |
971 break; |
977 } |
972 } |
978 } |
973 } |