# HG changeset patch # User Teemu Piippo # Date 1410052315 -10800 # Node ID 69b8adc9a6695b0e8a86ca3f5a6bcc7613e80ed7 # Parent 2f3cc8e045d5ad8170985f018fb5c8ff9faa8d45 - fixed: due to a shared pointer called via reference called dismiss() in LDDocument::closeInitialFile, this could cause LDDocuments to delete themselves in setImplicit(true) as no shared pointers were left inside closeInitialFile to keep the refcount up. - fixed: bad QMap iteration after erase in the gl compiler how diabolic can bugs get? *shudder* diff -r 2f3cc8e045d5 -r 69b8adc9a669 src/glCompiler.cc --- a/src/glCompiler.cc Sun Sep 07 01:13:20 2014 +0300 +++ b/src/glCompiler.cc Sun Sep 07 04:11:55 2014 +0300 @@ -280,12 +280,18 @@ QVector vbodata; - for (auto it = m_objectInfo.begin(); it != m_objectInfo.end(); ++it) + for (auto it = m_objectInfo.begin(); it != m_objectInfo.end();) { if (it.key() == null) + { it = m_objectInfo.erase (it); - elif (it.key().toStrongRef()->document() == CurrentDocument() and not it.key().toStrongRef()->isHidden()) + } + elif (it.key().toStrongRef()->document() == CurrentDocument() + and not it.key().toStrongRef()->isHidden()) + { vbodata += it->data[vbonum]; + ++it; + } } glBindBuffer (GL_ARRAY_BUFFER, m_vbo[vbonum]); diff -r 2f3cc8e045d5 -r 69b8adc9a669 src/ldDocument.cc --- a/src/ldDocument.cc Sun Sep 07 01:13:20 2014 +0300 +++ b/src/ldDocument.cc Sun Sep 07 04:11:55 2014 +0300 @@ -173,6 +173,7 @@ if (m_isImplicit != a) { m_isImplicit = a; + print ("Setting implicity of %1 to %2\n", this, a ? "true" : "false"); if (a == false) { @@ -186,20 +187,10 @@ } else { + print ("Removing %1 from explicit documents...\n", this); g_explicitDocuments.removeOne (self().toStrongRef()); + print ("Removed %1", this); print ("Closed %1", name()); - int count = 0; - - for (LDObjectWeakPtr obj : g_allObjects) - { - if (obj == null) - continue; - - LDSubfilePtr ref = obj.toStrongRef().dynamicCast(); - - if (ref != null and ref->fileInfo() == self()) - count++; - } } if (g_win != null) @@ -702,7 +693,7 @@ for (LDDocumentWeakPtr doc : g_allDocuments) { - if (doc.toStrongRef()->name() == shortName) + if (doc != null and doc.toStrongRef()->name() == shortName) { documentToReplace = doc; break; @@ -1454,7 +1445,8 @@ not g_explicitDocuments[1]->name().isEmpty() and not g_explicitDocuments[0]->hasUnsavedChanges()) { - g_explicitDocuments[0]->dismiss(); + LDDocumentPtr filetoclose = g_explicitDocuments.first(); + filetoclose->dismiss(); } }