From fb5790e1b1d4ddeac19a2996c806744509de4ac8 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 2 Apr 2009 19:09:52 +0200 Subject: Only set system style when it actually changes This issue would cause Qt Creator and similar apps with proxy styles to loose their custom styling whenever any x11 system settings changed. This happened because we would re-read the settings and override the system style even if the system style did not actually change would be set on the application. We Task-number: 250199 Reviewed-by: ogoffart --- src/gui/kernel/qapplication_x11.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 6babda9..260a9a4 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -887,11 +887,15 @@ bool QApplicationPrivate::x11_apply_settings() } } + static QString currentStyleName = stylename; if (QCoreApplication::startingUp()) { if (!stylename.isEmpty() && !QApplicationPrivate::styleOverride) QApplicationPrivate::styleOverride = new QString(stylename); } else { - QApplication::setStyle(stylename); + if (currentStyleName != stylename) { + currentStyleName = stylename; + QApplication::setStyle(stylename); + } } int num = -- cgit v0.12 From b2b11265d9cf20706eadca61c37d931886eb35cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 2 Apr 2009 17:17:16 +0200 Subject: Adding auto-tests for commits a2fcc4a5 and 8d500381 Task-number: 244500 Task-number: 244485 Reviewed-by: ossi Reviewed-by: thiago --- tests/auto/qfile/rename-fallback.qrc | 5 +++ tests/auto/qfile/test/test.pro | 2 +- tests/auto/qfile/tst_qfile.cpp | 46 ++++++++++++++++++++++++ tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 26 ++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qfile/rename-fallback.qrc diff --git a/tests/auto/qfile/rename-fallback.qrc b/tests/auto/qfile/rename-fallback.qrc new file mode 100644 index 0000000..c8a894a --- /dev/null +++ b/tests/auto/qfile/rename-fallback.qrc @@ -0,0 +1,5 @@ + + + rename-fallback.qrc + + diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro index 2293bd7..68f4c05 100644 --- a/tests/auto/qfile/test/test.pro +++ b/tests/auto/qfile/test/test.pro @@ -17,7 +17,7 @@ QT = core network DEFINES += SRCDIR=\\\"$$PWD/../\\\" } -RESOURCES += ../qfile.qrc +RESOURCES += ../qfile.qrc ../rename-fallback.qrc TARGET = ../tst_qfile diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 48902c7..829e0b3 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -169,6 +169,8 @@ private slots: void rename_data(); void rename(); void renameWithAtEndSpecialFile() const; + void renameFallback(); + void renameMultiple(); void appendAndRead(); void miscWithUncPathAsCurrentDir(); void standarderror(); @@ -214,6 +216,14 @@ void tst_QFile::cleanup() { // TODO: Add cleanup code here. // This will be executed immediately after each test is run. + + // for renameFallback() + QFile::remove("file-rename-destination.txt"); + + // for renameMultiple() + QFile::remove("file-to-be-renamed.txt"); + QFile::remove("file-renamed-once.txt"); + QFile::remove("file-renamed-twice.txt"); } void tst_QFile::initTestCase() @@ -2091,6 +2101,42 @@ void tst_QFile::renameWithAtEndSpecialFile() const QVERIFY(QFile::rename(newName, originalName)); } +void tst_QFile::renameFallback() +{ + // Using a resource file both to trigger QFile::rename's fallback handling + // and as a *read-only* source whose move should fail. + QFile file(":/rename-fallback.qrc"); + QVERIFY(file.exists() && "(test-precondition)"); + QFile::remove("file-rename-destination.txt"); + + QVERIFY(!file.rename("file-rename-destination.txt")); + QVERIFY(!QFile::exists("file-rename-destination.txt")); +} + +void tst_QFile::renameMultiple() +{ + // create the file if it doesn't exist + QFile file("file-to-be-renamed.txt"); + QVERIFY(file.open(QIODevice::ReadWrite) && "(test-precondition)"); + + // any stale files from previous test failures? + QFile::remove("file-renamed-once.txt"); + QFile::remove("file-renamed-twice.txt"); + + // begin testing + QVERIFY(file.rename("file-renamed-once.txt")); + QCOMPARE(file.fileName(), QString("file-renamed-once.txt")); + QVERIFY(file.rename("file-renamed-twice.txt")); + QCOMPARE(file.fileName(), QString("file-renamed-twice.txt")); + + QVERIFY(!QFile::exists("file-to-be-renamed.txt")); + QVERIFY(!QFile::exists("file-renamed-once.txt")); + QVERIFY(QFile::exists("file-renamed-twice.txt")); + + file.remove(); + QVERIFY(!QFile::exists("file-renamed-twice.txt")); +} + void tst_QFile::appendAndRead() { QFile writeFile(QLatin1String("appendfile.txt")); diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index d2a2546..9364af4 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -77,6 +77,7 @@ private slots: void resize(); void openOnRootDrives(); void stressTest(); + void rename(); public: }; @@ -335,5 +336,30 @@ void tst_QTemporaryFile::stressTest() } } +void tst_QTemporaryFile::rename() +{ + // This test checks that the temporary file is deleted, even after a + // rename. + + QDir dir; + QVERIFY(!dir.exists("temporary-file.txt")); + + QString tempname; + { + QTemporaryFile file(dir.filePath("temporary-file.XXXXXX")); + + QVERIFY(file.open()); + tempname = file.fileName(); + QVERIFY(dir.exists(tempname)); + + QVERIFY(file.rename("temporary-file.txt")); + QVERIFY(!dir.exists(tempname)); + QVERIFY(dir.exists("temporary-file.txt")); + } + + QVERIFY(!dir.exists(tempname)); + QVERIFY(!dir.exists("temporary-file.txt")); +} + QTEST_MAIN(tst_QTemporaryFile) #include "tst_qtemporaryfile.moc" -- cgit v0.12 From 87a711f1b32b737231c87a4b0cde986582ef8af5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 2 Apr 2009 20:17:33 +0200 Subject: some more quoting for qmake ... sometimes, even two reviews are not enough ... --- mkspecs/features/moc.prf | 2 +- mkspecs/features/uic.prf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index d3ad4b2..f1dcf37 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -63,7 +63,7 @@ INCREDIBUILD_XGE += moc_source #make sure we can include these files moc_dir_short = $$MOC_DIR win32:moc_dir_short ~= s,^.:,/, -contains(moc_dir_short, ^[/\\].*):INCLUDEPATH += $$MOC_DIR +contains(moc_dir_short, ^[/\\\\].*):INCLUDEPATH += $$MOC_DIR else:INCLUDEPATH += $$OUT_PWD/$$MOC_DIR #auto depend on moc diff --git a/mkspecs/features/uic.prf b/mkspecs/features/uic.prf index f03d623..c7b1686 100644 --- a/mkspecs/features/uic.prf +++ b/mkspecs/features/uic.prf @@ -36,7 +36,7 @@ isEmpty(QMAKE_MOD_UIC):QMAKE_MOD_UIC = ui_ ui_dir_short = $$UI_HEADERS_DIR win32:ui_dir_short ~= s,^.:,/, -contains(ui_dir_short, ^[/\\].*):INCLUDEPATH += $$UI_HEADERS_DIR +contains(ui_dir_short, ^[/\\\\].*):INCLUDEPATH += $$UI_HEADERS_DIR else:INCLUDEPATH += $$OUT_PWD/$$UI_HEADERS_DIR uic3 { -- cgit v0.12