--- a/src/document.cc Thu Dec 19 02:37:12 2013 +0200 +++ b/src/document.cc Thu Dec 19 13:36:48 2013 +0200 @@ -979,7 +979,7 @@ // ----------------------------------------------------------------------------- static bool g_closingUnusedFiles = false; -void LDDocument::closeUnused() +static void reallyCloseUnused() { // Don't go here more than once at a time, otherwise we risk double-deletions if (g_closingUnusedFiles) return; @@ -1012,6 +1012,15 @@ // ============================================================================= // ----------------------------------------------------------------------------- +void LDDocument::closeUnused() +{ // Close unused files later on in the event loop. This function sees a lot of + // calls, this reduces the amount of unneeded calls and prevents the engine + // from beginning to close unused files when it really shouldn't be doing that. + invokeLater (reallyCloseUnused); +} + +// ============================================================================= +// ----------------------------------------------------------------------------- LDObject* LDDocument::getObject (int pos) const { if (m_Objects.size() <= pos) return null;