<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 "this". 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'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 "return true", 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't clear enough!)<br>
<br>There is one more problem. I can't always reproduce it. Before replaceWith(..) is called the
ResourceManager'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 "delete this". (Patch attached)<br><br><b>Random Question:</b> In determineUri()'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(&m_rm->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->m_initializedData.find(m_uri);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if( it == m_rm->m_initializedData.end() ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> m_rm->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 "this" 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't we move the MutexLocker inside the <span style="font-family: courier new,monospace;">if( it ==
m_rm->m_initializedData.end() )<font face="arial,helvetica,sans-serif"> ?<br><br>- Vishesh Handa</font></span><br>
</div></div>