--- a/src/documentmanager.cpp Sat Jan 28 17:47:06 2017 +0200 +++ b/src/documentmanager.cpp Sun Jan 29 15:05:14 2017 +0200 @@ -271,15 +271,13 @@ return nullptr; } -LDObjectList DocumentManager::loadFileContents (QFile* fp, int* numWarnings, bool* ok) +void DocumentManager::loadFileContents(QIODevice* input, Model& model, int* numWarnings, bool* ok) { - LDObjectList objs; - if (numWarnings) *numWarnings = 0; - DocumentLoader* loader = new DocumentLoader (m_loadingMainFile); - loader->read (fp); + DocumentLoader* loader = new DocumentLoader {&model, m_loadingMainFile}; + loader->read(input); loader->start(); // After start() returns, if the loader isn't done yet, it's delaying @@ -292,10 +290,6 @@ // If we wanted the success value, supply that now if (ok) *ok = not loader->hasAborted(); - - objs = loader->objects(); - delete loader; - return objs; } LDDocument* DocumentManager::openDocument (QString path, bool search, bool implicit, LDDocument* fileToOverride, @@ -335,7 +329,9 @@ int numWarnings; bool ok; - LDObjectList objs = loadFileContents (fp, &numWarnings, &ok); + Model model; + loadFileContents(fp, model, &numWarnings, &ok); + load->merge(model); fp->close(); fp->deleteLater(); @@ -348,8 +344,6 @@ return nullptr; } - load->addObjects (objs); - if (m_loadingMainFile) { m_window->changeDocument (load); @@ -411,7 +405,7 @@ print (tr ("Logoed studs loaded.\n")); } -bool DocumentManager::preInline (LDDocument* doc, LDObjectList& objs, bool deep, bool renderinline) +bool DocumentManager::preInline (LDDocument* doc, Model& model, bool deep, bool renderinline) { // Possibly substitute with logoed studs: // stud.dat -> stud-logo.dat @@ -423,12 +417,12 @@ if (doc->name() == "stud.dat" and m_logoedStud) { - objs = m_logoedStud->inlineContents (deep, renderinline); + m_logoedStud->inlineContents(model, deep, renderinline); return true; } else if (doc->name() == "stud2.dat" and m_logoedStud2) { - objs = m_logoedStud2->inlineContents (deep, renderinline); + m_logoedStud2->inlineContents(model, deep, renderinline); return true; } }