[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Review Request 119543: Removed all KDialogs from balooWidgets
From: "Thomas Braxton" <kde.braxton () gmail ! com>
Date: 2014-07-31 1:02:45
Message-ID: 20140731010245.15440.3568 () probe ! kde ! org
[Download RAW message or body]
--===============7050170904002172635==
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
> On July 30, 2014, 8:54 a.m., Vishesh Handa wrote:
> > src/tagwidget.cpp, line 180
> > <https://git.reviewboard.kde.org/r/119543/diff/1/?file=294417#file294417line180>
> >
> > Any reason you've combined the too functions? I don't remember why, but there was \
> > a point when it split up.
> > Also, if one really doesn't need it to be split up, then we should probably use a \
> > QScopedPointer instead of deleting it outself.
>
> Felix Eisele wrote:
> i did googling yesterday and i think it is not needed.
> I am not a fan of class members. you didnt see the dataflow.
> We should i use a QScopedPointer?
>
> Thomas Braxton wrote:
> Or you could just make it not a pointer and it cleans itself up.
>
> Felix Eisele wrote:
> Good idea!
>
> Frank Reininghaus wrote:
> No, this is a **very bad** idea. Creating the dialog on the stack as a child of \
> "this" and then executing its nested event loop will cause crashes like the ones \
> that are fixed by https://git.reviewboard.kde.org/r/118858/ . You should use a \
> QPointer for the dialog and delete it after calling exec() and checking that the \
> QPointer is not null.
> See the links that Dominik added in a comment to that review request of mine for \
> further info.
> Thomas Braxton wrote:
> Since the whole purpose of this function is to get a list of tags using a dialog, \
> the dialog must exist when it returns from exec(). Otherwise the whole function is \
> **moot**.
> Frank Reininghaus wrote:
> Unfortunately, you can't really control what happens inside the nested event loop \
> that is started by exec(). Anything can happen in there, including events that \
> cause the deletion of the parent widget of the dialog. This parent widget will then \
> try to delete the dialog, which lives on the stack. This will cause a crash.
> The easiest way to reproduce this is the "quit by D-Bus"-trick, as described in, \
> e.g.,
> https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0
> http://kate-editor.org/2012/04/06/crash-through-d-bus-calls/
> https://bugs.kde.org/show_bug.cgi?id=293863#c13
>
> And even if you say that the user is unlikely to do this D-Bus thing: there are \
> other ways to achieve the same effect, even if they are much harder to reproduce. \
> You really cannot assume that the dialog still exists when exec() returns. \
> Definitely not. Code that assumes this is buggy (even if the Qt docs for QDialog \
> still suggest this approach - maybe I should try to get that changed).
> And no, I am really not making this stuff up. We do get bug reports about crashes \
> that are caused by problems like this. Please do not add new versions of these bugs \
> when modifying code.
> BTW, your statement that "the whole function is **moot**" if the dialog does not \
> exist anymore is wrong. After all, the function cannot know what will happen during \
> exec(). Most of the time, the dialog will still be there, stuff will get done with \
> the tags, and everything is all right. But sometimes, the application will quit \
> during exec(), and then the sole remaining purpose of the function is to return \
> gracefully, without a crash. And this graceful return is prevented by creating the \
> dialog on the stack.
You're right, QPointer it has to be.
- Thomas
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/119543/#review63489
-----------------------------------------------------------
On July 30, 2014, 6:05 p.m., Felix Eisele wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/119543/
> -----------------------------------------------------------
>
> (Updated July 30, 2014, 6:05 p.m.)
>
>
> Review request for Baloo and Vishesh Handa.
>
>
> Repository: baloo-widgets
>
>
> Description
> -------
>
> Removed all KDialogs from balooWidgets. Removed not needed includes
>
>
> Diffs
> -----
>
> src/kedittagsdialog.cpp c83ce9d
> src/kedittagsdialog_p.h 0bcf744
> src/tagwidget.h 2843acd
> src/tagwidget.cpp f2c3601
> src/tagwidget_p.h 045a185
>
> Diff: https://git.reviewboard.kde.org/r/119543/diff/
>
>
> Testing
> -------
>
>
> Thanks,
>
> Felix Eisele
>
>
--===============7050170904002172635==
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit
<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/119543/">https://git.reviewboard.kde.org/r/119543/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <p style="margin-top: 0;">On July 30th, 2014, 8:54 a.m. UTC, <b>Vishesh \
Handa</b> wrote:</p> <blockquote style="margin-left: 1em; border-left: 2px solid \
#d0d0d0; padding-left: 10px;">
<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="https://git.reviewboard.kde.org/r/119543/diff/1/?file=294417#file294417line180" \
style="color: black; font-weight: bold; text-decoration: \
underline;">src/tagwidget.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; ">bool \
TagWidget::readOnly() const</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" \
align="right"><font size="2">178</font></th> <td bgcolor="#fdfebc" width="50%"><pre \
style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n"><span \
class="hl">d</span></span><span class="o"><span class="hl">-></span></span><span \
class="n"><span class="hl">m_e</span>ditTagsDialog</span> <span class="o">=</span> \
<span class="k">new</span> <span class="n">KEditTagsDialog</span><span \
class="p">(</span> <span class="n">selectedTags</span><span class="p">(),</span> \
<span class="k">this</span> <span class="p">);</span></pre></td> <th \
bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid \
#C0C0C0;" align="right"><font size="2">165</font></th> <td bgcolor="#fdfebc" \
width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span \
class="n"><span class="hl">KE</span>ditTagsD<span class="hl">ialog</span></span><span \
class="o"><span class="hl">*</span></span><span class="hl"> </span><span \
class="n"><span class="hl">d</span>ialog</span> <span class="o">=</span> <span \
class="k">new</span> <span class="n">KEditTagsDialog</span><span \
class="p">(</span><span class="n">selectedTags</span><span class="p">(),</span> <span \
class="k">this</span><span class="p">);</span></pre></td> </tr>
</tbody>
</table>
<pre style="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;">Any \
reason you've combined the too functions? I don't remember why, but there was a point \
when it split up.</p> <p style="padding: 0;text-rendering: inherit;margin: \
0;line-height: inherit;white-space: inherit;">Also, if one really doesn't need it to \
be split up, then we should probably use a QScopedPointer instead of deleting it \
outself.</p></pre> </blockquote>
<p>On July 30th, 2014, 9:41 a.m. UTC, <b>Felix Eisele</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="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;">i did \
googling yesterday and i think it is not needed. <br style="padding: \
0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" /> I \
am not a fan of class members. you didnt see the dataflow. <br style="padding: \
0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" /> We \
should i use a QScopedPointer?</p></pre> </blockquote>
<p>On July 30th, 2014, 3:55 p.m. UTC, <b>Thomas Braxton</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="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;">Or \
you could just make it not a pointer and it cleans itself up.</p></pre> \
</blockquote>
<p>On July 30th, 2014, 6:05 p.m. UTC, <b>Felix Eisele</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="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;">Good \
idea!</p></pre> </blockquote>
<p>On July 30th, 2014, 7:53 p.m. UTC, <b>Frank Reininghaus</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="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;">No, \
this is a <strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: normal;">very bad</strong> idea. Creating the dialog on the \
stack as a child of "this" and then executing its nested event loop will cause \
crashes like the ones that are fixed by https://git.reviewboard.kde.org/r/118858/ . \
You should use a QPointer for the dialog and delete it after calling exec() and \
checking that the QPointer is not null.</p> <p style="padding: 0;text-rendering: \
inherit;margin: 0;line-height: inherit;white-space: inherit;">See the links that \
Dominik added in a comment to that review request of mine for further info.</p></pre> \
</blockquote>
<p>On July 30th, 2014, 10:34 p.m. UTC, <b>Thomas Braxton</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="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;">Since \
the whole purpose of this function is to get a list of tags using a dialog, the \
dialog must exist when it returns from exec(). Otherwise the whole function is \
<strong style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: normal;">moot</strong>.</p></pre> </blockquote>
<p>On July 30th, 2014, 11:44 p.m. UTC, <b>Frank Reininghaus</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="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;">Unfortunately, you can't really control what happens inside the nested \
event loop that is started by exec(). Anything can happen in there, including events \
that cause the deletion of the parent widget of the dialog. This parent widget will \
then try to delete the dialog, which lives on the stack. This will cause a crash.</p> \
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: inherit;">The easiest way to reproduce this is the "quit by \
D-Bus"-trick, as described in, e.g.,</p> <p style="padding: 0;text-rendering: \
inherit;margin: 0;line-height: inherit;white-space: \
inherit;">https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0<br \
style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: \
normal;" /> http://kate-editor.org/2012/04/06/crash-through-d-bus-calls/<br \
style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: \
normal;" /> https://bugs.kde.org/show_bug.cgi?id=293863#c13</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: inherit;">And even if you say that the user is unlikely to do \
this D-Bus thing: there are other ways to achieve the same effect, even if they are \
much harder to reproduce. You really cannot assume that the dialog still exists when \
exec() returns. Definitely not. Code that assumes this is buggy (even if the Qt docs \
for QDialog still suggest this approach - maybe I should try to get that \
changed).</p> <p style="padding: 0;text-rendering: inherit;margin: 0;line-height: \
inherit;white-space: inherit;">And no, I am really not making this stuff up. We do \
get bug reports about crashes that are caused by problems like this. Please do not \
add new versions of these bugs when modifying code.</p> <p style="padding: \
0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">BTW, \
your statement that "the whole function is <strong style="padding: 0;text-rendering: \
inherit;margin: 0;line-height: inherit;white-space: normal;">moot</strong>" if the \
dialog does not exist anymore is wrong. After all, the function cannot know what will \
happen during exec(). Most of the time, the dialog will still be there, stuff will \
get done with the tags, and everything is all right. But sometimes, the application \
will quit during exec(), and then the sole remaining purpose of the function is to \
return gracefully, without a crash. And this graceful return is prevented by creating \
the dialog on the stack.</p></pre> </blockquote>
</blockquote>
<pre style="margin-left: 1em; 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;">You're right, QPointer it has to be.</p></pre> <br />
<p>- Thomas</p>
<br />
<p>On July 30th, 2014, 6:05 p.m. UTC, Felix Eisele 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 Baloo and Vishesh Handa.</div>
<div>By Felix Eisele.</div>
<p style="color: grey;"><i>Updated July 30, 2014, 6:05 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
baloo-widgets
</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;">Removed all KDialogs from balooWidgets. Removed not \
needed includes</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>src/kedittagsdialog.cpp <span style="color: grey">(c83ce9d)</span></li>
<li>src/kedittagsdialog_p.h <span style="color: grey">(0bcf744)</span></li>
<li>src/tagwidget.h <span style="color: grey">(2843acd)</span></li>
<li>src/tagwidget.cpp <span style="color: grey">(f2c3601)</span></li>
<li>src/tagwidget_p.h <span style="color: grey">(045a185)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/119543/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
--===============7050170904002172635==--
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic