diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-12-22 03:17:30 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-12-22 03:17:30 -0600 |
commit | d1b6b7be7d5bc7754a143b424295a267bbdafdbd (patch) | |
tree | 20ee69ce981cd5ba62c65bb35b21188cd7b83246 /src/kernel | |
parent | f4193c940cdc34284e19cf4cb0687c1a8e81a458 (diff) | |
download | qt3-d1b6b7be7d5bc7754a143b424295a267bbdafdbd.tar.gz qt3-d1b6b7be7d5bc7754a143b424295a267bbdafdbd.zip |
Repair performance regression accidentally introduced with new style API
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/qobject.cpp | 52 | ||||
-rw-r--r-- | src/kernel/qobject.h | 6 | ||||
-rw-r--r-- | src/kernel/qstyle.cpp | 78 | ||||
-rw-r--r-- | src/kernel/qstyle.h | 14 | ||||
-rw-r--r-- | src/kernel/qthread_unix.cpp | 2 |
5 files changed, 111 insertions, 41 deletions
diff --git a/src/kernel/qobject.cpp b/src/kernel/qobject.cpp index 403691e..d6be971 100644 --- a/src/kernel/qobject.cpp +++ b/src/kernel/qobject.cpp @@ -49,6 +49,9 @@ #include "qucomextra_p.h" #include "qptrvector.h" +// QStyleControlElementData +#include "qstyle.h" + #ifdef QT_THREAD_SUPPORT #include "qmutex.h" #include <private/qmutexpool_p.h> @@ -58,6 +61,33 @@ #include <ctype.h> #include <stdlib.h> +// Keep in sync with duplicate definition in qcommonstyle.cpp +class QStyleControlElementDataPrivate { + public: + bool isQPushButton; + bool isQToolButton; + bool isQButton; + bool isQTabBar; + bool isQTitleBar; + bool isQToolBox; + bool isQToolBar; + bool isQProgressBar; + bool isQPopupMenu; + bool isQComboBox; + bool isQCheckBox; + bool isQRadioButton; + bool isQHeader; + bool isQScrollBar; + bool isQSlider; + bool isQDialogButtons; + bool isQSpinWidget; + bool isQListView; + bool isQDockWindow; + bool isQTabWidget; + bool isQFrame; + bool isQWidget; +}; + #ifndef QT_NO_USERDATA class QObjectPrivate : public QPtrVector<QObjectUserData> #else @@ -70,14 +100,36 @@ public: ownThread = NULL; disableThreadPostedEvents = false; setAutoDelete( TRUE ); + controlElementData = NULL; + controlElementDataPrivate = NULL; + } + ~QObjectPrivate() { + delete controlElementData; + delete controlElementDataPrivate; } #endif QThread* ownThread; QMutex* senderObjectListMutex; QMutex* childObjectListMutex; bool disableThreadPostedEvents; + QStyleControlElementData* controlElementData; + QStyleControlElementDataPrivate* controlElementDataPrivate; }; +QStyleControlElementData* QObject::controlElementDataObject() { + if (!d->controlElementData) { + d->controlElementData = new QStyleControlElementData(); + } + return d->controlElementData; +} + +QStyleControlElementDataPrivate* QObject::controlElementDataPrivateObject() { + if (!d->controlElementDataPrivate) { + d->controlElementDataPrivate = new QStyleControlElementDataPrivate(); + } + return d->controlElementDataPrivate; +} + #if defined(QT_THREAD_SUPPORT) void QObject::moveToThread_helper(QThread *targetThread) diff --git a/src/kernel/qobject.h b/src/kernel/qobject.h index a63fc4d..3a86cb9 100644 --- a/src/kernel/qobject.h +++ b/src/kernel/qobject.h @@ -68,6 +68,9 @@ struct QUObject; class QThread; #endif +class QStyleControlElementData; +class QStyleControlElementDataPrivate; + class Q_EXPORT QObject: public Qt { Q_OBJECT @@ -140,6 +143,9 @@ public: void dumpObjectTree(); void dumpObjectInfo(); + QStyleControlElementData* controlElementDataObject(); + QStyleControlElementDataPrivate* controlElementDataPrivateObject(); + #ifndef QT_NO_PROPERTIES virtual bool setProperty( const char *name, const QVariant& value ); virtual QVariant property( const char *name ) const; diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp index 75757c9..eb12c1b 100644 --- a/src/kernel/qstyle.cpp +++ b/src/kernel/qstyle.cpp @@ -637,8 +637,8 @@ QStyle::~QStyle() \sa unPolish() */ void QStyle::polish( QWidget *widget ) { - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - polish(ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + polish(ceData, getControlElementFlagsForObject(widget, QStyleOption()), widget); } /*! @@ -652,8 +652,8 @@ void QStyle::polish( QWidget *widget ) { \sa polish() */ void QStyle::unPolish( QWidget *widget ) { - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - unPolish(ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(widget, QStyleOption()), widget); } /*! @@ -715,8 +715,8 @@ void QStyle::unPolish( const QStyleControlElementData &ceData, ControlElementFla \sa unPolish() */ void QStyle::polish( QApplication *app ) { - QStyleControlElementData ceData = populateControlElementDataFromApplication(app, QStyleOption()); - applicationPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app); + const QStyleControlElementData &ceData = populateControlElementDataFromApplication(app, QStyleOption()); + applicationPolish(ceData, getControlElementFlagsForObject(app, QStyleOption()), app); } /*! @@ -727,8 +727,8 @@ void QStyle::polish( QApplication *app ) { \sa polish() */ void QStyle::unPolish( QApplication *app ) { - QStyleControlElementData ceData = populateControlElementDataFromApplication(app, QStyleOption()); - applicationUnPolish(ceData, getControlElementFlagsForObject(app, ceData.widgetObjectTypes, QStyleOption()), app); + const QStyleControlElementData &ceData = populateControlElementDataFromApplication(app, QStyleOption()); + applicationUnPolish(ceData, getControlElementFlagsForObject(app, QStyleOption()), app); } /*! @@ -782,8 +782,8 @@ void QStyle::polish( QPalette&) checkable by default (\l{QPopupMenu::setCheckable()}). */ void QStyle::polishPopupMenu( QPopupMenu *pm ) { - QStyleControlElementData ceData = populateControlElementDataFromWidget(pm, QStyleOption()); - unPolish(ceData, getControlElementFlagsForObject(pm, ceData.widgetObjectTypes, QStyleOption()), pm); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(pm, QStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(pm, QStyleOption()), pm); } /*! @@ -2351,14 +2351,16 @@ bool QStyle::eventFilter(QObject *o, QEvent *e) { if (m_objectEventSourceToHandlerMap.contains(o)) { QStyle* handler = m_objectEventSourceToHandlerMap[o]; - QStyleControlElementData ceData = m_objectEventSourceDataToHandlerMap[o]; + const QStyleControlElementData &ceData = m_objectEventSourceDataToHandlerMap[o]; ControlElementFlags elementFlags = m_objectEventSourceFlagsToHandlerMap[o]; bool ret; QWidget* w = dynamic_cast<QWidget*>(o); if ((w) && (e->type() == QEvent::Paint)) { QPainter p(w); - ceData.activePainter = &p; + QPainter* activePainterOrig = ceData.activePainter; + const_cast<QStyleControlElementData&>(ceData).activePainter = &p; ret = handler->objectEventHandler(ceData, elementFlags, o, e); + const_cast<QStyleControlElementData&>(ceData).activePainter = activePainterOrig; } else { ret = handler->objectEventHandler(ceData, elementFlags, o, e); @@ -2638,8 +2640,8 @@ void QStyle::drawPrimitive( PrimitiveElement pe, } } - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, opt); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, QStyleOption()), r, cg, flags, opt); } void QStyle::drawControl( ControlElement element, @@ -2657,8 +2659,8 @@ void QStyle::drawControl( ControlElement element, } #endif - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawControl(element, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, cg, flags, opt, widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawControl(element, p, ceData, getControlElementFlagsForObject(widget, opt), r, cg, flags, opt, widget); } void QStyle::drawControlMask( ControlElement control, @@ -2667,8 +2669,8 @@ void QStyle::drawControlMask( ControlElement control, const QRect &r, const QStyleOption& opt ) const { - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), r, opt, widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, opt), r, opt, widget); } QRect QStyle::subRect(SubRect r, const QWidget *widget) const @@ -2680,8 +2682,8 @@ QRect QStyle::subRect(SubRect r, const QWidget *widget) const } #endif - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - return subRect(r, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, QStyleOption()); + return subRect(r, ceData, getControlElementFlagsForObject(widget, QStyleOption()), widget); } void QStyle::drawComplexControl( ComplexControl control, @@ -2701,8 +2703,8 @@ void QStyle::drawComplexControl( ComplexControl control, } #endif - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, cg, flags, controls, active, opt, widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, QStyleOption()), r, cg, flags, controls, active, opt, widget); } void QStyle::drawComplexControlMask( ComplexControl control, @@ -2711,8 +2713,8 @@ void QStyle::drawComplexControlMask( ComplexControl control, const QRect &r, const QStyleOption& opt ) const { - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), r, opt, widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, QStyleOption()), r, opt, widget); } QRect QStyle::querySubControlMetrics( ComplexControl control, @@ -2727,8 +2729,8 @@ QRect QStyle::querySubControlMetrics( ComplexControl control, } #endif - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt, false); - return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), sc, opt, widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt, false); + return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, QStyleOption()), sc, opt, widget); } QStyle::SubControl QStyle::querySubControl(ComplexControl control, @@ -2736,14 +2738,14 @@ QStyle::SubControl QStyle::querySubControl(ComplexControl control, const QPoint &pos, const QStyleOption& opt ) const { - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - return querySubControl(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, opt), pos, opt, widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + return querySubControl(control, ceData, getControlElementFlagsForObject(widget, opt), pos, opt, widget); } int QStyle::pixelMetric(PixelMetric m, const QWidget *widget) const { - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, QStyleOption()); - return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, QStyleOption(), false); + return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, QStyleOption()), widget); } QSize QStyle::sizeFromContents(ContentsType contents, @@ -2760,8 +2762,8 @@ QSize QStyle::sizeFromContents(ContentsType contents, } #endif - QStyleControlElementData ceData = populateControlElementDataFromWidget(widget, opt); - return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, QStyleOption()), contentsSize, opt, widget); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, QStyleOption()), contentsSize, opt, widget); } int QStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption &so, QStyleHintReturn *shr) const @@ -2770,14 +2772,14 @@ int QStyle::styleHint(StyleHint sh, const QWidget * w, const QStyleOption &so, Q if (sh == SH_Widget_ShareActivation) { ceDataNotNeeded = true; } - QStyleControlElementData ceData = populateControlElementDataFromWidget(w, so, false, ceDataNotNeeded); - return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption(), false), so, shr, w); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(w, so, false, ceDataNotNeeded); + return styleHint(sh, ceData, getControlElementFlagsForObject(w, QStyleOption(), false), so, shr, w); } QPixmap QStyle::stylePixmap(StylePixmap sp, const QWidget *w, const QStyleOption &so) const { - QStyleControlElementData ceData = populateControlElementDataFromWidget(w, so); - return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, QStyleOption()), so, w); + const QStyleControlElementData &ceData = populateControlElementDataFromWidget(w, so); + return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, QStyleOption()), so, w); } /*! @@ -2830,4 +2832,8 @@ QStyleControlElementData::QStyleControlElementData() { topLevelWidgetFlags = 0; } +QStyleControlElementData::~QStyleControlElementData() { + // +} + #endif // QT_NO_STYLE diff --git a/src/kernel/qstyle.h b/src/kernel/qstyle.h index be23340..3f4ae79 100644 --- a/src/kernel/qstyle.h +++ b/src/kernel/qstyle.h @@ -223,6 +223,7 @@ class QStyleControlElementTabBarData { class Q_EXPORT QStyleControlElementData { public: QStyleControlElementData(); + ~QStyleControlElementData(); public: bool isNull; @@ -285,6 +286,11 @@ class Q_EXPORT QStyleControlElementData { QStyleControlElementGenericWidgetData topLevelWidgetData; Q_UINT32 topLevelWidgetFlags; QPixmap paletteBgPixmap; + + private: + // Disable copy constructor + QStyleControlElementData(const QStyleControlElementData&); + }; class Q_EXPORT QStyleWidgetActionRequestData { @@ -1222,11 +1228,11 @@ private: inline QStyle::ControlElementFlags operator|(const QStyle::ControlElementFlags a, const QStyle::ControlElementFlags b) { return static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); } // inline QStyle::ControlElementFlags operator|=(QStyle::ControlElementFlags &a, const QStyle::ControlElementFlags b) { a = static_cast<QStyle::ControlElementFlags>(static_cast<int>(a) | static_cast<int>(b)); return a; } -Q_EXPORT QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields=true); -Q_EXPORT QStyleControlElementData populateControlElementDataFromApplication(const QApplication* app, const QStyleOption& opt, bool populateReliantFields=true); -Q_EXPORT QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, QStringList objectTypeList, const QStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT const QStyleControlElementData &populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT const QStyleControlElementData &populateControlElementDataFromApplication(const QApplication* app, const QStyleOption& opt, bool populateReliantFields=true); +Q_EXPORT QStyle::ControlElementFlags getControlElementFlagsForObject(const QObject* object, const QStyleOption& opt, bool populateReliantFields=true); Q_EXPORT QStringList getObjectTypeListForObject(const QObject* object); -Q_EXPORT QStyleControlElementData populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields, bool populateMinimumNumberOfFields); +Q_EXPORT const QStyleControlElementData &populateControlElementDataFromWidget(const QWidget* widget, const QStyleOption& opt, bool populateReliantFields, bool populateMinimumNumberOfFields); #endif // QT_NO_STYLE #endif // QSTYLE_H diff --git a/src/kernel/qthread_unix.cpp b/src/kernel/qthread_unix.cpp index bc492af..1358250 100644 --- a/src/kernel/qthread_unix.cpp +++ b/src/kernel/qthread_unix.cpp @@ -410,7 +410,7 @@ void QThread::start(Priority priority) d->args[1] = d; #if defined(QT_USE_GLIBMAINLOOP) // The correct thread_id is set in QThreadInstance::start using the value of d->args[1] - d->thread_id = NULL; + d->thread_id = 0; // Legacy glib versions require this threading system initialization call if (!GLIB_CHECK_VERSION (2, 32, 0)) { |