[PATCH] Fix infinite recursion in KdeuiWidgetsProxyStyle

Aurélien Gâteau aurelien.gateau at free.fr
Wed Jun 11 23:09:58 BST 2008


Rafael Fernández López wrote:
>> 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).

They can be useful to debug too, you know. Want to see widget 
boundaries? create tmp.css with this content:

-----------
* {
     border: 1px solid red;
}
-----------

And start your app like this:

myapp -stylesheet tmp.css

(this is a classic web design trick, I find it amusing that those tricks 
can be applied to applications now)

> 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.

I don't see what is cached in this code. KdeuiWidgetsProxyStyle does not 
store anything, and it asks the parent widget for its style everytime 
it's needed.

Aurélien




More information about the kde-core-devel mailing list