[PATCH] Fix infinite recursion in KdeuiWidgetsProxyStyle

Rafael Fernández López ereslibre at kde.org
Wed Jun 11 22:48:03 BST 2008


Hi Aurélien and all,

> You (may) know that KLineEdit uses KdeuiWidgetsProxyStyle to define the
> right margin necessary to show the "clear" button. To do so it uses a
> proxy of QStyle(): KdeuiWidgetsProxyStyle.

I wasn't aware of that, and... as I see on the code (unrelated to this topic) 
there is code in there that is not compliant with our kdelibs coding style.

> This causes infinite recursion when the KLineEdit parent uses
> QStyleSheetStyle because also acts as a proxy to the "base" style.
>
> The first patch breaks the infinite recursion by detecting if the style
> proxied by KdeuiWidgetsProxyStyle is QStyleSheetStyle. It fixes a crash
> in Gwenview when one tries to edit places shown on the start page.
> It also fixes most crashes caused by passing a custom stylesheet to the
> application from the command line. Konqueror still crashes, but Dolphin
> and Gwenview and a few others no longer crash.
>
> The second patch reworks the way KLineEdit tells KLineEditStyle
> (inherited from KdeuiWidgetsProxyStyle) the margin to reserve for the
> "clear" button. I had to do so because after the first patch, the casts:
>
> dynamic_cast<KLineEditStyle*>(style())
>
> Would return 0 if the parent widget where using QStyleSheetStyle (I
> haven't figured out why).

I have no idea (haven't played around with QStyleSheets, mainly because I 
consider them evil for a configurable desktop, is OK for e.g. suse installer).

OTOH it would have been nice to know the exact reason of this failing.

And, I must say... I usually don't like to see how QStyle, QFont & friends are 
"cached". That means that if the user goes to systemsettings and change 
something, your app will continue to live as if nothing happened, or even 
worse, some parts of it will react to the changes, and others that had values 
cached won't, resulting in a probably unusable app while it is still open, and 
forcing the user to restart the app.

Don't get me wrong, if it fixes a patch is good, but going a bit further is 
good... and caching those kind of objects that will decide how the window 
looks or reacts to user events is not a good idea in general.


Regards,
Rafael Fernández López.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080611/804335b1/attachment.sig>


More information about the kde-core-devel mailing list