summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/syncqt.pl98
-rwxr-xr-xconfigure4
-rw-r--r--src/corelib/kernel/qvariant.cpp48
-rw-r--r--src/corelib/thread/qthread_unix.cpp6
-rw-r--r--src/corelib/tools/qlocale_blackberry.cpp4
-rw-r--r--src/gui/kernel/qguiapplication.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.cpp3
-rw-r--r--src/plugins/platforms/windows/qplatformfunctions_wince.h1
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp4
-rw-r--r--src/widgets/widgets/qdockwidget.cpp3
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp42
-rw-r--r--tests/auto/opengl/qgl/tst_qgl.cpp4
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp8
13 files changed, 147 insertions, 80 deletions
diff --git a/bin/syncqt.pl b/bin/syncqt.pl
index cc91a11de0..8c1e04e0d0 100755
--- a/bin/syncqt.pl
+++ b/bin/syncqt.pl
@@ -97,7 +97,6 @@ my $force_win = 0;
my $force_relative = 0;
my $check_includes = 0;
my $copy_headers = 0;
-my $create_uic_class_map = 0;
my $create_private_headers = 1;
my $minimal = 0;
my $module_version = 0;
@@ -508,36 +507,6 @@ sub copyFile
}
######################################################################
-# Syntax: symlinkFile(file, ifile)
-# Params: file, string, filename to create "symlink" for
-# ifile, string, destination name of symlink
-#
-# Purpose: File is symlinked to ifile (or copied if filesystem doesn't
-# support symlink).
-# Returns: 1 on success, else 0.
-######################################################################
-sub symlinkFile
-{
- my ($lib, $file, $ifile) = @_;
-
- if ($isunix) {
- print "$lib: symlink created for $file " if ($verbose_level);
- if ( $force_relative && ($ifile =~ /^$quoted_basedir/)) {
- my $t = getcwd();
- my $c = -1;
- my $p = "../";
- $t =~ s-^$quoted_basedir/--;
- $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 );
- $file =~ s-^$quoted_basedir/-$p-;
- print " ($file)\n" if($verbose_level);
- }
- print "\n" if($verbose_level);
- return symlink($file, $ifile);
- }
- return copyFile($lib, $file, $ifile);
-}
-
-######################################################################
# Syntax: findFiles(dir, match, descend)
# Params: dir, string, directory to search for name
# match, string, regular expression to match in dir
@@ -786,7 +755,6 @@ while ( @ARGV ) {
$modules{$module} = $prodir;
push @modules_to_sync, $module;
$moduleheaders{$module} = $headerdir;
- $create_uic_class_map = 0;
} elsif ($var eq "version") {
if($val) {
$module_version = $val;
@@ -1079,34 +1047,37 @@ foreach my $lib (@modules_to_sync) {
my $header_dir = dirname($header_path);
make_path($header_dir, $lib, $verbose_level);
- open(HEADER, ">$header_path") || die "Could not open $header_path for writing: $!\n";
- print HEADER "#ifndef $guard\n";
- print HEADER "#define $guard\n";
+ my $hdrcont =
+ "#ifndef $guard\n" .
+ "#define $guard\n";
my $warning = "Header <$lib/";
$warning .= "private/" unless ($public_header);
$warning .= "$header> is deprecated. Please include <$include> instead.";
- print HEADER "#if defined(__GNUC__)\n";
- print HEADER "# warning $warning\n";
- print HEADER "#elif defined(_MSC_VER)\n";
- print HEADER "# pragma message (\"$warning\")\n";
- print HEADER "#endif\n";
- print HEADER "#include <$include>\n";
+ $hdrcont .=
+ "#if defined(__GNUC__)\n" .
+ "# warning $warning\n" .
+ "#elif defined(_MSC_VER)\n" .
+ "# pragma message (\"$warning\")\n" .
+ "#endif\n" .
+ "#include <$include>\n";
if ($public_header) {
- print HEADER "#if 0\n";
- print HEADER "#pragma qt_no_master_include\n";
- print HEADER "#endif\n";
+ $hdrcont .=
+ "#if 0\n" .
+ "#pragma qt_no_master_include\n" .
+ "#endif\n";
}
- print HEADER "#endif\n";
- close HEADER;
-
- if ($verbose_level < 3) {
- my $line_prefix = ",";
- $line_prefix = "$lib: created deprecated header(s) {" if ($first);
- print "$line_prefix $header";
- } else {
- print "$lib: created deprecated header $header => $include\n";
+ $hdrcont .=
+ "#endif\n";
+ if (writeFile($header_path, $hdrcont)) {
+ if ($verbose_level < 3) {
+ my $line_prefix = ",";
+ $line_prefix = "$lib: created deprecated header(s) {" if ($first);
+ print "$line_prefix $header";
+ } else {
+ print "$lib: created deprecated header $header => $include\n";
+ }
+ $first = 0;
}
- $first = 0;
}
my $addendum = fixPaths($header_path, $dir) . " ";
@@ -1156,25 +1127,6 @@ foreach my $lib (@modules_to_sync) {
writeFile($headers_pri_file, $headers_pri_contents, $lib, "headers.pri file");
}
}
-unless($showonly || !$create_uic_class_map) {
- my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h";
- if(-e $class_lib_map) {
- open CLASS_LIB_MAP, "<$class_lib_map";
- local $/;
- binmode CLASS_LIB_MAP;
- my $old_class_lib_map_contents = <CLASS_LIB_MAP>;
- close CLASS_LIB_MAP;
- $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
- $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents);
- }
- if($class_lib_map) {
- my $class_lib_map_dir = dirname($class_lib_map);
- make_path($class_lib_map_dir, "<outdir>", $verbose_level);
- open CLASS_LIB_MAP, ">$class_lib_map";
- print CLASS_LIB_MAP $class_lib_map_contents;
- close CLASS_LIB_MAP;
- }
-}
if($check_includes) {
foreach my $lib (@modules_to_sync) {
diff --git a/configure b/configure
index d7c96749f4..a5831efb50 100755
--- a/configure
+++ b/configure
@@ -6421,9 +6421,7 @@ echo "#define QT_QPA_DEFAULT_PLATFORM_NAME \"$QT_QPA_DEFAULT_PLATFORM\"" >>"$out
if cmp -s "$outpath/src/corelib/global/qconfig.h" "$outpath/src/corelib/global/qconfig.h.new"; then
rm -f "$outpath/src/corelib/global/qconfig.h.new"
else
- [ -f "$outpath/src/corelib/global/qconfig.h" ] && chmod +w "$outpath/src/corelib/global/qconfig.h"
- mv "$outpath/src/corelib/global/qconfig.h.new" "$outpath/src/corelib/global/qconfig.h"
- chmod -w "$outpath/src/corelib/global/qconfig.h"
+ mv -f "$outpath/src/corelib/global/qconfig.h.new" "$outpath/src/corelib/global/qconfig.h"
fi
# create a forwarding header
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index bae4a837a0..276257ddcf 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -162,6 +162,10 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d)
return qRound64(d->data.f);
case QVariant::Double:
return qRound64(d->data.d);
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QJsonValue:
+ return v_cast<QJsonValue>(d)->toDouble();
+#endif
}
Q_ASSERT(false);
return 0;
@@ -206,12 +210,14 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
case QMetaType::Long:
case QMetaType::Float:
case QMetaType::LongLong:
+ case QMetaType::QJsonValue:
return qMetaTypeNumber(d);
case QVariant::ULongLong:
case QVariant::UInt:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
+
return qlonglong(qMetaTypeUNumber(d));
}
@@ -240,6 +246,7 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
case QMetaType::Long:
case QMetaType::Float:
case QMetaType::LongLong:
+ case QMetaType::QJsonValue:
return qulonglong(qMetaTypeNumber(d));
case QVariant::ULongLong:
case QVariant::UInt:
@@ -340,6 +347,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QVariant::Url:
*str = v_cast<QUrl>(d)->toString();
break;
+ case QMetaType::QJsonValue:
+ *str = v_cast<QJsonValue>(d)->toString();
+ break;
#endif
case QVariant::Uuid:
*str = v_cast<QUuid>(d)->toString();
@@ -580,6 +590,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::ULong:
*b = qMetaTypeUNumber(d) != Q_UINT64_C(0);
break;
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QJsonValue:
+ *b = v_cast<QJsonValue>(d)->toBool();
+ break;
+#endif
default:
*b = false;
return false;
@@ -616,6 +631,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::ULong:
*f = double(qMetaTypeUNumber(d));
break;
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QJsonValue:
+ *f = v_cast<QJsonValue>(d)->toDouble();
+ break;
+#endif
default:
*f = 0.0;
return false;
@@ -652,6 +672,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::ULong:
*f = float(qMetaTypeUNumber(d));
break;
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QJsonValue:
+ *f = v_cast<QJsonValue>(d)->toDouble();
+ break;
+#endif
default:
*f = 0.0f;
return false;
@@ -2731,6 +2756,29 @@ bool QVariant::canConvert(int targetTypeId) const
if (targetTypeId >= QMetaType::User)
return canConvertMetaObject(currentType, targetTypeId, d.data.o);
+ if (currentType == QMetaType::QJsonValue) {
+ switch (targetTypeId) {
+ case QMetaType::QString:
+ case QMetaType::Bool:
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ case QMetaType::Double:
+ case QMetaType::Float:
+ case QMetaType::ULong:
+ case QMetaType::Long:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
+ case QMetaType::UShort:
+ case QMetaType::UChar:
+ case QMetaType::Char:
+ case QMetaType::SChar:
+ case QMetaType::Short:
+ return true;
+ default:
+ return false;
+ }
+ }
+
// FIXME It should be LastCoreType intead of Uuid
if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) {
switch (uint(targetTypeId)) {
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index f123e1813b..be9b946990 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -172,6 +172,12 @@ static void destroy_current_thread_data_key()
{
pthread_once(&current_thread_data_once, create_current_thread_data_key);
pthread_key_delete(current_thread_data_key);
+
+ // Reset current_thread_data_once in case we end up recreating
+ // the thread-data in the rare case of QObject construction
+ // after destroying the QThreadData.
+ pthread_once_t pthread_once_init = PTHREAD_ONCE_INIT;
+ current_thread_data_once = pthread_once_init;
}
Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key)
diff --git a/src/corelib/tools/qlocale_blackberry.cpp b/src/corelib/tools/qlocale_blackberry.cpp
index 6d60a97062..e2dfa6c801 100644
--- a/src/corelib/tools/qlocale_blackberry.cpp
+++ b/src/corelib/tools/qlocale_blackberry.cpp
@@ -289,9 +289,9 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
case DateToStringShort:
return lc_region.toString(in.toDate(), QLocale::ShortFormat);
case TimeToStringLong:
- return lc_region.toString(in.toTime(), QLocale::LongFormat);
+ return lc_region.toString(in.toTime(), d->timeFormat(QLocale::LongFormat).toString());
case TimeToStringShort:
- return lc_region.toString(in.toTime(), QLocale::ShortFormat);
+ return lc_region.toString(in.toTime(), d->timeFormat(QLocale::ShortFormat).toString());
case DateTimeToStringShort:
return lc_region.toString(in.toDateTime(), d->dateTimeFormat(QLocale::ShortFormat).toString());
case DateTimeToStringLong:
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 3c3cea2910..add1c1f90b 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -789,7 +789,7 @@ static void init_platform(const QString &pluginArgument, const QString &platform
fatalMessage += QStringLiteral("Available platforms are: %1\n").arg(
keys.join(QStringLiteral(", ")));
fatalMessage += QStringLiteral("GUI applications require a platform plugin. Terminating.");
- qFatal(qPrintable(fatalMessage));
+ qFatal("%s", qPrintable(fatalMessage));
return;
}
diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp
index 005b6d272a..ed959467ff 100644
--- a/src/plugins/platforms/qnx/qqnxglcontext.cpp
+++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp
@@ -315,6 +315,9 @@ void QQnxGLContext::createSurface(QPlatformSurface *surface)
}
platformWindow->setBufferSize(surfaceSize);
+ // Post root window, in case it hasn't been posted yet, to make it appear.
+ platformWindow->screen()->onWindowPost(platformWindow);
+
// Obtain the native handle for our window
screen_window_t handle = platformWindow->nativeHandle();
diff --git a/src/plugins/platforms/windows/qplatformfunctions_wince.h b/src/plugins/platforms/windows/qplatformfunctions_wince.h
index 3190e39ec5..30fc66563e 100644
--- a/src/plugins/platforms/windows/qplatformfunctions_wince.h
+++ b/src/plugins/platforms/windows/qplatformfunctions_wince.h
@@ -74,6 +74,7 @@
#ifndef CWP_SKIPINVISIBLE
#define CWP_SKIPINVISIBLE 0x0001
+#define CWP_SKIPTRANSPARENT 0x0004
#define findPlatformWindowAt(a, b, c) findPlatformWindowAt(a, b)
#endif
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 5c096b7eca..c6cfa4dbbc 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -232,8 +232,10 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
}
const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition);
+ // In this context, neither an invisible nor a transparent window (transparent regarding mouse
+ // events, "click-through") can be considered as the window under mouse.
QWindow *currentWindowUnderMouse = platformWindow->hasMouseCapture() ?
- QWindowsScreen::windowAt(globalPosition) : window;
+ QWindowsScreen::windowAt(globalPosition, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT) : window;
compressMouseMove(&msg);
// Qt expects the platform plugin to capture the mouse on
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index a3c331aa2b..ae931deb16 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -1259,6 +1259,9 @@ void QDockWidget::setFloating(bool floating)
d->endDrag(true);
QRect r = d->undockedGeometry;
+ // Keep position when undocking for the first time.
+ if (floating && isVisible() && !r.isValid())
+ r = QRect(mapToGlobal(QPoint(0, 0)), size());
d->setWindowState(floating, false, floating ? r : QRect());
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 62b894178e..4d862f4fc5 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -142,6 +142,9 @@ private slots:
void toDouble_data();
void toDouble();
+ void toFloat_data();
+ void toFloat();
+
void toPointF_data();
void toPointF();
@@ -456,6 +459,9 @@ void tst_QVariant::canConvert_data()
var = QVariant::fromValue<signed char>(-1);
QTest::newRow("SChar")
<< var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
+ var = QVariant::fromValue<QJsonValue>(QJsonValue(QStringLiteral("hello")));
+ QTest::newRow("JsonValue")
+ << var << N << N << Y << N << N << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y;
#undef N
#undef Y
@@ -511,6 +517,7 @@ void tst_QVariant::toInt_data()
bytearray[2] = '0';
bytearray[3] = '0';
QTest::newRow( "QByteArray2" ) << QVariant( bytearray ) << 4500 << true;
+ QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << 321 << true;
}
void tst_QVariant::toInt()
@@ -557,6 +564,7 @@ void tst_QVariant::toUInt_data()
bytearray[2] = '2';
bytearray[3] = '1';
QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (uint)4321 << true;
+ QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (uint)321 << true;
}
void tst_QVariant::toUInt()
@@ -742,6 +750,8 @@ void tst_QVariant::toBool_data()
QTest::newRow( "ulonglong1" ) << QVariant( (qulonglong)1 ) << true;
QTest::newRow( "QChar" ) << QVariant(QChar('a')) << true;
QTest::newRow( "Null_QChar" ) << QVariant(QChar(0)) << false;
+ QTest::newRow("QJsonValue(true)") << QVariant(QJsonValue(true)) << true;
+ QTest::newRow("QJsonValue(false)") << QVariant(QJsonValue(false)) << false;
}
void tst_QVariant::toBool()
@@ -805,6 +815,7 @@ void tst_QVariant::toDouble_data()
bytearray[2] = '.';
bytearray[3] = '1';
QTest::newRow( "bytearray" ) << QVariant( bytearray ) << 32.1 << true;
+ QTest::newRow("QJsonValue") << QVariant(QJsonValue(32.1)) << 32.1 << true;
}
void tst_QVariant::toDouble()
@@ -820,6 +831,34 @@ void tst_QVariant::toDouble()
QVERIFY( ok == valueOK );
}
+void tst_QVariant::toFloat_data()
+{
+ QTest::addColumn<QVariant>("value");
+ QTest::addColumn<float>("result");
+ QTest::addColumn<bool>("valueOK");
+
+ QByteArray bytearray(4, ' ');
+ bytearray[0] = '3';
+ bytearray[1] = '2';
+ bytearray[2] = '.';
+ bytearray[3] = '1';
+ QTest::newRow("QByteArray") << QVariant(bytearray) << float(32.1) << true;
+ QTest::newRow("QJsonValue") << QVariant(QJsonValue(32.1)) << float(32.1) << true;
+}
+
+void tst_QVariant::toFloat()
+{
+ QFETCH(QVariant, value );
+ QFETCH(float, result);
+ QFETCH(bool, valueOK);
+ QVERIFY(value.isValid());
+ QVERIFY(value.canConvert(QMetaType::Float));
+ bool ok;
+ float d = value.toFloat(&ok);
+ QCOMPARE(d, result);
+ QVERIFY(ok == valueOK);
+}
+
void tst_QVariant::toLongLong_data()
{
QTest::addColumn<QVariant>("value");
@@ -843,6 +882,7 @@ void tst_QVariant::toLongLong_data()
bytearray[2] = '0';
bytearray[3] = '0';
QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (qlonglong) 3200 << true;
+ QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (qlonglong)321 << true;
}
void tst_QVariant::toLongLong()
@@ -887,6 +927,7 @@ void tst_QVariant::toULongLong_data()
bytearray[2] = '0';
bytearray[3] = '1';
QTest::newRow( "QByteArray" ) << QVariant( bytearray ) << (qulonglong) 3201 << true;
+ QTest::newRow("QJsonValue") << QVariant(QJsonValue(321)) << (qulonglong)321 << true;
}
void tst_QVariant::toULongLong()
@@ -953,6 +994,7 @@ void tst_QVariant::toString_data()
QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" );
QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) <<
QString( "123456789012" );
+ QTest::newRow("QJsonValue") << QVariant(QJsonValue(QString("hello"))) << QString("hello");
}
void tst_QVariant::toString()
diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp
index 28ec699427..3fc89acb67 100644
--- a/tests/auto/opengl/qgl/tst_qgl.cpp
+++ b/tests/auto/opengl/qgl/tst_qgl.cpp
@@ -1309,14 +1309,17 @@ void tst_QGL::glWidgetReparent()
{
// Try it as a top-level first:
GLWidget *widget = new GLWidget;
+ widget->setObjectName(QStringLiteral("glWidget1"));
widget->setGeometry(0, 0, 200, 30);
widget->show();
QWidget grandParentWidget;
+ grandParentWidget.setObjectName(QStringLiteral("grandParentWidget"));
grandParentWidget.setPalette(Qt::blue);
QVBoxLayout grandParentLayout(&grandParentWidget);
QWidget parentWidget(&grandParentWidget);
+ parentWidget.setObjectName(QStringLiteral("parentWidget"));
grandParentLayout.addWidget(&parentWidget);
parentWidget.setPalette(Qt::green);
parentWidget.setAutoFillBackground(true);
@@ -1348,6 +1351,7 @@ void tst_QGL::glWidgetReparent()
// Now do pretty much the same thing, but don't show the
// widget first:
widget = new GLWidget;
+ widget->setObjectName(QStringLiteral("glWidget2"));
parentLayout.addWidget(widget);
QVERIFY(QTest::qWaitForWindowExposed(&grandParentWidget));
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index 6ab7cb4491..a4ad18c7a6 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -347,7 +347,9 @@ void tst_QDockWidget::features()
void tst_QDockWidget::setFloating()
{
+ const QRect deskRect = QApplication::desktop()->availableGeometry();
QMainWindow mw;
+ mw.move(deskRect.left() + deskRect.width() * 2 / 3, deskRect.top() + deskRect.height() / 3);
QDockWidget dw;
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
@@ -355,10 +357,16 @@ void tst_QDockWidget::setFloating()
QVERIFY(QTest::qWaitForWindowExposed(&mw));
QVERIFY(!dw.isFloating());
+ const QPoint dockedPosition = dw.mapToGlobal(dw.pos());
QSignalSpy spy(&dw, SIGNAL(topLevelChanged(bool)));
dw.setFloating(true);
+ const QPoint floatingPosition = dw.pos();
+
+ // QTBUG-31044, show approximately at old position, give or take window frame.
+ QVERIFY((dockedPosition - floatingPosition).manhattanLength() < 50);
+
QVERIFY(dw.isFloating());
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());