<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/105806/">http://git.reviewboard.kde.org/r/105806/</a>
</td>
</tr>
</table>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="http://git.reviewboard.kde.org/r/105806/diff/1/?file=75561#file75561line105" style="color: black; font-weight: bold; text-decoration: underline;">services/fileindexer/fileindexer.cpp</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">Nepomuk2::FileIndexer::FileIndexer( QObject* parent, const QList<QVariant>& )</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">105</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">m_indexScheduler</span><span class="o">-></span><span class="n">deleteLater</span><span class="p">();</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Vishesh, if you're not sure why something gets deleted, use gdb to set a breakpoint in the dtor :-)
My take on this is: indeed, deleteLater+quit, in any order, is not reliable. This is because quit sets a bool, rather than posting an event, which m
eans the thread's eventloop could exit before processing the event.
The solution is to post an event to the thread. In KDSoapServer, I call myThread->quitThread(), which is an added public method which calls QMetaObj
ect::invokeMethod(someObject, "quitThreadImpl"). someObject has to be an object "associated with this thread", i.e. created by this thread, in run(). And quitThreadImpl() can then call thread->quit(), from the thread itself rather than from the outside.
Don't call invokeMethod(myThread, "...") because myThread is associated with the main thread! The common QThread trap.
You want an object whose event processing happens within the thread itself.
This sounds a bit convoluted, but actually it's good practice to never have slots in a QThread subclass (to avoid falling in the trap above), so I a
lways recommend to split the QThread subclass and the actual object that you're working with. If you already do that, then that object is associated with the thread, and you can post events to it. Maybe you already have such an object (this construct is useful for any slots, not just for calling quit from the outside), I admit that I didn't read the code that all this is about :-)
Maybe Qt could make some of this easier, for instance with a QThread::postedQuit() or something like that.</pre>
</div>
<br />
<p>- David</p>
<br />
<p>On August 18th, 2012, 7:34 p.m., Vishesh Handa wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Nepomuk, David Faure, Thiago Macieira, Sebastian Trueg, and Marc Mutz.</div>
<div>By Vishesh Handa.</div>
<p style="color: grey;"><i>Updated Aug. 18, 2012, 7:34 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"> The IndexScheduler lives in the m_schedulingThread, which should ideally
be deleted before the thread finishes execution.
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Nope. Cannot test this. In fact I'm not even sure if this was actually the reason for the crash.</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="http://bugs.kde.org/show_bug.cgi?id=301698">301698</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>services/fileindexer/fileindexer.cpp <span style="color: grey">(af8be4d)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/105806/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>