summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-03-01 17:06:29 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-03-02 14:55:44 (GMT)
commitad1b5495a2a437d21435a9c321c9abf612cd210e (patch)
tree42f4d4bf3669ce9727dc59ffc0eb7127e545e6be
parent6f3fe3fee31697d8e828b0f88e9111bfbbb62490 (diff)
downloadQt-ad1b5495a2a437d21435a9c321c9abf612cd210e.zip
Qt-ad1b5495a2a437d21435a9c321c9abf612cd210e.tar.gz
Qt-ad1b5495a2a437d21435a9c321c9abf612cd210e.tar.bz2
Fixed Windows performance regression introduced by ac2818bef95f134.
Only create a temporary DC if we're not on the main thread. Task-number: QTBUG-24602 Change-Id: I36dad4c197c7cc1e019b19d42c81526fc8cfdcf4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
-rw-r--r--src/gui/kernel/qwidget_win.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp
index 3fdc00c..8a400cd 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/gui/kernel/qwidget_win.cpp
@@ -49,6 +49,7 @@
#include "qlayout.h"
#include "qpainter.h"
#include "qstack.h"
+#include "qthread.h"
#include "qt_windows.h"
#include "qwidget.h"
#include "qwidget_p.h"
@@ -1636,6 +1637,8 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
}
}
+extern Q_GUI_EXPORT HDC qt_win_display_dc();
+
int QWidget::metric(PaintDeviceMetric m) const
{
Q_D(const QWidget);
@@ -1645,7 +1648,8 @@ int QWidget::metric(PaintDeviceMetric m) const
} else if (m == PdmHeight) {
val = data->crect.height();
} else {
- HDC gdc = GetDC(0);
+ bool ownDC = QThread::currentThread() != qApp->thread();
+ HDC gdc = ownDC ? GetDC(0) : qt_win_display_dc();
switch (m) {
case PdmDpiX:
case PdmPhysicalDpiX:
@@ -1696,7 +1700,8 @@ int QWidget::metric(PaintDeviceMetric m) const
val = 0;
qWarning("QWidget::metric: Invalid metric command");
}
- ReleaseDC(0, gdc);
+ if (ownDC)
+ ReleaseDC(0, gdc);
}
return val;
}