<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://git.reviewboard.kde.org/r/124253/">https://git.reviewboard.kde.org/r/124253/</a>
</td>
</tr>
</table>
<br />
<p>Ship it!</p>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Ship It!</pre>
<br />
<p>- Maxim Mikityanskiy</p>
<br />
<p>On Июль 4th, 2015, 4:32 п.п. UTC, Maxim Mikityanskiy wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
<div>Review request for kde-workspace.</div>
<div>By Maxim Mikityanskiy.</div>
<p style="color: grey;"><i>Updated Июль 4, 2015, 4:32 п.п.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
powerdevil
</div>
<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;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">At first, there is a memory leak when watcher is created in Login1SuspendJob::doStart, then switch goes through default branch, and the watcher is never deleted.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">The second bug is more serious.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%">QDBusPendingReply<span style="color: #666666"><</span><span style="color: #B00040">void</span><span style="color: #666666">></span> reply;
QDBusPendingCallWatcher <span style="color: #666666">*</span>watcher <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> QDBusPendingCallWatcher(reply, <span style="color: #008000; font-weight: bold">this</span>);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher<span style="color: #666666">*</span>)), <span style="color: #008000; font-weight: bold">this</span>, SLOT(sendResult(QDBusPendingCallWatcher<span style="color: #666666">*</span>)));
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">The above piece of code creates default-initialized reply, then creates watcher for this reply, and connects the signal to sendResult slot. But then, in every case branch of switch, reply gets overwritten. Old reply gets destroyed and new object assigns into that variable named reply. No watcher is bound with the new reply! So what we got: our watcher will never be deleted, and sendResult slot will never be called.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">To fix that bugs we should create watcher for the real reply, not for default-initialized one. If no reply was created, don't create watcher, so avoid the first leak. If the reply was created, create watcher for it, so that sendResult will be called and watcher will be deleted from here.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">This simple patch fixes described problems.</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>daemon/backends/upower/login1suspendjob.cpp <span style="color: grey">(8918b22)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/124253/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>