--- a/src/documentmanager.cpp Sun Mar 18 12:00:39 2018 +0200 +++ b/src/documentmanager.cpp Sun Mar 18 12:33:29 2018 +0200 @@ -59,17 +59,24 @@ LDDocument* DocumentManager::getDocumentByName (QString filename) { - LDDocument* doc = findDocumentByName (filename); - - if (doc == nullptr) + if (not filename.isEmpty()) { - bool tmp = m_loadingMainFile; - m_loadingMainFile = false; - doc = openDocument (filename, true, true); - m_loadingMainFile = tmp; + LDDocument* doc = findDocumentByName (filename); + + if (doc == nullptr) + { + bool tmp = m_loadingMainFile; + m_loadingMainFile = false; + doc = openDocument (filename, true, true); + m_loadingMainFile = tmp; + } + + return doc; } - - return doc; + else + { + return nullptr; + } } void DocumentManager::openMainModel (QString path) @@ -153,10 +160,13 @@ LDDocument* DocumentManager::findDocumentByName (QString name) { - for (LDDocument* document : m_documents) + if (not name.isEmpty()) { - if (isOneOf (name, document->name(), document->defaultName())) - return document; + for (LDDocument* document : m_documents) + { + if (isOneOf (name, document->name(), document->defaultName())) + return document; + } } return nullptr;