aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@live.com>2014-12-06 10:38:34 -0600
committerSimon Hausmann <simon.hausmann@digia.com>2014-12-08 16:28:25 +0100
commit7568922fa240e6e9440e9c6e93bf8ec00c06ec17 (patch)
treeb14dcf1f414c501097631c7e2373cd886b5d4aff
parent6a0145dd664ab9f5e3703ab3d0f962b3f378d6c6 (diff)
Avoid string-based connect in QQuickImageBase.
String-based connect is relatively slow, and should be avoided in core items. This improves performance of the tst_librarymetrics_performance::instantiation_cached(043) image - empty test case (approximately halving the time). Task-number: QTBUG-43096 Change-Id: I02485c515435eceacc95c55f877fc8566e7406d7 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/quick/items/qquickimagebase.cpp10
-rw-r--r--src/quick/items/qquickimagebase_p.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index 1a5d115a3c..a4c4af4e45 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -35,6 +35,7 @@
#include "qquickimagebase_p_p.h"
#include <QtGui/qguiapplication.h>
+#include <QtGui/qscreen.h>
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmlfile.h>
@@ -45,14 +46,12 @@ QQuickImageBase::QQuickImageBase(QQuickItem *parent)
: QQuickImplicitSizeItem(*(new QQuickImageBasePrivate), parent)
{
setFlag(ItemHasContents);
- connect(this, SIGNAL(windowChanged(QQuickWindow*)), SLOT(handleWindowChanged(QQuickWindow*)));
}
QQuickImageBase::QQuickImageBase(QQuickImageBasePrivate &dd, QQuickItem *parent)
: QQuickImplicitSizeItem(dd, parent)
{
setFlag(ItemHasContents);
- connect(this, SIGNAL(windowChanged(QQuickWindow*)), SLOT(handleWindowChanged(QQuickWindow*)));
}
QQuickImageBase::~QQuickImageBase()
@@ -278,10 +277,11 @@ void QQuickImageBase::requestProgress(qint64 received, qint64 total)
}
}
-void QQuickImageBase::handleWindowChanged(QQuickWindow* window)
+void QQuickImageBase::itemChange(ItemChange change, const ItemChangeData &value)
{
- if (window)
- connect(window, SIGNAL(screenChanged(QScreen*)), this, SLOT(handleScreenChanged(QScreen*)));
+ if (change == ItemSceneChange && value.window)
+ connect(value.window, &QQuickWindow::screenChanged, this, &QQuickImageBase::handleScreenChanged);
+ QQuickItem::itemChange(change, value);
}
void QQuickImageBase::handleScreenChanged(QScreen* screen)
diff --git a/src/quick/items/qquickimagebase_p.h b/src/quick/items/qquickimagebase_p.h
index 4446268a2b..2750db8873 100644
--- a/src/quick/items/qquickimagebase_p.h
+++ b/src/quick/items/qquickimagebase_p.h
@@ -93,12 +93,12 @@ protected:
virtual void load();
virtual void componentComplete();
virtual void pixmapChange();
+ void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE;
QQuickImageBase(QQuickImageBasePrivate &dd, QQuickItem *parent);
private Q_SLOTS:
virtual void requestFinished();
void requestProgress(qint64,qint64);
- void handleWindowChanged(QQuickWindow *window);
void handleScreenChanged(QScreen *screen);
private: