# HG changeset patch # User Teemu Piippo # Date 1405260163 -10800 # Node ID a522e1cd92afd76a2a16b3eb9ab90e6386ab3daf # Parent 268413885cb1a82edf41bff4cbd2ead27f4f33f5 - fixed incorrect conversions of weak pointers to strong ones diff -r 268413885cb1 -r a522e1cd92af src/ldDocument.cc --- a/src/ldDocument.cc Sun Jul 13 16:48:29 2014 +0300 +++ b/src/ldDocument.cc Sun Jul 13 17:02:43 2014 +0300 @@ -184,10 +184,15 @@ g_explicitDocuments.removeOne (self().toStrongRef()); print ("Closed %1", name()); int count = 0; - for (LDObjectPtr obj : g_allObjects) + + for (LDObjectWeakPtr obj : g_allObjects) { - LDSubfilePtr ref = obj.dynamicCast(); - if (ref && ref->fileInfo() == self()) + if (obj == null) + continue; + + LDSubfilePtr ref = obj.toStrongRef().dynamicCast(); + + if (ref != null && ref->fileInfo() == self()) count++; } } @@ -218,10 +223,10 @@ // LDDocumentPtr findDocument (QString name) { - for (LDDocumentPtr file : g_allDocuments) + for (LDDocumentWeakPtr file : g_allDocuments) { - if (file->name() == name) - return file; + if (file != null && file.toStrongRef()->name() == name) + return file.toStrongRef(); } return LDDocumentPtr(); @@ -273,12 +278,12 @@ // in the immediate vicinity of a current model to override stock LDraw stuff. QString reltop = basename (dirname (relpath)); - for (LDDocumentPtr doc : g_allDocuments) + for (LDDocumentWeakPtr doc : g_allDocuments) { - if (doc->fullPath().isEmpty()) + if (doc == null) continue; - QString partpath = format ("%1/%2", dirname (doc->fullPath()), relpath); + QString partpath = format ("%1/%2", dirname (doc.toStrongRef()->fullPath()), relpath); QFile f (partpath); if (f.exists())