<br>Hey Sebastian<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
least one problem: run the resourcetest and see it crashing. This is due<br>
to determineUri deleting &quot;this&quot;. determineUri() is called all over the<br>
place. I think the one solution is to move that call into Resource as I<br>
already did with store().<br></blockquote><div><br>I had no idea there were tests. For some reason I totally missed them! I was going to write my own tests to validate the patch. <br><br>Anyway, you&#39;re right. It crashes. The problem is that replaceWith(..) deletes itself. And then determineUri tries to access the m_uri variable. Even if we simply &quot;return true&quot;, from determineUri(). It is called all over the place and hence some other member function accesses its, no longer valid, member variables<font face="arial,helvetica,sans-serif">.</font> (Your explanation wasn&#39;t clear enough!)<br>
<br>There is one more problem. I can&#39;t always reproduce it. Before replaceWith(..) is called the 
ResourceManager&#39;s mutex is locked. Then when deleting it self resetSelf(bool) attempts to lock the mutex. The locking sometimes fails, and it just keeps waiting. <br>
<br>One way of solving both the problems is to derive ResourceData from QObject. And then call deleteLater() instead of &quot;delete this&quot;. (Patch attached)<br><br><b>Random Question:</b> In determineUri()&#39;s last if condition - <br>
<br><span style="font-family: courier new,monospace;">if( !m_uri.isEmpty() ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            QMutexLocker rmlock(&amp;m_rm-&gt;mutex);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            ResourceDataHash::iterator it = m_rm-&gt;m_initializedData.find(m_uri);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            if( it == m_rm-&gt;m_initializedData.end() ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                m_rm-&gt;m_initializedData.insert( m_uri, this );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            else {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                // As the ResourceData already exists in m_initializedData, we simply</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                // make all the the Resources which contain &quot;this&quot; ResourceData, point</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                // to the initialized ResourceData instead.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                replaceWith( it.value() );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        }<br></span><br>Couldn&#39;t we move the MutexLocker inside the <span style="font-family: courier new,monospace;">if( it == 
m_rm-&gt;m_initializedData.end() )<font face="arial,helvetica,sans-serif"> ?<br><br>- Vishesh Handa</font></span><br>
</div></div>