[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: Review Request: Put an end to plugin statusbar icon leaks
From: "Commit Hook" <null () kde ! org>
Date: 2011-10-05 11:41:11
Message-ID: 20111005114111.15834.67723 () vidsolbach ! de
[Download RAW message or body]
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/101653/#review7118
-----------------------------------------------------------
This review has been submitted with commit 848a9f02135c06ec5743d7cac69e635898172323 \
by Thomas Friedrichsmeier to branch KDE/4.7.
- Commit Hook
On Oct. 5, 2011, 7:28 a.m., Thomas Friedrichsmeier wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/101653/
> -----------------------------------------------------------
>
> (Updated Oct. 5, 2011, 7:28 a.m.)
>
>
> Review request for kdelibs.
>
>
> Description
> -------
>
> I guess this one needs some explaining...
>
> Many KParts::Plugins appear to assume that widgets that they add to a \
> KParts::StatusBarExtension (SE) will effectively be owned by SE, and will be \
> deleted with the extension. E.g. the konqi W3 Validator plugin has this code:
> void PluginValidators::removeStatusBarIcon()
> {
> if (!m_icon)
> return;
>
> m_statusBarExt = KParts::StatusBarExtension::childObject(m_part);
> if (!m_statusBarExt)
> return;
>
> m_statusBarExt->removeStatusBarItem(m_icon);
> delete m_icon;
> m_icon = 0;
> }
>
> Note the return when no SE exists (any more). Checking for the existence of the SE \
> is important, as it may become deleted before the plugins are deleted. In fact, at \
> least for KHTMLPart that is the case. However, the assumption that the icon will \
> have been deleted with the SE is wrong. It is still around. In konqueror this is \
> not visible, because the part is always sent a de-activate event before \
> destruction, and the SE hides the icons, then. In RKWard, parts typically do not \
> receive a de-activate event before destruction, turning the memory leak into a \
> visible icon leak (see this screenshot: \
> http://reaktanz.de/stuff/R/RKWard_icon_soup.png ).
> Fixing this in the plugin is simple: Only SE::removeStatusBarItem() would need to \
> be guarded. But the problem is bound to re-surface in the next plugin. Further, I \
> think the assumption that the widget will become owned by the SE is very \
> reasonable.
> ----- The part of the description below was changed for Version 2 of the patch \
> -----
> Basically that is what this patch does, by deleting the widget in the destructor. \
> Double deletion of the widget in both the StatusBarExtension and the Plugin should \
> not be a problem in this solution. In the StatusBarExtension, the widget is already \
> stored as a QPointer, and it is destroyed using deleteLater(), rather than \
> immediate deletion.
> Deprecating StatusBarExtension::removeStatusBarItem() may be somewhat \
> controversial. However, while I could think of valid use-cases for this in theory, \
> I firmly believe that none exists in practice. Rather all uses that I have seen are \
> in conjunction with the manual deletion of the added widget / icon. The deprecation \
> is intended to serve as a prompt for removing such - now obsolete - code.
>
> Diffs
> -----
>
> kparts/statusbarextension.h 69691d7f80c55a6193c345f7f514d35af2b20b15
> kparts/statusbarextension.cpp 11fdf40681c708bc0f031797083c7f6b6b638f60
>
> Diff: http://git.reviewboard.kde.org/r/101653/diff/diff
>
>
> Testing
> -------
>
>
> Thanks,
>
> Thomas Friedrichsmeier
>
>
[Attachment #3 (text/html)]
<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/101653/">http://git.reviewboard.kde.org/r/101653/</a>
</td>
</tr>
</table>
<br />
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This review has been \
submitted with commit 848a9f02135c06ec5743d7cac69e635898172323 by Thomas \
Friedrichsmeier to branch KDE/4.7.</pre> <br />
<p>- Commit</p>
<br />
<p>On October 5th, 2011, 7:28 a.m., Thomas Friedrichsmeier 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 kdelibs.</div>
<div>By Thomas Friedrichsmeier.</div>
<p style="color: grey;"><i>Updated Oct. 5, 2011, 7:28 a.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;">I guess this one needs some explaining...
Many KParts::Plugins appear to assume that widgets that they add to a \
KParts::StatusBarExtension (SE) will effectively be owned by SE, and will be deleted \
with the extension. E.g. the konqi W3 Validator plugin has this code:
void PluginValidators::removeStatusBarIcon()
{
if (!m_icon)
return;
m_statusBarExt = KParts::StatusBarExtension::childObject(m_part);
if (!m_statusBarExt)
return;
m_statusBarExt->removeStatusBarItem(m_icon);
delete m_icon;
m_icon = 0;
}
Note the return when no SE exists (any more). Checking for the existence of the SE is \
important, as it may become deleted before the plugins are deleted. In fact, at least \
for KHTMLPart that is the case. However, the assumption that the icon will have been \
deleted with the SE is wrong. It is still around. In konqueror this is not visible, \
because the part is always sent a de-activate event before destruction, and the SE \
hides the icons, then. In RKWard, parts typically do not receive a de-activate event \
before destruction, turning the memory leak into a visible icon leak (see this \
screenshot: http://reaktanz.de/stuff/R/RKWard_icon_soup.png ).
Fixing this in the plugin is simple: Only SE::removeStatusBarItem() would need to be \
guarded. But the problem is bound to re-surface in the next plugin. Further, I think \
the assumption that the widget will become owned by the SE is very reasonable.
----- The part of the description below was changed for Version 2 of the patch -----
Basically that is what this patch does, by deleting the widget in the destructor. \
Double deletion of the widget in both the StatusBarExtension and the Plugin should \
not be a problem in this solution. In the StatusBarExtension, the widget is already \
stored as a QPointer, and it is destroyed using deleteLater(), rather than immediate \
deletion.
Deprecating StatusBarExtension::removeStatusBarItem() may be somewhat controversial. \
However, while I could think of valid use-cases for this in theory, I firmly believe \
that none exists in practice. Rather all uses that I have seen are in conjunction \
with the manual deletion of the added widget / icon. The deprecation is intended to \
serve as a prompt for removing such - now obsolete - code. </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>kparts/statusbarextension.h <span style="color: \
grey">(69691d7f80c55a6193c345f7f514d35af2b20b15)</span></li>
<li>kparts/statusbarextension.cpp <span style="color: \
grey">(11fdf40681c708bc0f031797083c7f6b6b638f60)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/101653/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic