Why so many QStyles
faure at kde.org
Sun Jan 4 13:54:36 UTC 2015
On Sunday 04 January 2015 13:51:15 David Faure wrote:
> 2) I can't think of a reason against passing qApp->style() to the
> KLineEditStyle ctor; the rest of the code in QProxyStyle::ensureBaseStyle is
> about the -style cmdline override (which qApp->style() honours too).
More testing gives a very good reason against doing that...
"Ownership of style is transferred to QProxyStyle."
==2384== at 0x4C2A601: operator delete(void*) (vg_replace_malloc.c:510)
==2384== by 0x1E07D5DB: Breeze::Style::~Style() (breezestyle.cpp:200)
==2384== by 0xC6335BB: QObjectPrivate::deleteChildren() (qobject.cpp:1935)
==2384== by 0xC631CF7: QObject::~QObject() (qobject.cpp:1028)
==2384== by 0xB3092BF: QStyle::~QStyle() (qstyle.cpp:420)
==2384== by 0xB315CDD: QCommonStyle::~QCommonStyle() (qcommonstyle.cpp:131)
==2384== by 0xB34563F: QProxyStyle::~QProxyStyle() (qproxystyle.cpp:151)
==2384== by 0x7FF262F: KLineEditStyle::~KLineEditStyle() (in /d/kde/inst/kde_frameworks/lib64/libKF5Completion.so.5.6.0)
==2384== by 0x7FF265F: KLineEditStyle::~KLineEditStyle() (klineedit_p.h:185)
==2384== by 0x7FE768F: KLineEditPrivate::~KLineEditPrivate() (klineedit.cpp:51)
==2384== by 0x7FF19FA: QScopedPointerDeleter<KLineEditPrivate>::cleanup(KLineEditPrivate*) (qscopedpointer.h:62)
==2384== by 0x7FF12A2: QScopedPointer<KLineEditPrivate, QScopedPointerDeleter<KLineEditPrivate> >::~QScopedPointer() (qscopedpointer.h:109)
==2384== by 0x7FE8107: KLineEdit::~KLineEdit() (klineedit.cpp:202)
And QProxyStyle::setBaseStyle transfers ownership too.
So clearly the intent is that a separate widget style instance is used as the base for every proxy style.
I'm not sure why, but that's what we'll have to work with.
[OTOH I wonder if KLineEdit couldn't keep its proxy style as a singleton, so that only one
instance of it is created, this would at least keep instances down a bit. But it has some state
(data members) so maybe this isn't possible].
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5
More information about the Kde-frameworks-devel