354 g_aborted = true; |
354 g_aborted = true; |
355 } |
355 } |
356 |
356 |
357 // ============================================================================= |
357 // ============================================================================= |
358 // ----------------------------------------------------------------------------- |
358 // ----------------------------------------------------------------------------- |
359 List<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok) |
359 QList<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok) |
360 { List<str> lines; |
360 { QList<str> lines; |
361 List<LDObject*> objs; |
361 QList<LDObject*> objs; |
362 |
362 |
363 if (numWarnings) |
363 if (numWarnings) |
364 *numWarnings = 0; |
364 *numWarnings = 0; |
365 |
365 |
366 // Calculate the amount of lines |
366 // Calculate the amount of lines |
490 |
490 |
491 // ============================================================================= |
491 // ============================================================================= |
492 // ----------------------------------------------------------------------------- |
492 // ----------------------------------------------------------------------------- |
493 void closeAll() |
493 void closeAll() |
494 { // Remove all loaded files and the objects they contain |
494 { // Remove all loaded files and the objects they contain |
495 List<LDFile*> files = g_loadedFiles; |
495 QList<LDFile*> files = g_loadedFiles; |
496 |
496 |
497 for (LDFile * file : files) |
497 for (LDFile * file : files) |
498 delete file; |
498 delete file; |
499 } |
499 } |
500 |
500 |
881 return numObjs() - 1; |
881 return numObjs() - 1; |
882 } |
882 } |
883 |
883 |
884 // ============================================================================= |
884 // ============================================================================= |
885 // ----------------------------------------------------------------------------- |
885 // ----------------------------------------------------------------------------- |
886 void LDFile::addObjects (const List<LDObject*> objs) |
886 void LDFile::addObjects (const QList<LDObject*> objs) |
887 { for (LDObject * obj : objs) |
887 { for (LDObject * obj : objs) |
888 if (obj) |
888 if (obj) |
889 addObject (obj); |
889 addObject (obj); |
890 } |
890 } |
891 |
891 |
930 m_objects[idx] = obj; |
930 m_objects[idx] = obj; |
931 } |
931 } |
932 |
932 |
933 // ============================================================================= |
933 // ============================================================================= |
934 // ----------------------------------------------------------------------------- |
934 // ----------------------------------------------------------------------------- |
935 static List<LDFile*> getFilesUsed (LDFile* node) |
935 static QList<LDFile*> getFilesUsed (LDFile* node) |
936 { List<LDFile*> filesUsed; |
936 { QList<LDFile*> filesUsed; |
937 |
937 |
938 for (LDObject * obj : node->objects()) |
938 for (LDObject * obj : node->objects()) |
939 { if (obj->getType() != LDObject::Subfile) |
939 { if (obj->getType() != LDObject::Subfile) |
940 continue; |
940 continue; |
941 |
941 |
949 |
949 |
950 // ============================================================================= |
950 // ============================================================================= |
951 // Find out which files are unused and close them. |
951 // Find out which files are unused and close them. |
952 // ----------------------------------------------------------------------------- |
952 // ----------------------------------------------------------------------------- |
953 void LDFile::closeUnused() |
953 void LDFile::closeUnused() |
954 { List<LDFile*> filesUsed = getFilesUsed (LDFile::current()); |
954 { QList<LDFile*> filesUsed = getFilesUsed (LDFile::current()); |
955 |
955 |
956 // Anything that's explicitly opened must not be closed |
956 // Anything that's explicitly opened must not be closed |
957 for (LDFile* file : g_loadedFiles) |
957 for (LDFile* file : g_loadedFiles) |
958 if (!file->implicit()) |
958 if (!file->implicit()) |
959 filesUsed << file; |
959 filesUsed << file; |
1019 return tr ("<anonymous>"); |
1019 return tr ("<anonymous>"); |
1020 } |
1020 } |
1021 |
1021 |
1022 // ============================================================================= |
1022 // ============================================================================= |
1023 // ----------------------------------------------------------------------------- |
1023 // ----------------------------------------------------------------------------- |
1024 List<LDObject*> LDFile::inlineContents (LDSubfile::InlineFlags flags) |
1024 QList<LDObject*> LDFile::inlineContents (LDSubfile::InlineFlags flags) |
1025 { // Possibly substitute with logoed studs: |
1025 { // Possibly substitute with logoed studs: |
1026 // stud.dat -> stud-logo.dat |
1026 // stud.dat -> stud-logo.dat |
1027 // stud2.dat -> stud-logo2.dat |
1027 // stud2.dat -> stud-logo2.dat |
1028 if (gl_logostuds && (flags & LDSubfile::RendererInline)) |
1028 if (gl_logostuds && (flags & LDSubfile::RendererInline)) |
1029 { if (name() == "stud.dat" && g_logoedStud) |
1029 { if (name() == "stud.dat" && g_logoedStud) |
1031 |
1031 |
1032 elif (name() == "stud2.dat" && g_logoedStud2) |
1032 elif (name() == "stud2.dat" && g_logoedStud2) |
1033 return g_logoedStud2->inlineContents (flags); |
1033 return g_logoedStud2->inlineContents (flags); |
1034 } |
1034 } |
1035 |
1035 |
1036 List<LDObject*> objs, objcache; |
1036 QList<LDObject*> objs, objcache; |
1037 |
1037 |
1038 bool deep = flags & LDSubfile::DeepInline, |
1038 bool deep = flags & LDSubfile::DeepInline, |
1039 doCache = flags & LDSubfile::CacheInline; |
1039 doCache = flags & LDSubfile::CacheInline; |
1040 |
1040 |
1041 // If we have this cached, just clone that |
1041 // If we have this cached, just clone that |
1058 if (deep && obj->getType() == LDObject::Subfile) |
1058 if (deep && obj->getType() == LDObject::Subfile) |
1059 { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
1059 { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
1060 |
1060 |
1061 // We only want to cache immediate subfiles, so shed the caching |
1061 // We only want to cache immediate subfiles, so shed the caching |
1062 // flag when recursing deeper in hierarchy. |
1062 // flag when recursing deeper in hierarchy. |
1063 List<LDObject*> otherobjs = ref->inlineContents (flags & ~ (LDSubfile::CacheInline)); |
1063 QList<LDObject*> otherobjs = ref->inlineContents (flags & ~ (LDSubfile::CacheInline)); |
1064 |
1064 |
1065 for (LDObject * otherobj : otherobjs) |
1065 for (LDObject * otherobj : otherobjs) |
1066 { // Cache this object, if desired |
1066 { // Cache this object, if desired |
1067 if (doCache) |
1067 if (doCache) |
1068 objcache << otherobj->clone(); |
1068 objcache << otherobj->clone(); |