977 // ============================================================================= |
977 // ============================================================================= |
978 // Find out which files are unused and close them. |
978 // Find out which files are unused and close them. |
979 // ----------------------------------------------------------------------------- |
979 // ----------------------------------------------------------------------------- |
980 static bool g_closingUnusedFiles = false; |
980 static bool g_closingUnusedFiles = false; |
981 |
981 |
982 void LDDocument::closeUnused() |
982 static void reallyCloseUnused() |
983 { // Don't go here more than once at a time, otherwise we risk double-deletions |
983 { // Don't go here more than once at a time, otherwise we risk double-deletions |
984 if (g_closingUnusedFiles) |
984 if (g_closingUnusedFiles) |
985 return; |
985 return; |
986 |
986 |
987 QList<LDDocument*> filesUsed; |
987 QList<LDDocument*> filesUsed; |
1006 for (LDDocument* file : g_loadedFiles) |
1006 for (LDDocument* file : g_loadedFiles) |
1007 if (!filesUsed.contains (file)) |
1007 if (!filesUsed.contains (file)) |
1008 delete file; |
1008 delete file; |
1009 |
1009 |
1010 g_closingUnusedFiles = false; |
1010 g_closingUnusedFiles = false; |
|
1011 } |
|
1012 |
|
1013 // ============================================================================= |
|
1014 // ----------------------------------------------------------------------------- |
|
1015 void LDDocument::closeUnused() |
|
1016 { // Close unused files later on in the event loop. This function sees a lot of |
|
1017 // calls, this reduces the amount of unneeded calls and prevents the engine |
|
1018 // from beginning to close unused files when it really shouldn't be doing that. |
|
1019 invokeLater (reallyCloseUnused); |
1011 } |
1020 } |
1012 |
1021 |
1013 // ============================================================================= |
1022 // ============================================================================= |
1014 // ----------------------------------------------------------------------------- |
1023 // ----------------------------------------------------------------------------- |
1015 LDObject* LDDocument::getObject (int pos) const |
1024 LDObject* LDDocument::getObject (int pos) const |