[PATCH] Fix infinite recursion in KdeuiWidgetsProxyStyle
Olivier Goffart
ogoffart at kde.org
Thu Jun 12 22:02:00 BST 2008
Le mercredi 11 juin 2008, Aurélien Gâteau a écrit :
> Hello,
>
> 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.
>
> This causes infinite recursion when the KLineEdit parent uses
> QStyleSheetStyle because also acts as a proxy to the "base" style.
If fact, it should not recurse infinitively.
Let's say you have QStyleSheetStyle which is the proxy for the OriginalStyle
Then you add KdeuiWidgetsProxyStyle. which will be the proxy of the old
QStyleSheetStyle. But a new QStyleSheetStyle will be created on top.
So we will have
QStyleSheetStyle -> KdeuiWidgetsProxyStyle -> QStyleSheetStyle -> OriginalStyl
e (where -> mean "is a proxy for")
Now, maybe there is a bug making that some style may be deleted while they
should not.
I'll look into that.
> 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).
The reason why is because the style() is QStyleSheetStyle and not the
KLineEditStyle anymore.
> + // We may still get a QStyleSheetStyle based style if
> + // QApplication::style() is a QStyleSheetStyle. In this case, fallback
> + // to Windows style: since it's the base class of QStyleSheetStyle,
> + // it's probably the closest one.
The window style is the base class because it's the one which is the base
class of the biggest number of style. But for KDE it's probably not what we
want... Maybe Oxygen or Plastique.
-------------- 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/20080612/f10daf41/attachment.sig>
More information about the kde-core-devel
mailing list