[PATCH] Fix infinite recursion in KdeuiWidgetsProxyStyle

David Faure faure at kde.org
Thu Jun 12 19:10:30 BST 2008

On Wednesday 11 June 2008, Aurélien Gâteau wrote:
> dynamic_cast<KLineEditStyle*>(style())
> Would return 0 if the parent widget where using QStyleSheetStyle (I 
> haven't figured out why).

Well, because QWidget::setStyleSheet() sets the widget's style to be the QStyleSheetStyle,
so obviously style() is a QStyleSheetStyle* and not a KLineEditStyle* anymore...

Anyway the klineedit.cpp change is fine, makes things more robust.

The proxystyle change is, well, I'm happy you found a fix, but obviously it's not that robust;
it uses the classname of an internal Qt class which could be renamed any day, or
any other other similar proxy could end up creating the same trouble; it has a
"fallback to windows style" last resort which sounds like it might create bugs...
I wish Qt had real support for proxy styles and avoided the recursion in the first place.
I still don't really understand why it recurses, normally proxies (e.g. in modelview)
only call down in the stack, never up...
Hmm isn't this because we use the style of the parentwidget of the lineedit, instead
of simply storing the style which the lineedit itself was using, before setting our proxy?
This would seem like a better approach for setting up the proxy style in a way
that avoids the recursion, no? I mean passing the current style of the lineedit 
(if it's not a kdeuiproxystyle already) to the kdeuiproxystyle constructor.

But if my idea is nonsense then I'm not objecting to your fix since it means 
I'll finally be able to commit the support for user-configurable kde-global
stylesheet (after 4.1) :-)

David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).

More information about the kde-core-devel mailing list