From 7a3cac878f4f4a7c2cf3ea08557ee63d8c6a9330 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 19 Oct 2010 08:47:29 +0200 Subject: Fixed some tools definitions and properties in symbian profiles. This is needed for Symbian development on Windows using makefiles. RevBy: Trust me --- mkspecs/common/armcc.conf | 1 + mkspecs/common/symbian/symbian.conf | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mkspecs/common/armcc.conf b/mkspecs/common/armcc.conf index 2c765bc..4f178d7 100644 --- a/mkspecs/common/armcc.conf +++ b/mkspecs/common/armcc.conf @@ -37,5 +37,6 @@ QMAKE_LFLAGS_PLUGIN += $$QMAKE_LFLAGS_SHLIB QMAKE_LFLAGS_THREAD += QMAKE_AR = armar --create +QMAKE_LIB = armar --create QMAKE_RANLIB = diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 8c79d8b..ed14b32 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -114,11 +114,11 @@ contains(QMAKE_HOST.os,Windows) { } QMAKE_IDL = midl -QMAKE_LIB = ar -ru -QMAKE_RC = windres QMAKE_ZIP = zip -r -9 QMAKE_UNZIP = unzip -o +QMAKE_WRITE_DEFAULT_RC = 1 + QMAKE_TAR = tar -cf QMAKE_GZIP = gzip -9f -- cgit v0.12 From 5096e91a68f86d034289b1ec47a6c559c31580cb Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 12 Jan 2011 15:21:45 +0000 Subject: Fix for using search paths with a dirty path Opening "searchpath:/file" and other non clean paths was failing Reviewed-by: joao --- src/corelib/io/qfilesystemengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index d9d802e..799c109 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -168,7 +168,7 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator)); for (int i = 0; i < paths.count(); i++) { - entry = QFileSystemEntry(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1)); + entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1))); // Recurse! if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true)) return true; -- cgit v0.12 From d4479f37edd5d38455399d31799de57aa08e62e3 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 14 Jan 2011 10:30:39 +0200 Subject: No longer copy the executable file to phone by default The user needs to explicitly use -u or --upload to do that. Task-number: QTBUG-16625 Merge-request: 2548 Signed-off-by: axis --- tools/runonphone/main.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index 93b087b..618e401 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -62,6 +62,7 @@ void printUsage(QTextStream& outstream, QString exeName) << "-t, --timeout terminate test if timeout occurs" << endl << "-v, --verbose show debugging output" << endl << "-q, --quiet hide progress messages" << endl + << "-u, --upload upload executable file to phone" << endl << "-d, --download copy file from phone to PC after running test" << endl << "--nocrashlog Don't capture call stack if test crashes" << endl << "--crashlogpath Path to save crash logs (default=working dir)" << endl @@ -84,6 +85,7 @@ int main(int argc, char *argv[]) QStringList args = QCoreApplication::arguments(); QTextStream outstream(stdout); QTextStream errstream(stderr); + QString uploadLocalFile; QString downloadRemoteFile; QString downloadLocalFile; int loglevel=1; @@ -112,6 +114,18 @@ int main(int argc, char *argv[]) return 1; } } + else if (arg == "--upload" || arg == "-u") { + CHECK_PARAMETER_EXISTS + uploadLocalFile = it.next(); + if (!QFileInfo(uploadLocalFile).exists()) { + errstream << "Executable file (" << uploadLocalFile << ") doesn't exist" << endl; + return 1; + } + if (!(QFileInfo(uploadLocalFile).suffix() == "exe")) { + errstream << "File (" << uploadLocalFile << ") must be an executable" << endl; + return 1; + } + } else if (arg == "--download" || arg == "-d") { CHECK_PARAMETER_EXISTS downloadRemoteFile = it.next(); @@ -147,12 +161,18 @@ int main(int argc, char *argv[]) } } - if (exeFile.isEmpty() && sisFile.isEmpty() && + if (exeFile.isEmpty() && sisFile.isEmpty() && uploadLocalFile.isEmpty() && (downloadLocalFile.isEmpty() || downloadRemoteFile.isEmpty())) { printUsage(outstream, args[0]); return 1; } + if (!uploadLocalFile.isEmpty() && (!downloadLocalFile.isEmpty() || !downloadRemoteFile.isEmpty())) { + errstream << "Upload option can't be used together with download" << endl; + printUsage(outstream, args[0]); + return 1; + } + if (serialPortName.isEmpty()) { if (loglevel > 0) outstream << "Detecting serial ports" << endl; @@ -182,19 +202,20 @@ int main(int argc, char *argv[]) QScopedPointer launcher; launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly)); - QFileInfo info(exeFile); + QFileInfo exeInfo(exeFile); + QFileInfo uploadInfo(uploadLocalFile); if (!sisFile.isEmpty()) { launcher->addStartupActions(trk::Launcher::ActionCopyInstall); launcher->setCopyFileName(sisFile, "c:\\data\\testtemp.sis"); launcher->setInstallFileName("c:\\data\\testtemp.sis"); } - else if (info.exists()) { + else if (!uploadLocalFile.isEmpty() && uploadInfo.exists()) { launcher->addStartupActions(trk::Launcher::ActionCopy); - launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + info.fileName()); + launcher->setCopyFileName(uploadLocalFile, QString("c:\\sys\\bin\\") + uploadInfo.fileName()); } if (!exeFile.isEmpty()) { launcher->addStartupActions(trk::Launcher::ActionRun); - launcher->setFileName(QString("c:\\sys\\bin\\") + info.fileName()); + launcher->setFileName(QString("c:\\sys\\bin\\") + exeInfo.fileName()); launcher->setCommandLineArgs(cmdLine); } if (!downloadRemoteFile.isEmpty() && !downloadLocalFile.isEmpty()) { -- cgit v0.12 From 003995384b06d3663c3a9c42a97c32f960a8e92f Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 14 Jan 2011 11:15:58 +0200 Subject: Help message clarification Merge-request: 2548 Signed-off-by: axis --- tools/runonphone/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index 618e401..e2346fa 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -56,7 +56,7 @@ void printUsage(QTextStream& outstream, QString exeName) { outstream << exeName << " [options] [program] [program arguments]" << endl - << "-s, --sis specify sis file to install" << endl + << "-s, --sis specify sis file to install" << endl << "-p, --portname specify COM port to use by device name" << endl << "-f, --portfriendlyname specify COM port to use by friendly name" << endl << "-t, --timeout terminate test if timeout occurs" << endl -- cgit v0.12 From 32f3fcd9ab19f66cb435e6a8830ce54ccf13885a Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 3 Jan 2011 11:54:35 +0100 Subject: Added Symbian implementation of keyboard language functions. More specifically, QApplication::keyboardInputLocale() and QApplication::keyboardInputDirection(). Task: QTBUG-15600 RevBy: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 9 +++++++++ src/gui/kernel/qkeymapper_p.h | 1 + src/gui/kernel/qkeymapper_s60.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 7f157a1..3df40d7 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1546,6 +1546,8 @@ void qt_init(QApplicationPrivate * /* priv */, int) repository = 0; #endif + qt_keymapper_private()->updateInputLanguage(); + #ifdef QT_KEYPAD_NAVIGATION if (touch) { QApplicationPrivate::navigationMode = Qt::NavigationModeNone; @@ -2086,6 +2088,13 @@ int QApplicationPrivate::symbianProcessWsEvent(const QSymbianEvent *symbianEvent } break; #endif + +#ifdef Q_WS_S60 + case KEikInputLanguageChange: + qt_keymapper_private()->updateInputLanguage(); + break; +#endif + default: break; } diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h index 38f141e..98d8eec 100644 --- a/src/gui/kernel/qkeymapper_p.h +++ b/src/gui/kernel/qkeymapper_p.h @@ -213,6 +213,7 @@ public: int mapS60ScanCodesToQt(TUint s60key); int mapQtToS60Key(int qtKey); int mapQtToS60ScanCodes(int qtKey); + void updateInputLanguage(); #endif }; diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/gui/kernel/qkeymapper_s60.cpp index d019c0f..c3a2c51 100644 --- a/src/gui/kernel/qkeymapper_s60.cpp +++ b/src/gui/kernel/qkeymapper_s60.cpp @@ -40,7 +40,11 @@ ****************************************************************************/ #include "private/qkeymapper_p.h" +#include #include +#include +#include +#include QT_BEGIN_NAMESPACE @@ -214,4 +218,32 @@ int QKeyMapperPrivate::mapQtToS60ScanCodes(int qtKey) } return res; } + +void QKeyMapperPrivate::updateInputLanguage() +{ +#ifdef Q_WS_S60 + TInt err; + CRepository *repo; + const TUid KCRUidAknFep = TUid::Uid(0x101F876D); + const TUint32 KAknFepInputTxtLang = 0x00000005; + TRAP(err, repo = CRepository::NewL(KCRUidAknFep)); + if (err != KErrNone) + return; + + TInt symbianLang; + err = repo->Get(KAknFepInputTxtLang, symbianLang); + delete repo; + if (err != KErrNone) + return; + + QString qtLang = QString::fromAscii(qt_symbianLocaleName(symbianLang)); + keyboardInputLocale = QLocale(qtLang); + keyboardInputDirection = (TBidiText::ScriptDirectionality(TLanguage(symbianLang)) == TBidiText::ERightToLeft) + ? Qt::RightToLeft : Qt::LeftToRight; +#else + keyboardInputLocale = QLocale(); + keyboardInputDirection = Qt::LeftToRight; +#endif +} + QT_END_NAMESPACE -- cgit v0.12 From a13e97b42c89159667f2d89c7eda2dbfdf1465e8 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 17 Jan 2011 13:31:44 +0100 Subject: Add packagesExist() function to qmake. This can be used to detect whether or not a given (set of) packages exist, which can be useful for compiling in or our extra functionality at build time. Merge-request: 1022 Reviewed-by: Oswald Buddenhagen --- doc/src/development/qmake-manual.qdoc | 13 +++++++++++++ doc/src/snippets/code/doc_src_qmake-manual.qdoc | 12 ++++++++++++ mkspecs/features/link_pkgconfig.prf | 3 ++- mkspecs/features/qt_functions.prf | 14 ++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index d7a48a3..b6270d5 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -3397,6 +3397,19 @@ \tableofcontents{2} + \section1 packagesExist(packages) + + Uses the PKGCONFIG mechanism to determine whether or not the given packages + exist at the time of project parsing. + + This can be useful to optionally enable or disable features. For example: + + \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 157 + + And then, in the code: + + \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 158 + \section1 basename(variablename) Returns the basename of the file specified. For example: diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc index ab67a3d..ec35a52 100644 --- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc +++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc @@ -1029,3 +1029,15 @@ DEPLOYMENT += dep_note //! [156] DEPLOYMENT.display_name = My Qt App //! [156] + +//! [157] +packagesExist(sqlite3 QtNetwork QtDeclarative) { + DEFINES += USE_FANCY_UI +} +//! [157] + +//! [158] +#ifdef USE_FANCY_UI + // Use the fancy UI, as we have extra packages available +#endif +//! [158] diff --git a/mkspecs/features/link_pkgconfig.prf b/mkspecs/features/link_pkgconfig.prf index d70e5de..b1b00e43 100644 --- a/mkspecs/features/link_pkgconfig.prf +++ b/mkspecs/features/link_pkgconfig.prf @@ -1,5 +1,6 @@ # handle pkg-config files -isEmpty(PKG_CONFIG):PKG_CONFIG = pkg-config +isEmpty(PKG_CONFIG):PKG_CONFIG = pkg-config # keep consistent with qt_functions.prf too! + for(PKGCONFIG_LIB, $$list($$unique(PKGCONFIG))) { QMAKE_CXXFLAGS += $$system($$PKG_CONFIG --cflags $$PKGCONFIG_LIB) QMAKE_CFLAGS += $$system($$PKG_CONFIG --cflags $$PKGCONFIG_LIB) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 964e13b..f1c3e13 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -103,3 +103,17 @@ defineTest(qtPrepareTool) { } export($$1) } + +defineTest(packagesExist) { + # this can't be done in global scope here because qt_functions is loaded + # before the .pro is parsed, so if the .pro set PKG_CONFIG, we wouldn't know it + # yet. oops. + isEmpty(PKG_CONFIG):PKG_CONFIG = pkg-config # keep consistent with link_pkgconfig.prf! too + + for(package, ARGS) { + !system($$PKG_CONFIG --exists $$package):return(false) + } + + return(true) +} + -- cgit v0.12 From 145c6bdef2680ca0da07f8f0cf09419edf9ecd52 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 17 Jan 2011 13:31:45 +0100 Subject: Use packagesExist() macro to bail if a nonexistant package is requested. This will solve problematic cases with large projects, lots of required packages, and no configure scripts failing to build partway through. Previously, PKGCONFIG processing would error to stdout, but continue the compilation. This should not affect existing code overly much, apart from projects who added nonexistent packages they didn't use to PKGCONFIG (but let's face it, that's a bit of a stupid thing to do.) Task-number: QTBUG-11418 Merge-request: 1022 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/link_pkgconfig.prf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkspecs/features/link_pkgconfig.prf b/mkspecs/features/link_pkgconfig.prf index b1b00e43..a3dbd1f 100644 --- a/mkspecs/features/link_pkgconfig.prf +++ b/mkspecs/features/link_pkgconfig.prf @@ -2,7 +2,11 @@ isEmpty(PKG_CONFIG):PKG_CONFIG = pkg-config # keep consistent with qt_functions.prf too! for(PKGCONFIG_LIB, $$list($$unique(PKGCONFIG))) { + # don't proceed if the .pro asks for a package we don't have! + !packagesExist($$PKGCONFIG_LIB):error("Package $$PKGCONFIG_LIB not found") + QMAKE_CXXFLAGS += $$system($$PKG_CONFIG --cflags $$PKGCONFIG_LIB) QMAKE_CFLAGS += $$system($$PKG_CONFIG --cflags $$PKGCONFIG_LIB) LIBS += $$system($$PKG_CONFIG --libs $$PKGCONFIG_LIB) } + -- cgit v0.12 From 4a7a6d19fa557a7220dfd1a1387e0958182505f2 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 17 Jan 2011 13:31:46 +0100 Subject: Improve documentation for PWD variable. - Note that it can be used in shadow build circumstances. - Note that IN_PWD is an alias for PWD. - See also: _PRO_FILE_ Merge-request: 1022 Reviewed-by: Oswald Buddenhagen --- doc/src/development/qmake-manual.qdoc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index b6270d5..f5ac12d 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -1900,8 +1900,17 @@ \target PWD \section1 PWD - This variable contains the full path leading to the directory where - the \c qmake project file (project.pro) is located. + The \c PWD variable specifies the full path leading to the directory + containing the current file being parsed. This can be useful + to refer to files within the source tree when writing project files to + support shadow builds. + + See also \l{#_PRO_FILE_PWD_}{_PRO_FILE_PWD_}. + + \note IN_PWD is an alias for PWD. + + \note Function calls have no effect on the value of PWD. PWD will refer to + the path of the calling file. \target OUT_PWD \section1 OUT_PWD -- cgit v0.12 From 44d0d663d4972b2d8a0248e4ea3222a46942ff0e Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 6 Jan 2011 13:39:14 +1000 Subject: network tests: make IMAP, FTP testdata more flexible. Move all hardcoded IMAP/FTP fixtures into network-settings.h. Make it work with new and old network test server. Reviewed-by: Markus Goetz Task: QTBUG-15114 --- tests/auto/network-settings.h | 79 ++++++++++++++++---- .../qhttpsocketengine/tst_qhttpsocketengine.cpp | 10 +-- .../tst_qnativesocketengine.cpp | 2 +- .../tst_qsocks5socketengine.cpp | 12 +-- tests/auto/qsslsocket/tst_qsslsocket.cpp | 3 +- tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 87 ++++++++++++++++------ 6 files changed, 142 insertions(+), 51 deletions(-) diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 6730946..0cb8e3a 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -64,6 +64,7 @@ //#define SYMBIAN_WINSOCK_CONNECTIVITY #endif // Q_CC_NOKIAX86 +// FIXME: any reason we do this for symbian only, and not other platforms? class QtNetworkSettingsRecord { public: QtNetworkSettingsRecord() { } @@ -128,7 +129,6 @@ public: static QString wildcardServerName() { return "qt-test-server.wildcard.dev." + serverDomainName(); - //return "qttest.wildcard.dev." + serverDomainName(); } #ifdef QT_NETWORK_LIB @@ -149,8 +149,10 @@ public: } #endif - static QByteArray expectedReplyIMAP() + static bool compareReplyIMAP(QByteArray const& actual) { + QList expected; + #ifdef Q_OS_SYMBIAN loadTestSettings(); @@ -160,17 +162,35 @@ public: imapExpectedReply = entry->recordValue().toAscii(); imapExpectedReply.append('\r').append('\n'); } - return imapExpectedReply.data(); + expected << imapExpectedReply.data(); } #endif - QByteArray expected( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " ); - expected = expected.append(QtNetworkSettings::serverName().toAscii()); - expected = expected.append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); - return expected; + + // Mandriva; old test server + expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " ) + .append(QtNetworkSettings::serverName().toAscii()) + .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + + // Ubuntu 10.04; new test server + expected << QByteArray( "* OK " ) + .append(QtNetworkSettings::serverLocalName().toAscii()) + .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"); + + // Feel free to add more as needed + + Q_FOREACH (QByteArray const& ba, expected) { + if (ba == actual) { + return true; + } + } + + return false; } - static QByteArray expectedReplySSL() + static bool compareReplyIMAPSSL(QByteArray const& actual) { + QList expected; + #ifdef Q_OS_SYMBIAN loadTestSettings(); @@ -180,19 +200,46 @@ public: imapExpectedReplySsl = entry->recordValue().toAscii(); imapExpectedReplySsl.append('\r').append('\n'); } - return imapExpectedReplySsl.data(); + expected << imapExpectedReplySsl.data(); } #endif - QByteArray expected( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " ); - expected = expected.append(QtNetworkSettings::serverName().toAscii()); - expected = expected.append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); - return expected; + // Mandriva; old test server + expected << QByteArray( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " ) + .append(QtNetworkSettings::serverName().toAscii()) + .append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + + // Ubuntu 10.04; new test server + expected << QByteArray( "* OK " ) + .append(QtNetworkSettings::serverLocalName().toAscii()) + .append(" Cyrus IMAP4 v2.2.13-Debian-2.2.13-19 server ready\r\n"); + + // Feel free to add more as needed + + Q_FOREACH (QByteArray const& ba, expected) { + if (ba == actual) { + return true; + } + } + + return false; } - static QByteArray expectedReplyFtp() + static bool compareReplyFtp(QByteArray const& actual) { - QByteArray expected( "220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n" ); - return expected; + QList expected; + + // A few different vsFTPd versions. + // Feel free to add more as needed + expected << QByteArray( "220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n" ); + expected << QByteArray( "220 (vsFTPd 2.2.2)\r\n221 Goodbye.\r\n" ); + + Q_FOREACH (QByteArray const& ba, expected) { + if (ba == actual) { + return true; + } + } + + return false; } #ifdef Q_OS_SYMBIAN diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp index f86ba63..972185b 100644 --- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -325,7 +325,7 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message @@ -455,7 +455,7 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest() // Read greeting QVERIFY(socket.waitForReadyRead(5000)); QString s = socket.readLine(); - QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), qPrintable(s)); // Write NOOP QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8); @@ -530,8 +530,8 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest() // Read greeting QVERIFY(!tcpSocketNonBlocking_data.isEmpty()); - QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(), - QtNetworkSettings::expectedReplyIMAP().constData()); + QByteArray data = tcpSocketNonBlocking_data.at(0).toLatin1(); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(data), data.constData()); tcpSocketNonBlocking_data.clear(); @@ -713,7 +713,7 @@ void tst_QHttpSocketEngine::passwordAuth() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message diff --git a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp index 2b0b632..782c2f0 100644 --- a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp +++ b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp @@ -173,7 +173,7 @@ void tst_QNativeSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message QByteArray array2 = "ZZZ LOGOUT\r\n"; diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp index 8f0cbc3..9da7197 100644 --- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -336,7 +336,7 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; @@ -596,7 +596,7 @@ void tst_QSocks5SocketEngine::tcpSocketBlockingTest() // Read greeting QVERIFY(socket.waitForReadyRead(5000)); QString s = socket.readLine(); - QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), s.toLatin1().constData()); // Write NOOP QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8); @@ -671,8 +671,8 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() // Read greeting QVERIFY(!tcpSocketNonBlocking_data.isEmpty()); - QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(), - QtNetworkSettings::expectedReplyIMAP().constData()); + QByteArray data = tcpSocketNonBlocking_data.at(0).toLatin1(); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(data), data.constData()); tcpSocketNonBlocking_data.clear(); @@ -859,7 +859,7 @@ void tst_QSocks5SocketEngine::passwordAuth() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; @@ -927,7 +927,7 @@ void tst_QSocks5SocketEngine::passwordAuth2() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(array), array.constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index d6a7a01..3223006 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -502,8 +502,9 @@ void tst_QSslSocket::simpleConnectWithIgnore() if (!socket.canReadLine()) enterLoop(10); - QCOMPARE(socket.readAll(), QtNetworkSettings::expectedReplySSL()); + QByteArray data = socket.readAll(); socket.disconnectFromHost(); + QVERIFY2(QtNetworkSettings::compareReplyIMAPSSL(data), data.constData()); } void tst_QSslSocket::sslErrors_data() diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 2dbe5b7..86069cd 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -95,6 +95,7 @@ #include "private/qhostinfo_p.h" #include "../network-settings.h" +#include "../../shared/util.h" Q_DECLARE_METATYPE(QAbstractSocket::SocketError) Q_DECLARE_METATYPE(QAbstractSocket::SocketState) @@ -222,6 +223,8 @@ protected slots: void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth); private: + QByteArray expectedReplyIMAP(); + void fetchExpectedReplyIMAP(); QTcpSocket *newSocket() const; QTcpSocket *nonBlockingIMAP_socket; QStringList nonBlockingIMAP_data; @@ -233,6 +236,8 @@ private: bool readingBody; QTime timer; + QByteArray expectedReplyIMAP_cached; + mutable int proxyAuthCalled; bool gotClosedSignal; @@ -658,8 +663,6 @@ void tst_QTcpSocket::nonBlockingIMAP() // Read greeting QVERIFY(!nonBlockingIMAP_data.isEmpty()); -// QCOMPARE(nonBlockingIMAP_data.at(0).toLatin1().constData(), -// "* OK fluke Cyrus IMAP4 v2.2.12 server ready\r\n"); QCOMPARE(nonBlockingIMAP_data.at(0).left(4).toLatin1().constData(), "* OK"); nonBlockingIMAP_data.clear(); @@ -787,6 +790,36 @@ void tst_QTcpSocket::delayedClose() delete socket; } + +//---------------------------------------------------------------------------------- + +QByteArray tst_QTcpSocket::expectedReplyIMAP() +{ + if (expectedReplyIMAP_cached.isEmpty()) { + fetchExpectedReplyIMAP(); + } + + return expectedReplyIMAP_cached; +} + +// Figure out how the current IMAP server responds +void tst_QTcpSocket::fetchExpectedReplyIMAP() +{ + QTcpSocket *socket = newSocket(); + socket->connectToHost(QtNetworkSettings::serverName(), 143); + QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); + QVERIFY2(socket->state() == QTcpSocket::ConnectedState, qPrintable(socket->errorString())); + + QTRY_VERIFY(socket->canReadLine()); + + QByteArray greeting = socket->readLine(); + delete socket; + + QVERIFY2(QtNetworkSettings::compareReplyIMAP(greeting), greeting.constData()); + + expectedReplyIMAP_cached = greeting; +} + //---------------------------------------------------------------------------------- void tst_QTcpSocket::partialRead() @@ -797,8 +830,8 @@ void tst_QTcpSocket::partialRead() QVERIFY(socket->state() == QTcpSocket::ConnectedState); char buf[512]; -// QByteArray greeting = "* OK fluke Cyrus IMAP4 v2.2.12 server ready"; - QByteArray greeting = "* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE"; + QByteArray greeting = expectedReplyIMAP(); + QVERIFY(!greeting.isEmpty()); for (int i = 0; i < 10; i += 2) { while (socket->bytesAvailable() < 2) @@ -821,8 +854,8 @@ void tst_QTcpSocket::unget() QVERIFY(socket->state() == QTcpSocket::ConnectedState); char buf[512]; -// QByteArray greeting = "* OK fluke Cyrus IMAP4 v2.2.12 server ready"; - QByteArray greeting = "* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE"; + QByteArray greeting = expectedReplyIMAP(); + QVERIFY(!greeting.isEmpty()); for (int i = 0; i < 10; i += 2) { while (socket->bytesAvailable() < 2) @@ -1244,13 +1277,17 @@ void tst_QTcpSocket::readLine() QVERIFY(socket->waitForReadyRead(10000)); char buffer[1024]; - int expectedReplySize = QtNetworkSettings::expectedReplyIMAP().size(); - Q_ASSERT(expectedReplySize >= 3); - QCOMPARE(socket->readLine(buffer, sizeof(buffer)), qint64(expectedReplySize)); - QCOMPARE((int) buffer[expectedReplySize-2], (int) '\r'); - QCOMPARE((int) buffer[expectedReplySize-1], (int) '\n'); - QCOMPARE((int) buffer[expectedReplySize], (int) '\0'); + qint64 linelen = socket->readLine(buffer, sizeof(buffer)); + QVERIFY(linelen >= 3); + QVERIFY(linelen < 1024); + + QByteArray reply = QByteArray::fromRawData(buffer, linelen); + QCOMPARE((int) buffer[linelen-2], (int) '\r'); + QCOMPARE((int) buffer[linelen-1], (int) '\n'); + QCOMPARE((int) buffer[linelen], (int) '\0'); + + QVERIFY2(QtNetworkSettings::compareReplyIMAP(reply), reply.constData()); QCOMPARE(socket->write("1 NOOP\r\n"), qint64(8)); @@ -1282,13 +1319,11 @@ void tst_QTcpSocket::readLine() void tst_QTcpSocket::readLineString() { QTcpSocket *socket = newSocket(); -// QByteArray expected("* OK fluke Cyrus IMAP4 v2.2.12 server ready\r\n"); - QByteArray expected("* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); socket->connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket->waitForReadyRead(10000)); QByteArray arr = socket->readLine(); - QCOMPARE(arr, QtNetworkSettings::expectedReplyIMAP()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(arr), arr.constData()); delete socket; } @@ -1456,8 +1491,11 @@ void tst_QTcpSocket::atEnd() QVERIFY(!stream.atEnd()); QString greeting = stream.readLine(); QVERIFY(stream.atEnd()); -// QCOMPARE(greeting, QString("220 (vsFTPd 2.0.4)")); - QCOMPARE(greeting, QString("220 (vsFTPd 2.0.5)")); + + // Test server must use some vsFTPd 2.x.x version + QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting)); + QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting)); + QVERIFY2(greeting.endsWith(")"), qPrintable(greeting)); delete socket; } @@ -1522,7 +1560,8 @@ void tst_QTcpSocket::socketInAThread() TestThread thread; thread.start(); QVERIFY(thread.wait(15000)); - QCOMPARE(thread.data(), QtNetworkSettings::expectedReplyFtp()); + QByteArray data = thread.data(); + QVERIFY2(QtNetworkSettings::compareReplyFtp(data), data.constData()); } } @@ -1542,9 +1581,13 @@ void tst_QTcpSocket::socketsInThreads() QVERIFY(thread3.wait(15000)); QVERIFY(thread1.wait(15000)); - QCOMPARE(thread1.data(),QtNetworkSettings::expectedReplyFtp()); - QCOMPARE(thread2.data(),QtNetworkSettings::expectedReplyFtp()); - QCOMPARE(thread3.data(),QtNetworkSettings::expectedReplyFtp()); + QByteArray data1 = thread1.data(); + QByteArray data2 = thread2.data(); + QByteArray data3 = thread3.data(); + + QVERIFY2(QtNetworkSettings::compareReplyFtp(data1), data1.constData()); + QVERIFY2(QtNetworkSettings::compareReplyFtp(data2), data2.constData()); + QVERIFY2(QtNetworkSettings::compareReplyFtp(data3), data3.constData()); } } @@ -1846,7 +1889,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead() QCOMPARE(readyReadSpy.count(), 1); QString s = socket->readLine(); - QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), s.toLatin1().constData()); QCOMPARE(socket->bytesAvailable(), qint64(0)); QCoreApplication::instance()->processEvents(); -- cgit v0.12 From f65b7aa11d18ab710bc2e6720d7a6dbc8f169c65 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 17 Jan 2011 13:35:58 +0000 Subject: Add QScopedValueRollback tools class. This template allows a value to be automatically rolled back to a previous state when the class goes out of scope. This can be used to maintain a valid state when an exception is thrown. Reviewed-by: mread Reviewed-by: joao --- src/corelib/tools/qscopedvaluerollback.cpp | 84 ++++++++++++++++++++++++++++++ src/corelib/tools/qscopedvaluerollback.h | 81 ++++++++++++++++++++++++++++ src/corelib/tools/tools.pri | 7 +-- 3 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 src/corelib/tools/qscopedvaluerollback.cpp create mode 100644 src/corelib/tools/qscopedvaluerollback.h diff --git a/src/corelib/tools/qscopedvaluerollback.cpp b/src/corelib/tools/qscopedvaluerollback.cpp new file mode 100644 index 0000000..8933efc --- /dev/null +++ b/src/corelib/tools/qscopedvaluerollback.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qscopedvaluerollback.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QScopedValueRollback + \brief The QScopedValueRollback resets a variable to its previous value on destruction + \since 4.8 + \ingroup misc + + The QScopedAssignment class can be used to revert state when an + exception is thrown without needing to write try-catch blocks. + + It can also be used to manage variables that are temporarily set, + such as reentrancy guards. By using this class, the variable will + be reset whether the function is exited normally, exited early by + a return statement, or exited by an exception. + + The template can only be instantiated with a type that supports assignment. + + \sa QScopedPointer +*/ + +/*! + \fn QScopedValueRollback::QScopedValueRollback(T &var) + + Stores the previous value of var internally, for revert on destruction. +*/ + +/*! + \fn QScopedValueRollback::~QScopedValueRollback() + + Assigns the previous value to the managed variable. + This is the value at construction time, or at the last call to commit() +*/ + +/*! + \fn void QScopedValueRollback::commit() + + Updates the previous value of the managed variable to its current value. +*/ + +QT_END_NAMESPACE diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h new file mode 100644 index 0000000..d344ed8 --- /dev/null +++ b/src/corelib/tools/qscopedvaluerollback.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSCOPEDVALUEROLLBACK_H +#define QSCOPEDVALUEROLLBACK_H + +#include + +QT_BEGIN_HEADER +QT_BEGIN_NAMESPACE +QT_MODULE(Core) + +template +class QScopedValueRollback +{ +public: + QScopedValueRollback(T &var) : + varRef(var) + { + oldValue = varRef; + } + + ~QScopedValueRollback() + { + varRef = oldValue; + } + + void commit() + { + oldValue = varRef; + } + +private: + T& varRef; + T oldValue; + + Q_DISABLE_COPY(QScopedValueRollback); +}; + +QT_END_NAMESPACE +QT_END_HEADER + +#endif // QSCOPEDVALUEROLLBACK_H diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 03bb32d..9d564a1 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -29,6 +29,9 @@ HEADERS += \ tools/qrect.h \ tools/qregexp.h \ tools/qringbuffer_p.h \ + tools/qscopedpointer.h \ + tools/qscopedpointer_p.h \ + tools/qscopedvaluerollback.h \ tools/qshareddata.h \ tools/qsharedpointer.h \ tools/qsharedpointer_impl.h \ @@ -45,9 +48,7 @@ HEADERS += \ tools/qelapsedtimer.h \ tools/qunicodetables_p.h \ tools/qvarlengtharray.h \ - tools/qvector.h \ - tools/qscopedpointer.h \ - tools/qscopedpointer_p.h + tools/qvector.h SOURCES += \ -- cgit v0.12 From 7a2442f3027d305a724fbf7b9248463241e32c2b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 17 Jan 2011 15:07:46 +0000 Subject: Add autotest for QScopedValueRollback Reviewed-by: mread --- .../qscopedvaluerollback/qscopedvaluerollback.pro | 4 + .../tst_qscopedvaluerollback.cpp | 203 +++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 tests/auto/qscopedvaluerollback/qscopedvaluerollback.pro create mode 100644 tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp diff --git a/tests/auto/qscopedvaluerollback/qscopedvaluerollback.pro b/tests/auto/qscopedvaluerollback/qscopedvaluerollback.pro new file mode 100644 index 0000000..f06e21b --- /dev/null +++ b/tests/auto/qscopedvaluerollback/qscopedvaluerollback.pro @@ -0,0 +1,4 @@ +load(qttest_p4) +SOURCES += tst_qscopedvaluerollback.cpp +QT -= gui +CONFIG += parallel_test diff --git a/tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp new file mode 100644 index 0000000..fac5702 --- /dev/null +++ b/tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +/*! + \class tst_QScopedValueRollback + \internal + \since 4.8 + \brief Tests class QScopedValueRollback. + + */ +class tst_QScopedValueRollback : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void leavingScope(); + void leavingScopeAfterCommit(); + void rollbackToPreviousCommit(); + void exceptions(); + void earlyExitScope(); +private: + void earlyExitScope_helper(int exitpoint, int &member); +}; + +void tst_QScopedValueRollback::leavingScope() +{ + int i = 0; + bool b = false; + QString s("This is useful"); + + //test rollback on going out of scope + { + QScopedValueRollback ri(i); + QScopedValueRollback rb(b); + QScopedValueRollback rs(s); + QCOMPARE(b, false); + QCOMPARE(i, 0); + QCOMPARE(s, QString("This is useful")); + b = true; + i = 1; + s = "Useless"; + QCOMPARE(b, true); + QCOMPARE(i, 1); + QCOMPARE(s, QString("Useless")); + } + QCOMPARE(b, false); + QCOMPARE(i, 0); + QCOMPARE(s, QString("This is useful")); +} + +void tst_QScopedValueRollback::leavingScopeAfterCommit() +{ + int i = 0; + bool b = false; + QString s("This is useful"); + + //test rollback on going out of scope + { + QScopedValueRollback ri(i); + QScopedValueRollback rb(b); + QScopedValueRollback rs(s); + QCOMPARE(b, false); + QCOMPARE(i, 0); + QCOMPARE(s, QString("This is useful")); + b = true; + i = 1; + s = "Useless"; + QCOMPARE(b, true); + QCOMPARE(i, 1); + QCOMPARE(s, QString("Useless")); + ri.commit(); + rb.commit(); + rs.commit(); + } + QCOMPARE(b, true); + QCOMPARE(i, 1); + QCOMPARE(s, QString("Useless")); +} + +void tst_QScopedValueRollback::rollbackToPreviousCommit() +{ + int i=0; + { + QScopedValueRollback ri(i); + i++; + ri.commit(); + i++; + } + QCOMPARE(i,1); + { + QScopedValueRollback ri1(i); + i++; + ri1.commit(); + i++; + ri1.commit(); + i++; + } + QCOMPARE(i,3); +} + +void tst_QScopedValueRollback::exceptions() +{ + bool b = false; + bool caught = false; + QT_TRY + { + QScopedValueRollback rb(b); + b = true; + QT_THROW(std::bad_alloc()); //if Qt compiled without exceptions this is noop + rb.commit(); //if Qt compiled without exceptions, true is committed + } + QT_CATCH(...) + { + caught = true; + } + QCOMPARE(b, !caught); //expect false if exception was thrown, true otherwise +} + +void tst_QScopedValueRollback::earlyExitScope() +{ + int i=0; + int j=0; + while (true) { + QScopedValueRollback ri(i); + i++; + j=i; + if (i>8) break; + ri.commit(); + } + QCOMPARE(i,8); + QCOMPARE(j,9); + + for (i = 0; i < 5; i++) { + j=1; + earlyExitScope_helper(i,j); + QCOMPARE(j, 1< r(member); + member *= 2; + if (exitpoint == 0) + return; + r.commit(); + member *= 2; + if (exitpoint == 1) + return; + r.commit(); + member *= 2; + if (exitpoint == 2) + return; + r.commit(); + member *= 2; + if (exitpoint == 3) + return; + r.commit(); +} + +QTEST_MAIN(tst_QScopedValueRollback) +#include "tst_QScopedValueRollback.moc" -- cgit v0.12 From f5a618d86395f35ced1b847581e48994e9196a32 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 20 Jan 2011 16:39:41 +0100 Subject: Made the translations dependency work for shadow builds. RevBy: Miikka Heikkinen --- mkspecs/common/symbian/symbian.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 8c79d8b..0eb1336 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -240,7 +240,7 @@ defineTest(matchSymbianLanguages) { language = $$replace(translation, "^(.*/)?[^/]+_(([^_]{2,3}_)?[^_]{2,3})\\.ts$", \\2) contains(SYMBIAN_SUPPORTED_LANGUAGES, $$language) { SYMBIAN_MATCHED_LANGUAGES += $$language - SYMBIAN_MATCHED_TRANSLATIONS += $$translation + SYMBIAN_MATCHED_TRANSLATIONS += $$_PRO_FILE_PWD_/$$translation } } -- cgit v0.12 From 8ee75222533fd5be30f9f21d609a9595519d5b94 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 20 Jan 2011 10:41:11 +0100 Subject: Added Symbian deployment localization for makefile build system. This is a complement to the 16575f7aef840b6aae0dc767468ab713fbcfd7a6 commit, which adds localization based on TRANSLATIONS keywords for Raptor and abld. In addition, since the __PRODUCT_INCLUDE__ define was creating a lot of trouble regarding < and >, it was refactored into its own source file, which is automatically included before every source file. Task: QTBUG-15292 RevBy: Miikka Heikkinen --- mkspecs/common/symbian/symbian-makefile.conf | 12 ++- mkspecs/common/symbian/symbianincludes.h | 17 ++++ mkspecs/features/symbian/symbian_building.prf | 124 +++++++++++++++++--------- mkspecs/symbian-armcc/qmake.conf | 5 +- qmake/generators/symbian/symbiancommon.cpp | 3 +- 5 files changed, 108 insertions(+), 53 deletions(-) create mode 100644 mkspecs/common/symbian/symbianincludes.h diff --git a/mkspecs/common/symbian/symbian-makefile.conf b/mkspecs/common/symbian/symbian-makefile.conf index 9dc3674..b899a2f 100644 --- a/mkspecs/common/symbian/symbian-makefile.conf +++ b/mkspecs/common/symbian/symbian-makefile.conf @@ -30,9 +30,15 @@ QMAKE_EXTENSION_STATICLIB = lib QMAKE_SYMBIAN_SHLIB = 1 is_using_gnupoc { - DEFINES *= __PRODUCT_INCLUDE__=\"<$${EPOCROOT}epoc32/include/variant/symbian_os.hrh>\" -} else { - DEFINES *= __PRODUCT_INCLUDE__=\"<$${EPOCROOT}epoc32/include/variant/Symbian_OS.hrh>\" + DEFINES *= __QT_PRODUCT_INCLUDE_IS_LOWERCASE__ +} +QMAKE_SYMBIAN_INCLUDES = $$[QT_INSTALL_DATA]/mkspecs/common/symbian/symbianincludes.h +symbian-armcc { + QMAKE_CFLAGS += --preinclude $$QMAKE_SYMBIAN_INCLUDES + QMAKE_CXXFLAGS += --preinclude $$QMAKE_SYMBIAN_INCLUDES +} else:symbian-gcce { + QMAKE_CFLAGS += -include $$QMAKE_SYMBIAN_INCLUDES + QMAKE_CXXFLAGS += -include $$QMAKE_SYMBIAN_INCLUDES } DEFINES *= \ __SYMBIAN32__ \ diff --git a/mkspecs/common/symbian/symbianincludes.h b/mkspecs/common/symbian/symbianincludes.h new file mode 100644 index 0000000..4c0ffa6 --- /dev/null +++ b/mkspecs/common/symbian/symbianincludes.h @@ -0,0 +1,17 @@ +#ifndef __PRODUCT_INCLUDE__ +# ifdef __QT_PRODUCT_INCLUDE_IS_LOWERCASE__ +# define __PRODUCT_INCLUDE__ +# else +# define __PRODUCT_INCLUDE__ +# endif +#endif + +#ifndef __QT_SYMBIAN_RESOURCE__ +# if defined(__ARMCC__) || defined(__CC_ARM) +# ifdef __QT_RVCT_HEADER_IS_2_2__ +# include +# else +# include +# endif +# endif +#endif diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index 9288583..8bb92be 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -242,6 +242,7 @@ symbian-armcc: { symbian_resources_INCLUDES = $$replace(symbian_resources_INCLUDES, ",", " -I") symbian_resources_INCLUDES += $$join(INCLUDEPATH, " -I", "-I") symbian_resources_DEFINES = $$join(DEFINES, " -D", "-D") +symbian_resources_DEFINES += -D__QT_SYMBIAN_RESOURCE__ symbian_resources_RCC_DIR = $$replace(RCC_DIR, "/$", "") symbian_resources_INCLUDES += "-I$$symbian_resources_RCC_DIR" @@ -256,6 +257,7 @@ for(symbian_resource, SYMBIAN_RESOURCES) { symbianresources.input = SYMBIAN_RESOURCES symbianresources.output = $$symbian_resources_RCC_DIR/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsg symbianresources.commands = cpp -nostdinc -undef \ + -include $$QMAKE_SYMBIAN_INCLUDES \ $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ ${QMAKE_FILE_NAME} \ @@ -271,46 +273,79 @@ symbianresources.CONFIG = no_link target_predeps QMAKE_EXTRA_COMPILERS += symbianresources +# This section generates the rsg and rsc files for symbian. contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") { - # Make our own extra target in order to get dependencies for generated - # files right. This also avoids the warning about files not found. - symbianGenResource.target = $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg - symbianGenResource.commands = cpp -nostdinc -undef \ - $$symbian_resources_INCLUDES \ - $$symbian_resources_DEFINES \ - $${baseTarget}.rss \ - > $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ - && rcomp -u -m045,046,047 \ - -s$${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ - -o$${symbianDestdir}/$${baseTarget}.rsc \ - -h$${symbian_resources_RCC_DIR}/$${baseTarget}.rsg \ - -i$${baseTarget}.rss - silent:symbianGenResource.commands = @echo rcomp $${baseTarget}.rss && $$symbianGenResource.commands - symbianGenResource.depends = $${baseTarget}.rss - PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg - QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg - QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp - QMAKE_DISTCLEAN += $${baseTarget}.rss - QMAKE_DISTCLEAN += $${symbianDestdir}/$${baseTarget}.rsc - - symbianGenRegResource.target = $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg - symbianGenRegResource.commands = cpp -nostdinc -undef \ - $$symbian_resources_INCLUDES \ - $$symbian_resources_DEFINES \ - $${baseTarget}_reg.rss \ - > $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ - && rcomp -u -m045,046,047 \ - -s$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ - -o$${symbianDestdir}/$${baseTarget}_reg.rsc \ - -h$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg \ - -i$${baseTarget}_reg.rss - silent:symbianGenRegResource.commands = @echo rcomp $${baseTarget}_reg.rss && $$symbianGenRegResource.commands - symbianGenRegResource.depends = $${baseTarget}_reg.rss $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg - PRE_TARGETDEPS += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg - QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg - QMAKE_CLEAN += $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp - QMAKE_DISTCLEAN += $${baseTarget}_reg.rss - QMAKE_DISTCLEAN += $${symbianDestdir}/$${baseTarget}_reg.rsc + # Look for extra languages for the resources, and then generate a target for each one. + localize_deployment:symbianGenResourceLanguages = $$SYMBIAN_MATCHED_LANGUAGES default + else:symbianGenResourceLanguages = default + for(language, symbianGenResourceLanguages) { + # Special languages get their language number appended to the filename. + contains(language, default) { + symbianGenResource_DEFINES = $$symbian_resources_DEFINES + rpp = $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp + rsc = $${symbianDestdir}/$${baseTarget}.rsc + rsg = $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg + } else { + languageNo = $$eval(SYMBIAN_LANG.$$language) + symbianGenResource_DEFINES = $$symbian_resources_DEFINES -DLANGUAGE_$${languageNo} + rpp = $${symbian_resources_RCC_DIR}/$${baseTarget}_$${languageNo}.rpp + rsc = $${symbianDestdir}/$${baseTarget}.r$${languageNo} + rsg = $${symbian_resources_RCC_DIR}/$${baseTarget}_$${languageNo}.rsg + } + + # Make our own extra target in order to get dependencies for generated + # files right. This also avoids the warning about files not found. + eval(symbianGenResource_$${language}.target = $$rsg) + eval(symbianGenResource_$${language}.commands = cpp -nostdinc -undef \ + -include $$QMAKE_SYMBIAN_INCLUDES \ + $$symbian_resources_INCLUDES \ + $$symbianGenResource_DEFINES \ + $${baseTarget}.rss \ + > $$rpp \ + && rcomp -u -m045,046,047 \ + -s$$rpp \ + -o$$rsc \ + -h$$rsg \ + -i$${baseTarget}.rss) + silent:eval(symbianGenResource_$${language}.commands = @echo rcomp $${baseTarget}.rss && $$eval(symbianGenResource_$${language}.commands)) + eval(symbianGenResource_$${language}.depends = $${baseTarget}.rss) + PRE_TARGETDEPS += $$rsg + QMAKE_CLEAN += $$rsg $$rpp + QMAKE_DISTCLEAN += $$rsc + + QMAKE_EXTRA_TARGETS += symbianGenResource_$${language} + + # Note that we depend on the base rsg file, even if dealing with a specific language. + # hence we don't use $$rsg on the next line. + eval(symbianGenRegResource_$${language}.depends = $${baseTarget}_reg.rss $${symbian_resources_RCC_DIR}/$${baseTarget}.rsg) + contains(language, default) { + rpp = $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp + rsc = $${symbianDestdir}/$${baseTarget}_reg.rsc + rsg = $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rsg + } else { + rpp = $${symbian_resources_RCC_DIR}/$${baseTarget}_reg_$${languageNo}.rpp + rsc = $${symbianDestdir}/$${baseTarget}_reg.r$${languageNo} + rsg = $${symbian_resources_RCC_DIR}/$${baseTarget}_reg_$${languageNo}.rsg + } + eval(symbianGenRegResource_$${language}.target = $$rsg) + eval(symbianGenRegResource_$${language}.commands = cpp -nostdinc -undef \ + -include $$QMAKE_SYMBIAN_INCLUDES \ + $$symbian_resources_INCLUDES \ + $$symbianGenResource_DEFINES \ + $${baseTarget}_reg.rss \ + > $$rpp \ + && rcomp -u -m045,046,047 \ + -s$$rpp \ + -o$$rsc \ + -h$$rsg \ + -i$${baseTarget}_reg.rss) + silent:eval(symbianGenRegResource_$${language}.commands = @echo rcomp $${baseTarget}_reg.rss && $$eval(symbianGenRegResource_$${language}.commands)) + PRE_TARGETDEPS += $$rsg + QMAKE_CLEAN += $$rsg $$rpp + QMAKE_DISTCLEAN += $$rsc + + QMAKE_EXTRA_TARGETS += symbianGenRegResource_$${language} + } # Trick to get qmake to create the RCC_DIR for us. symbianRccDirCreation.input = SOURCES @@ -318,14 +353,15 @@ contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") { symbianRccDirCreation.output = $${symbian_resources_RCC_DIR}/symbian_resource_dummy symbianRccDirCreation.CONFIG = no_link combine - QMAKE_EXTRA_TARGETS += symbianGenResource symbianGenRegResource QMAKE_EXTRA_COMPILERS += symbianRccDirCreation - QMAKE_DISTCLEAN += $${baseTarget}.loc + QMAKE_DISTCLEAN += $${baseTarget}.rss \ + $${baseTarget}_reg.rss \ + $${baseTarget}.loc } # Generated pkg files -QMAKE_DISTCLEAN += $${baseTarget}_template.pkg -QMAKE_DISTCLEAN += $${baseTarget}_installer.pkg -QMAKE_DISTCLEAN += $${baseTarget}_stub.pkg +QMAKE_DISTCLEAN += $${baseTarget}_template.pkg \ + $${baseTarget}_installer.pkg \ + $${baseTarget}_stub.pkg diff --git a/mkspecs/symbian-armcc/qmake.conf b/mkspecs/symbian-armcc/qmake.conf index be6af39..77a1966 100644 --- a/mkspecs/symbian-armcc/qmake.conf +++ b/mkspecs/symbian-armcc/qmake.conf @@ -53,10 +53,7 @@ INCLUDEPATH = $${EPOCROOT}epoc32/include \ exists($${EPOCROOT}epoc32/include/rvct2_2) { INCLUDEPATH += $${EPOCROOT}epoc32/include/rvct2_2 - QMAKE_CFLAGS += --preinclude rvct2_2.h - QMAKE_CXXFLAGS += --preinclude rvct2_2.h + DEFINES *= __QT_RVCT_HEADER_IS_2_2__ } else { INCLUDEPATH += $${EPOCROOT}epoc32/include/rvct - QMAKE_CFLAGS += --preinclude rvct.h - QMAKE_CXXFLAGS += --preinclude rvct.h } diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index 8747f5a..4943a74 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -405,8 +405,7 @@ void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, t << manufacturerStr << endl; } - // ### FIXME: remove epocBuild check once makefile based mkspecs support localized resource generation - if (epocBuild && symbianLocalizationList.size()) { + if (symbianLocalizationList.size()) { // Add localized resources to DEPLOYMENT if default resource deployment is done addLocalizedResourcesToDeployment("default_resource_deployment.files", symbianLocalizationList); addLocalizedResourcesToDeployment("default_reg_deployment.files", symbianLocalizationList); -- cgit v0.12 From 31cd1c76b30bd5d71830fcadcebf255f08eb90c2 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 27 Jan 2011 14:57:59 +0000 Subject: add qscopedvaluerollback autotest to corelib.pro --- tests/auto/corelib.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/corelib.pro b/tests/auto/corelib.pro index 3451b53..6810f76 100644 --- a/tests/auto/corelib.pro +++ b/tests/auto/corelib.pro @@ -59,6 +59,7 @@ SUBDIRS=\ qresourceengine \ qringbuffer \ qscopedpointer \ + qscopedvaluerollback \ qsemaphore \ qsequentialanimationgroup \ qset \ -- cgit v0.12 From 769c65fa7e7ea3ef0989b126aa0a329f5c6679d7 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 27 Jan 2011 15:02:08 +0000 Subject: Fix GCC compiler warning --- src/corelib/tools/qscopedvaluerollback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h index d344ed8..e874428 100644 --- a/src/corelib/tools/qscopedvaluerollback.h +++ b/src/corelib/tools/qscopedvaluerollback.h @@ -72,7 +72,7 @@ private: T& varRef; T oldValue; - Q_DISABLE_COPY(QScopedValueRollback); + Q_DISABLE_COPY(QScopedValueRollback) }; QT_END_NAMESPACE -- cgit v0.12 From b65e84ab1c242116d8559aea99e46e44cefb0c1a Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 28 Jan 2011 09:13:01 +0100 Subject: Added missing header. --- mkspecs/common/symbian/symbianincludes.h | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mkspecs/common/symbian/symbianincludes.h b/mkspecs/common/symbian/symbianincludes.h index 4c0ffa6..5d7f488 100644 --- a/mkspecs/common/symbian/symbianincludes.h +++ b/mkspecs/common/symbian/symbianincludes.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the mkspecs of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef __PRODUCT_INCLUDE__ # ifdef __QT_PRODUCT_INCLUDE_IS_LOWERCASE__ # define __PRODUCT_INCLUDE__ -- cgit v0.12 From 5e3c4b6a82df640c15778af72384c6b27f8860b7 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 19 Jan 2011 16:19:51 +0100 Subject: Fix warning in sun compiler Warning, nullref: Initializing const myClass& to a NULL value. Patch inspired by the one in QTBUG-16755 Task-number: QTBUG-16755 --- src/corelib/kernel/qobject.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 63fdf76..bd3ef3c 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -370,18 +370,18 @@ template inline T qobject_cast(QObject *object) { #if !defined(QT_NO_QOBJECT_CHECK) - reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(object)); + reinterpret_cast(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast(object)); #endif - return static_cast(reinterpret_cast(0)->staticMetaObject.cast(object)); + return static_cast(reinterpret_cast(object)->staticMetaObject.cast(object)); } template inline T qobject_cast(const QObject *object) { #if !defined(QT_NO_QOBJECT_CHECK) - reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(const_cast(object))); + reinterpret_cast(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast(const_cast(object))); #endif - return static_cast(reinterpret_cast(0)->staticMetaObject.cast(object)); + return static_cast(reinterpret_cast(object)->staticMetaObject.cast(object)); } -- cgit v0.12 From e03d5125d0792348593251585b0970c138544743 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 19 Oct 2010 08:51:04 +0200 Subject: Added Symbian makefile building support using MinGW backend. RevBy: Oswald Buddenhagen --- mkspecs/common/symbian/symbian-makefile.conf | 6 +++++- qmake/generators/metamakefile.cpp | 4 +++- qmake/generators/win32/mingw_make.h | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mkspecs/common/symbian/symbian-makefile.conf b/mkspecs/common/symbian/symbian-makefile.conf index 9dc3674..c39222d 100644 --- a/mkspecs/common/symbian/symbian-makefile.conf +++ b/mkspecs/common/symbian/symbian-makefile.conf @@ -2,7 +2,11 @@ # qmake configuration for makefile based symbian # -MAKEFILE_GENERATOR = SYMBIAN_UNIX +contains(QMAKE_HOST.os,Windows) { + MAKEFILE_GENERATOR = SYMBIAN_MINGW +} else { + MAKEFILE_GENERATOR = SYMBIAN_UNIX +} include(symbian.conf) diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index df05550..be957d6 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -489,6 +489,8 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO) mkfile = new SymbianSbsv2MakefileGenerator; } else if(gen == "SYMBIAN_UNIX") { mkfile = new SymbianMakefileTemplate; + } else if(gen == "SYMBIAN_MINGW") { + mkfile = new SymbianMakefileTemplate; } else { fprintf(stderr, "Unknown generator specified: %s\n", gen.toLatin1().constData()); } @@ -545,7 +547,7 @@ MetaMakefileGenerator::modesForGenerator(const QString &gen, } else if (gen == "PROJECTBUILDER" || gen == "XCODE") { *host_mode = Option::HOST_MACX_MODE; *target_mode = Option::TARG_MACX_MODE; - } else if (gen == "SYMBIAN_ABLD" || gen == "SYMBIAN_SBSV2" || gen == "SYMBIAN_UNIX") { + } else if (gen == "SYMBIAN_ABLD" || gen == "SYMBIAN_SBSV2" || gen == "SYMBIAN_UNIX" || gen == "SYMBIAN_MINGW") { #if defined(Q_OS_MAC) *host_mode = Option::HOST_MACX_MODE; #elif defined(Q_OS_UNIX) diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h index 9f30333..564cd48 100644 --- a/qmake/generators/win32/mingw_make.h +++ b/qmake/generators/win32/mingw_make.h @@ -54,17 +54,17 @@ public: protected: QString escapeDependencyPath(const QString &path) const; QString getLibTarget(); + bool writeMakefile(QTextStream &); + void init(); private: bool isWindowsShell() const; void writeMingwParts(QTextStream &); void writeIncPart(QTextStream &t); void writeLibsPart(QTextStream &t); void writeLibDirPart(QTextStream &t); - bool writeMakefile(QTextStream &); void writeObjectsPart(QTextStream &t); void writeBuildRulesPart(QTextStream &t); void writeRcFilePart(QTextStream &t); - void init(); void processPrlVariable(const QString &var, const QStringList &l); QStringList &findDependencies(const QString &file); -- cgit v0.12 From 9ce88a4fb065b182ba6ad157ae4c1587da6bfc0a Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 19 Oct 2010 10:10:08 +0200 Subject: Added object script support to RVCT when using MinGW qmake generator. RevBy: Oswald Buddenhagen --- mkspecs/common/symbian/symbian-makefile.conf | 2 ++ qmake/generators/win32/mingw_make.cpp | 46 +++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/mkspecs/common/symbian/symbian-makefile.conf b/mkspecs/common/symbian/symbian-makefile.conf index c39222d..94a8dbf 100644 --- a/mkspecs/common/symbian/symbian-makefile.conf +++ b/mkspecs/common/symbian/symbian-makefile.conf @@ -33,6 +33,8 @@ QMAKE_PREFIX_STATICLIB = QMAKE_EXTENSION_STATICLIB = lib QMAKE_SYMBIAN_SHLIB = 1 +QMAKE_LINK_OBJECT_SCRIPT = objects + is_using_gnupoc { DEFINES *= __PRODUCT_INCLUDE__=\"<$${EPOCROOT}epoc32/include/variant/symbian_os.hrh>\" } else { diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 4717542..ca04e91 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -199,6 +199,23 @@ void createArObjectScriptFile(const QString &fileName, const QString &target, co } } +void createRvctObjectScriptFile(const QString &fileName, const QStringList &objList) +{ + QString filePath = Option::output_dir + QDir::separator() + fileName; + QFile file(filePath); + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QTextStream t(&file); + for (QStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) { + if (QDir::isRelativePath(*it)) + t << "./" << *it << endl; + else + t << *it << endl; + } + t.flush(); + file.close(); + } +} + void MingwMakefileGenerator::writeMingwParts(QTextStream &t) { writeStandardParts(t); @@ -367,20 +384,33 @@ void MingwMakefileGenerator::writeObjectsPart(QTextStream &t) if (!var("BUILD_NAME").isEmpty()) { ar_script_file += "." + var("BUILD_NAME"); } - createArObjectScriptFile(ar_script_file, var("DEST_TARGET"), project->values("OBJECTS")); // QMAKE_LIB is used for win32, including mingw, whereas QMAKE_AR is used on Unix. - // Strip off any options since the ar commands will be read from file. - QString ar_cmd = var("QMAKE_LIB").section(" ", 0, 0);; - if (ar_cmd.isEmpty()) - ar_cmd = "ar"; - objectsLinkLine = ar_cmd + " -M < " + ar_script_file; + if (project->isActiveConfig("rvct_linker")) { + createRvctObjectScriptFile(ar_script_file, project->values("OBJECTS")); + QString ar_cmd = project->values("QMAKE_LIB").join(" "); + if (ar_cmd.isEmpty()) + ar_cmd = "armar --create"; + objectsLinkLine = ar_cmd + " " + var("DEST_TARGET") + " --via " + ar_script_file; + } else { + // Strip off any options since the ar commands will be read from file. + QString ar_cmd = var("QMAKE_LIB").section(" ", 0, 0);; + if (ar_cmd.isEmpty()) + ar_cmd = "ar"; + createArObjectScriptFile(ar_script_file, var("DEST_TARGET"), project->values("OBJECTS")); + objectsLinkLine = ar_cmd + " -M < " + ar_script_file; + } } else { QString ld_script_file = var("QMAKE_LINK_OBJECT_SCRIPT") + "." + var("TARGET"); if (!var("BUILD_NAME").isEmpty()) { ld_script_file += "." + var("BUILD_NAME"); } - createLdObjectScriptFile(ld_script_file, project->values("OBJECTS")); - objectsLinkLine = ld_script_file; + if (project->isActiveConfig("rvct_linker")) { + createRvctObjectScriptFile(ld_script_file, project->values("OBJECTS")); + objectsLinkLine = QString::fromLatin1("--via ") + ld_script_file; + } else { + createLdObjectScriptFile(ld_script_file, project->values("OBJECTS")); + objectsLinkLine = ld_script_file; + } } Win32MakefileGenerator::writeObjectsPart(t); } -- cgit v0.12 From e3092695a2768643a335834cceb83e120ba94083 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 23 Dec 2010 16:24:06 +0100 Subject: Fixed include in network module on Symbian. --- src/network/kernel/qnetworkinterface_symbian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp index 7942461..2879ceb 100644 --- a/src/network/kernel/qnetworkinterface_symbian.cpp +++ b/src/network/kernel/qnetworkinterface_symbian.cpp @@ -43,7 +43,7 @@ #include "qnetworkinterface.h" #include "qnetworkinterface_p.h" -#include "../corelib/kernel/qcore_symbian_p.h" +#include #ifndef QT_NO_NETWORKINTERFACE -- cgit v0.12 From 37a57d9ac8cbdedbdb9d44d32a0ae68333cf1549 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 23 Dec 2010 16:24:57 +0100 Subject: Fixed a build library deployment issue in sqlite. Make did not understand that sqlite3.dso, which the link relies on, is the same as $$OBJECTS_DIR/sqlite3.dso, which is extracted by the profile. RevBy: Trust me --- src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri index ebeccc9..b7a87f3 100644 --- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri +++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pri @@ -34,6 +34,12 @@ silent:symbian_sqlite3_dso.commands = @echo unzipping $@ && $$symbian_sqlite3_dso.commands QMAKE_EXTRA_COMPILERS += symbian_sqlite3_dso + # Workaround for the fact that make doesn't understand that sqlite3.dso + # is the same as $OBJECTS_DIR/sqlite3.dso + symbian_sqlite3_dso_standalone.target = sqlite3.dso + symbian_sqlite3_dso_standalone.depends = $$symbian_sqlite3_dso.output + QMAKE_EXTRA_TARGETS += symbian_sqlite3_dso_standalone + symbian_sqlite3_ver_dso.input = symbian_sqlite3_zip_file symbian_sqlite3_ver_dso.output = sqlite3{00060003}.dso !isEmpty(OBJECTS_DIR):symbian_sqlite3_ver_dso.output = $$OBJECTS_DIR/$$symbian_sqlite3_ver_dso.output -- cgit v0.12 From e496dfecd119a94d7990c4860efe0d6171c1d829 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 11 Nov 2010 13:52:28 +0100 Subject: Fixed a typo in src profile. RevBy: Trust me --- src/src.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src.pro b/src/src.pro index c07d399..0bf3b52 100644 --- a/src/src.pro +++ b/src/src.pro @@ -109,7 +109,7 @@ src_webkit_declarative.target = sub-webkitdeclarative src_phonon.depends = src_gui src_multimedia.depends = src_gui contains(QT_CONFIG, opengl):src_multimedia.depends += src_opengl - src_tools_activeqt.depends = src_tools_idc src_gui + src_activeqt.depends = src_tools_idc src_gui src_declarative.depends = src_gui src_script src_network src_plugins.depends = src_gui src_sql src_svg contains(QT_CONFIG, multimedia):src_plugins.depends += src_multimedia -- cgit v0.12 From 2c8031cffdfa48e93cb77be657422fc926ec1a29 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 7 Jan 2011 07:39:08 +0100 Subject: Stopped honoring the RVCT22INC variable on symbian-armcc mkspec. This usually points to the RVCT include directory, but those headers are not appropriate for Symbian. RevBy: Trust me --- mkspecs/features/symbian/symbian_building.prf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index 9288583..2ff279f 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -1,6 +1,11 @@ symbian-armcc { QMAKE_CFLAGS += $$QMAKE_CFLAGS.ARMCC QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS.ARMCC + # This is to prevent inclusion of the shipped RVCT headers, which are often in the + # environment variable RVCTxxINC by default. -J prevents the searching of that location, + # but needs a path, so just specify somewhere guaranteed not to contain header files. + QMAKE_CFLAGS += -J$${EPOCROOT}epoc32/ignore_this_path + QMAKE_CXXFLAGS += -J$${EPOCROOT}epoc32/ignore_this_path } else:symbian-gcce { QMAKE_CFLAGS += $$QMAKE_CFLAGS.GCCE QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS.GCCE @@ -235,12 +240,7 @@ contains(TEMPLATE, app):!contains(QMAKE_LINK, "^@:.*") { } # Symbian resource files -symbian-armcc: { - SYMBIAN_RVCT22INC=$$(RVCT22INC) - !isEmpty(SYMBIAN_RVCT22INC):symbian_resources_INCLUDES = -I$${SYMBIAN_RVCT22INC} -} -symbian_resources_INCLUDES = $$replace(symbian_resources_INCLUDES, ",", " -I") -symbian_resources_INCLUDES += $$join(INCLUDEPATH, " -I", "-I") +symbian_resources_INCLUDES = $$join(INCLUDEPATH, " -I", "-I") symbian_resources_DEFINES = $$join(DEFINES, " -D", "-D") symbian_resources_RCC_DIR = $$replace(RCC_DIR, "/$", "") symbian_resources_INCLUDES += "-I$$symbian_resources_RCC_DIR" -- cgit v0.12 From 0ec421b76066b6016c98a8d2f589db5516bb1a93 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 7 Jan 2011 07:47:12 +0100 Subject: Added .lib/.dso dependency tracking to Symbian with MinGW generator. This is just a mirror of the way the UNIX generator does it. See commits aaf189b084f52 and bdff51768dfe. RevBy: Oswald Buddenhagen --- qmake/generators/win32/mingw_make.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index ca04e91..7099422 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -218,6 +218,12 @@ void createRvctObjectScriptFile(const QString &fileName, const QStringList &objL void MingwMakefileGenerator::writeMingwParts(QTextStream &t) { + if (!project->isEmpty("QMAKE_SYMBIAN_SHLIB")) { + t << "vpath %.dso " << project->values("QMAKE_LIBDIR").join(";") << endl; + t << "vpath %.lib " << project->values("QMAKE_LIBDIR").join(";") << endl; + t << "\n\n"; + } + writeStandardParts(t); if (!preCompHeaderOut.isEmpty()) { -- cgit v0.12 From b93fc7fabd289c99124bf68898605591d6d9b283 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 7 Jan 2011 07:53:13 +0100 Subject: Avoided some MinGW specific codepaths when building Symbian libs. RevBy: Trust me --- qmake/generators/win32/mingw_make.cpp | 4 ++-- qmake/generators/win32/winmakefile.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 7099422..8450eaf 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -290,7 +290,7 @@ void MingwMakefileGenerator::init() if(configs.indexOf("qt") == -1) configs.append("qt"); - if(project->isActiveConfig("dll")) { + if(project->isActiveConfig("dll") && project->values("QMAKE_SYMBIAN_SHLIB").isEmpty()) { QString destDir = ""; if(!project->first("DESTDIR").isEmpty()) destDir = Option::fixPathToTargetOS(project->first("DESTDIR") + Option::dir_sep, false, false); @@ -299,7 +299,7 @@ void MingwMakefileGenerator::init() project->values("QMAKE_LFLAGS").append(QString("-Wl,--out-implib,") + project->first("MINGW_IMPORT_LIB")); } - if(!project->values("DEF_FILE").isEmpty()) + if(!project->values("DEF_FILE").isEmpty() && project->values("QMAKE_SYMBIAN_SHLIB").isEmpty()) project->values("QMAKE_LFLAGS").append(QString("-Wl,") + project->first("DEF_FILE")); MakefileGenerator::init(); diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 8cf970e..a42b97d 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -314,7 +314,8 @@ void Win32MakefileGenerator::processVars() // TARGET_VERSION_EXT will be used to add a version number onto the target name if (project->values("TARGET_VERSION_EXT").isEmpty() - && !project->values("VER_MAJ").isEmpty()) + && !project->values("VER_MAJ").isEmpty() + && project->values("QMAKE_SYMBIAN_SHLIB").isEmpty()) project->values("TARGET_VERSION_EXT").append(project->values("VER_MAJ").first()); if(project->isEmpty("QMAKE_COPY_FILE")) -- cgit v0.12 From 5c88141ed0b25d8ab9318bf4cb5dda54b90b2ce1 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 7 Jan 2011 07:56:19 +0100 Subject: Added support for rvct_linker config in qmake's MinGW generator. RevBy: Trust me --- qmake/generators/win32/mingw_make.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 8450eaf..648776d 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -368,17 +368,25 @@ void MingwMakefileGenerator::writeLibsPart(QTextStream &t) t << "LIBS = "; if(!project->values("QMAKE_LIBDIR").isEmpty()) writeLibDirPart(t); - t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << ' ' - << var("QMAKE_LIBS_PRIVATE").replace(QRegExp("(\\slib|^lib)")," -l") << endl; + if (project->isActiveConfig("rvct_linker")) { + t << var("QMAKE_LIBS") << ' ' + << var("QMAKE_LIBS_PRIVATE") << endl; + } else { + t << var("QMAKE_LIBS").replace(QRegExp("(\\slib|^lib)")," -l") << ' ' + << var("QMAKE_LIBS_PRIVATE").replace(QRegExp("(\\slib|^lib)")," -l") << endl; + } } } void MingwMakefileGenerator::writeLibDirPart(QTextStream &t) { QStringList libDirs = project->values("QMAKE_LIBDIR"); + QString libArg = QString::fromLatin1("-L"); + if (project->isActiveConfig("rvct_linker")) + libArg = QString::fromLatin1("--userlibpath "); for (int i = 0; i < libDirs.size(); ++i) libDirs[i].remove("\""); - t << valGlue(libDirs,"-L"+quote,quote+" -L" +quote,quote) << " "; + t << valGlue(libDirs, libArg+quote, quote+" "+libArg+quote, quote) << " "; } void MingwMakefileGenerator::writeObjectsPart(QTextStream &t) -- cgit v0.12 From 21f2e2330f788543e3ba97eeec50885150d45397 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 7 Jan 2011 08:09:01 +0100 Subject: Added support for various special compiler/linker flags on MinGW. This enables you to use QMAKE_xxx_yyy, where xxx is either CFLAGS, CXXFLAGS or LFLAGS, and yyy is either APP, SHLIB or PLUGIN. It is basically the same as the one in the UNIX generator. RevBy: Oswald Buddenhagen --- qmake/generators/win32/winmakefile.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index a42b97d..8530825 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -343,6 +343,24 @@ void Win32MakefileGenerator::processVars() if(!(*libDir_it).isEmpty()) (*libDir_it) = Option::fixPathToTargetOS((*libDir_it), false, false); } + + if (project->values("TEMPLATE").contains("app")) { + project->values("QMAKE_CFLAGS") += project->values("QMAKE_CFLAGS_APP"); + project->values("QMAKE_CXXFLAGS") += project->values("QMAKE_CXXFLAGS_APP"); + project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_APP"); + } else if (project->values("TEMPLATE").contains("lib") && project->isActiveConfig("dll")) { + if(!project->isActiveConfig("plugin") || !project->isActiveConfig("plugin_no_share_shlib_cflags")) { + project->values("QMAKE_CFLAGS") += project->values("QMAKE_CFLAGS_SHLIB"); + project->values("QMAKE_CXXFLAGS") += project->values("QMAKE_CXXFLAGS_SHLIB"); + } + if (project->isActiveConfig("plugin")) { + project->values("QMAKE_CFLAGS") += project->values("QMAKE_CFLAGS_PLUGIN"); + project->values("QMAKE_CXXFLAGS") += project->values("QMAKE_CXXFLAGS_PLUGIN"); + project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_PLUGIN"); + } else { + project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_SHLIB"); + } + } } void Win32MakefileGenerator::fixTargetExt() -- cgit v0.12 From 3f00eed4c329670bf10640c43467cd122347e0d2 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 7 Jan 2011 08:24:41 +0100 Subject: Added MinGW support for adding lib prefix and extension via profile. RevBy: Oswald Buddenhagen --- mkspecs/win32-g++/qmake.conf | 2 ++ qmake/generators/win32/mingw_make.cpp | 5 +---- qmake/generators/win32/winmakefile.cpp | 22 +++++++++++++++++----- qmake/generators/win32/winmakefile.h | 1 + 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf index ec216aa..8e49b18 100644 --- a/mkspecs/win32-g++/qmake.conf +++ b/mkspecs/win32-g++/qmake.conf @@ -62,6 +62,8 @@ QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows QMAKE_LFLAGS_DLL = -shared QMAKE_LINK_OBJECT_MAX = 10 QMAKE_LINK_OBJECT_SCRIPT= object_script +QMAKE_PREFIX_STATICLIB = lib +QMAKE_EXTENSION_STATICLIB = a QMAKE_LIBS = diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 648776d..95795b8 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -335,12 +335,9 @@ void MingwMakefileGenerator::init() void MingwMakefileGenerator::fixTargetExt() { if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { - project->values("TARGET_EXT").append(".a"); project->values("QMAKE_LFLAGS").append("-static"); - project->values("TARGET").first() = "lib" + project->first("TARGET"); - } else { - Win32MakefileGenerator::fixTargetExt(); } + Win32MakefileGenerator::fixTargetExt(); } void MingwMakefileGenerator::writeIncPart(QTextStream &t) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 8530825..a2f4c7b 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -57,6 +57,14 @@ Win32MakefileGenerator::Win32MakefileGenerator() : MakefileGenerator() { } +void Win32MakefileGenerator::init() +{ + if (project->isEmpty("QMAKE_EXTENSION_STATICLIB")) + project->values("QMAKE_EXTENSION_STATICLIB").append("lib"); + if (project->isEmpty("QMAKE_EXTENSION_SHLIB")) + project->values("QMAKE_EXTENSION_SHLIB").append("lib"); +} + int Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem, const QString &ext) { @@ -365,12 +373,16 @@ void Win32MakefileGenerator::processVars() void Win32MakefileGenerator::fixTargetExt() { - if (!project->values("QMAKE_APP_FLAG").isEmpty()) + if (!project->values("QMAKE_APP_FLAG").isEmpty()) { project->values("TARGET_EXT").append(".exe"); - else if (project->isActiveConfig("shared")) - project->values("TARGET_EXT").append(project->first("TARGET_VERSION_EXT") + ".dll"); - else - project->values("TARGET_EXT").append(".lib"); + } else if (project->isActiveConfig("shared")) { + project->values("TARGET_EXT").append(project->first("TARGET_VERSION_EXT") + "." + + project->first("QMAKE_EXTENSION_SHLIB")); + project->values("TARGET").first() = project->first("QMAKE_PREFIX_SHLIB") + project->first("TARGET"); + } else { + project->values("TARGET_EXT").append("." + project->first("QMAKE_EXTENSION_STATICLIB")); + project->values("TARGET").first() = project->first("QMAKE_PREFIX_STATICLIB") + project->first("TARGET"); + } } void Win32MakefileGenerator::processRcFileVar() diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h index 5437524..0e95beb 100644 --- a/qmake/generators/win32/winmakefile.h +++ b/qmake/generators/win32/winmakefile.h @@ -59,6 +59,7 @@ class Win32MakefileGenerator : public MakefileGenerator public: Win32MakefileGenerator(); ~Win32MakefileGenerator(); + void init(); protected: virtual QString defaultInstall(const QString &); virtual void writeCleanParts(QTextStream &t); -- cgit v0.12 From 63c02607744fd5431132c6ea4f44380e6e20e12f Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 28 Jan 2011 10:27:33 +0100 Subject: Fixed GCCE libdir handling if the paths have spaces in them. RevBy: Trust me --- mkspecs/symbian-gcce/qmake.conf | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mkspecs/symbian-gcce/qmake.conf b/mkspecs/symbian-gcce/qmake.conf index a31e6e4..3992681 100644 --- a/mkspecs/symbian-gcce/qmake.conf +++ b/mkspecs/symbian-gcce/qmake.conf @@ -72,16 +72,16 @@ QMAKE_LFLAGS += --target1-abs \ QMAKE_LIBDIR += $${EPOCROOT}epoc32/release/armv5/udeb/ # g++ knows the path to the gcc-shipped-libs, ld doesn't. So cache the full path in the generate Makefile -QMAKE_GCC_SEARCH_DIRS =$$system($$QMAKE_CXX -print-search-dirs) -for(line, QMAKE_GCC_SEARCH_DIRS) { - contains(line, "libraries:") { - foundIt="1" - } else { - contains(foundIt, "1") { - QMAKE_LFLAGS += $$replace(line, "[=:]", " -L") - } - } +QMAKE_GCC_SEARCH_DIRS = $$system($$QMAKE_CXX -print-search-dirs) +QMAKE_GCC_SEARCH_DIRS = "$$join(QMAKE_GCC_SEARCH_DIRS, " ")" +QMAKE_GCC_SEARCH_DIRS = $$replace(QMAKE_GCC_SEARCH_DIRS, ".*libraries: *", "") +QMAKE_GCC_SEARCH_DIRS = $$replace(QMAKE_GCC_SEARCH_DIRS, "=", "") +contains(QMAKE_HOST.os,Windows) { + QMAKE_GCC_SEARCH_DIRS = $$split(QMAKE_GCC_SEARCH_DIRS, ;) +} else { + QMAKE_GCC_SEARCH_DIRS = $$split(QMAKE_GCC_SEARCH_DIRS, :) } +for(line, QMAKE_GCC_SEARCH_DIRS):QMAKE_LIBDIR += $$line QMAKE_LIBDIR += $${EPOCROOT}epoc32/release/armv5/lib -- cgit v0.12 From 8a443d2695344f26b9adf4310672e1a5fd62aeb5 Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 28 Jan 2011 10:28:23 +0100 Subject: Made qmake strip trailing \ from libdirs. This was done because trailing \ would confuse the command line parser if the path was also quoted. RevBy: Oswald Buddenhagen --- qmake/generators/win32/mingw_make.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 95795b8..e4082cc 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -381,8 +381,11 @@ void MingwMakefileGenerator::writeLibDirPart(QTextStream &t) QString libArg = QString::fromLatin1("-L"); if (project->isActiveConfig("rvct_linker")) libArg = QString::fromLatin1("--userlibpath "); - for (int i = 0; i < libDirs.size(); ++i) + for (int i = 0; i < libDirs.size(); ++i) { libDirs[i].remove("\""); + if (libDirs[i].endsWith("\\")) + libDirs[i].chop(1); + } t << valGlue(libDirs, libArg+quote, quote+" "+libArg+quote, quote) << " "; } -- cgit v0.12 From c40ae86025856225e74289249ecc509bf61dc9ba Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 28 Jan 2011 14:52:41 +0100 Subject: Fix for linux build error --- tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp index fac5702..956253f 100644 --- a/tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp +++ b/tests/auto/qscopedvaluerollback/tst_qscopedvaluerollback.cpp @@ -200,4 +200,4 @@ void tst_QScopedValueRollback::earlyExitScope_helper(int exitpoint, int& member) } QTEST_MAIN(tst_QScopedValueRollback) -#include "tst_QScopedValueRollback.moc" +#include "tst_qscopedvaluerollback.moc" -- cgit v0.12 From 3f6da18e492a58d65feabdb2037b13d38ddf83bd Mon Sep 17 00:00:00 2001 From: axis Date: Mon, 31 Jan 2011 14:39:23 +0100 Subject: Fixed win32-msvc2008 build regression. We needed to move the code in the init() function to the fixTargetExt() function, which is where the variables are actually used. The reason is that fixTargetExt() runs before init(). RevBy: Miikka Heikkinen --- qmake/generators/win32/winmakefile.cpp | 13 +++++-------- qmake/generators/win32/winmakefile.h | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 409d550..603ffb5 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -57,14 +57,6 @@ Win32MakefileGenerator::Win32MakefileGenerator() : MakefileGenerator() { } -void Win32MakefileGenerator::init() -{ - if (project->isEmpty("QMAKE_EXTENSION_STATICLIB")) - project->values("QMAKE_EXTENSION_STATICLIB").append("lib"); - if (project->isEmpty("QMAKE_EXTENSION_SHLIB")) - project->values("QMAKE_EXTENSION_SHLIB").append("lib"); -} - int Win32MakefileGenerator::findHighestVersion(const QString &d, const QString &stem, const QString &ext) { @@ -373,6 +365,11 @@ void Win32MakefileGenerator::processVars() void Win32MakefileGenerator::fixTargetExt() { + if (project->isEmpty("QMAKE_EXTENSION_STATICLIB")) + project->values("QMAKE_EXTENSION_STATICLIB").append("lib"); + if (project->isEmpty("QMAKE_EXTENSION_SHLIB")) + project->values("QMAKE_EXTENSION_SHLIB").append("dll"); + if (!project->values("QMAKE_APP_FLAG").isEmpty()) { project->values("TARGET_EXT").append(".exe"); } else if (project->isActiveConfig("shared")) { diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h index cfc2c55..fb11e1a 100644 --- a/qmake/generators/win32/winmakefile.h +++ b/qmake/generators/win32/winmakefile.h @@ -59,7 +59,6 @@ class Win32MakefileGenerator : public MakefileGenerator public: Win32MakefileGenerator(); ~Win32MakefileGenerator(); - void init(); protected: virtual QString defaultInstall(const QString &); virtual void writeCleanParts(QTextStream &t); -- cgit v0.12 From 8c8d76ad7dc0d4fb8c95efb70245854f4f69cfc5 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 1 Feb 2011 11:15:55 +0100 Subject: Fixed "not a valid preprocessing token" on GCCE. It seems to be fixed upstream already. RevBy: Gareth Stockwell --- src/3rdparty/phonon/mmf/abstractaudioeffect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 70adcf6..517a334 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -124,7 +124,7 @@ private: #define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect) \ \ -void Effect##::createEffect(AudioPlayer::NativePlayer *player) \ +void Effect::createEffect(AudioPlayer::NativePlayer *player) \ { \ C##Effect *ptr = 0; \ QT_TRAP_THROWING(ptr = C##Effect::NewL(*player)); \ -- cgit v0.12 From 5a74d76d9fe9f2a49f5e0d062da590ecc08cf9bb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 1 Feb 2011 11:42:25 +0100 Subject: Fix leak in QFactoryLoader We need to release the library in case of errors --- src/corelib/plugin/qfactoryloader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 1be32ad..c0b947a 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -155,9 +155,11 @@ void QFactoryLoader::update() continue; } QObject *instance = library->instance(); - if (!instance) + if (!instance) { + library->release(); // ignore plugins that have a valid signature but cannot be loaded. continue; + } QFactoryInterface *factory = qobject_cast(instance); if (instance && factory && instance->qt_metacast(d->iid)) keys = factory->keys(); -- cgit v0.12 From 6f313a63d4155b53659917a3f7a71f4de60d0d91 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 2 Feb 2011 15:47:13 +0100 Subject: Crash in QFileSystemEngine::canonicalName with older libc version Crashed on OpenBSD. POSIX.1-2001 says that the behavior if resolved_path is NULL is implementation-defined. POSIX.1-2008 specifies that the it can be NULL Reviewed-By: Markus Goetz --- src/corelib/io/qfilesystemengine_unix.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 6acd811..8b88ffd 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -174,8 +174,9 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, if (entry.isEmpty() || entry.isRoot()) return entry; -#ifdef __UCLIBC__ - return QFileSystemEntry::slowCanonicalName(entry); +#if !defined(Q_OS_MAC) && _POSIX_VERSION < 200809L + // realpath(X,0) is not supported + return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); #else char *ret = 0; # if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES) -- cgit v0.12 From ba8e5eedf5f40091eb67dd391a7dcaf9299db2f5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 3 Feb 2011 14:57:33 +0100 Subject: Implement QThreadData::current using __thread It slightly faster, and QThreadData::current is used everywhere Reviewed-by: mread Reviewed-by: Joao --- src/corelib/thread/qthread_unix.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 0766447..891ac77 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -110,6 +110,17 @@ QT_BEGIN_NAMESPACE enum { ThreadPriorityResetFlag = 0x80000000 }; +#if defined(Q_OS_LINUX) && defined(__GLIBC__) && (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) +#define HAVE_TLS +#endif +#if defined(Q_CC_XLC) || defined (Q_CC_SUN) +#define HAVE_TLS +#endif + +#ifdef HAVE_TLS +static __thread QThreadData *currentThreadData = 0; +#endif + static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT; static pthread_key_t current_thread_data_key; @@ -157,7 +168,9 @@ Q_DESTRUCTOR_FUNCTION(destroy_current_thread_data_key) // that pthread has, so pthread_setspecific is also used. static QThreadData *get_thread_data() { -#ifdef Q_OS_SYMBIAN +#ifdef HAVE_TLS + return currentThreadData; +#elif defined Q_OS_SYMBIAN return reinterpret_cast(Dll::Tls()); #else pthread_once(¤t_thread_data_once, create_current_thread_data_key); @@ -167,7 +180,9 @@ static QThreadData *get_thread_data() static void set_thread_data(QThreadData *data) { -#ifdef Q_OS_SYMBIAN +#ifdef HAVE_TLS + currentThreadData = data; +#elif defined Q_OS_SYMBIAN qt_symbian_throwIfError(Dll::SetTls(data)); #endif pthread_once(¤t_thread_data_once, create_current_thread_data_key); @@ -176,7 +191,9 @@ static void set_thread_data(QThreadData *data) static void clear_thread_data() { -#ifdef Q_OS_SYMBIAN +#ifdef HAVE_TLS + currentThreadData = 0; +#elif defined Q_OS_SYMBIAN Dll::FreeTls(); #endif pthread_setspecific(current_thread_data_key, 0); -- cgit v0.12 From 6c39dd04b1fea88e0688ef847e185ebb1013471a Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 12 Jan 2011 10:55:25 +0100 Subject: tst_qnetworkreply: Relax a condition With the different buffers in Qt and the OS, we relax a condition for now. --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 1d2a69f..fd494c6 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -3850,19 +3850,13 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress() disconnect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop())); incomingSocket->setReadBufferSize(1*1024); - QTestEventLoop::instance().enterLoop(2); + QTestEventLoop::instance().enterLoop(5); // some progress should have been made QList args = spy.last(); QVERIFY(!args.isEmpty()); QVERIFY(args.at(0).toLongLong() > 0); - - incomingSocket->setReadBufferSize(32*1024); - incomingSocket->read(16*1024); - QTestEventLoop::instance().enterLoop(2); - // some more progress than before - QList args2 = spy.last(); - QVERIFY(!args2.isEmpty()); - QVERIFY(args2.at(0).toLongLong() > args.at(0).toLongLong()); + // but not everything! + QVERIFY(args.at(0).toLongLong() != sourceFile.size()); // set the read buffer to unlimited incomingSocket->setReadBufferSize(0); @@ -3870,8 +3864,10 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress() // progress should be finished QList args3 = spy.last(); QVERIFY(!args3.isEmpty()); - QVERIFY(args3.at(0).toLongLong() > args2.at(0).toLongLong()); + // More progress than before + QVERIFY(args3.at(0).toLongLong() > args.at(0).toLongLong()); QCOMPARE(args3.at(0).toLongLong(), args3.at(1).toLongLong()); + // And actually finished.. QCOMPARE(args3.at(0).toLongLong(), sourceFile.size()); // after sending this, the QNAM should emit finished() -- cgit v0.12 From 7ce32e349da4d9b17495aaf966c59a4233cd6f26 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 27 Jan 2011 14:02:44 +0100 Subject: QNAM: Move authentication cache to separate class Also make the authentication cache thread-safe by using a mutex and making QNetworkAuthenticationCredential a value-class. Reviewed-by: thiago --- src/network/access/access.pri | 2 + .../access/qnetworkaccessauthenticationmanager.cpp | 297 +++++++++++++++++++++ .../access/qnetworkaccessauthenticationmanager_p.h | 107 ++++++++ src/network/access/qnetworkaccessbackend.cpp | 2 +- src/network/access/qnetworkaccessmanager.cpp | 254 +----------------- src/network/access/qnetworkaccessmanager_p.h | 7 +- 6 files changed, 424 insertions(+), 245 deletions(-) create mode 100644 src/network/access/qnetworkaccessauthenticationmanager.cpp create mode 100644 src/network/access/qnetworkaccessauthenticationmanager_p.h diff --git a/src/network/access/access.pri b/src/network/access/access.pri index f8dfda6..7497c1a 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -8,6 +8,7 @@ HEADERS += \ access/qhttpnetworkreply_p.h \ access/qhttpnetworkconnection_p.h \ access/qhttpnetworkconnectionchannel_p.h \ + access/qnetworkaccessauthenticationmanager_p.h \ access/qnetworkaccessmanager.h \ access/qnetworkaccessmanager_p.h \ access/qnetworkaccesscache_p.h \ @@ -42,6 +43,7 @@ SOURCES += \ access/qhttpnetworkreply.cpp \ access/qhttpnetworkconnection.cpp \ access/qhttpnetworkconnectionchannel.cpp \ + access/qnetworkaccessauthenticationmanager.cpp \ access/qnetworkaccessmanager.cpp \ access/qnetworkaccesscache.cpp \ access/qnetworkaccessbackend.cpp \ diff --git a/src/network/access/qnetworkaccessauthenticationmanager.cpp b/src/network/access/qnetworkaccessauthenticationmanager.cpp new file mode 100644 index 0000000..d2bf00a --- /dev/null +++ b/src/network/access/qnetworkaccessauthenticationmanager.cpp @@ -0,0 +1,297 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnetworkaccessmanager.h" +#include "qnetworkaccessmanager_p.h" +#include "qnetworkaccessauthenticationmanager_p.h" + +#include "QtCore/qbuffer.h" +#include "QtCore/qurl.h" +#include "QtCore/qvector.h" +#include "QtCore/QMutexLocker" +#include "QtNetwork/qauthenticator.h" + +QT_BEGIN_NAMESPACE + + + + +class QNetworkAuthenticationCache: private QVector, + public QNetworkAccessCache::CacheableObject +{ +public: + QNetworkAuthenticationCache() + { + setExpires(false); + setShareable(true); + reserve(1); + } + + QNetworkAuthenticationCredential *findClosestMatch(const QString &domain) + { + iterator it = qLowerBound(begin(), end(), domain); + if (it == end() && !isEmpty()) + --it; + if (it == end() || !domain.startsWith(it->domain)) + return 0; + return &*it; + } + + void insert(const QString &domain, const QString &user, const QString &password) + { + QNetworkAuthenticationCredential *closestMatch = findClosestMatch(domain); + if (closestMatch && closestMatch->domain == domain) { + // we're overriding the current credentials + closestMatch->user = user; + closestMatch->password = password; + } else { + QNetworkAuthenticationCredential newCredential; + newCredential.domain = domain; + newCredential.user = user; + newCredential.password = password; + + if (closestMatch) + QVector::insert(++closestMatch, newCredential); + else + QVector::insert(end(), newCredential); + } + } + + virtual void dispose() { delete this; } +}; + +#ifndef QT_NO_NETWORKPROXY +static QByteArray proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm) +{ + QUrl key; + + switch (proxy.type()) { + case QNetworkProxy::Socks5Proxy: + key.setScheme(QLatin1String("proxy-socks5")); + break; + + case QNetworkProxy::HttpProxy: + case QNetworkProxy::HttpCachingProxy: + key.setScheme(QLatin1String("proxy-http")); + break; + + case QNetworkProxy::FtpCachingProxy: + key.setScheme(QLatin1String("proxy-ftp")); + break; + + case QNetworkProxy::DefaultProxy: + case QNetworkProxy::NoProxy: + // shouldn't happen + return QByteArray(); + + // no default: + // let there be errors if a new proxy type is added in the future + } + + if (key.scheme().isEmpty()) + // proxy type not handled + return QByteArray(); + + key.setUserName(proxy.user()); + key.setHost(proxy.hostName()); + key.setPort(proxy.port()); + key.setFragment(realm); + return "auth:" + key.toEncoded(); +} +#endif + +static inline QByteArray authenticationKey(const QUrl &url, const QString &realm) +{ + QUrl copy = url; + copy.setFragment(realm); + return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery); +} + + +#ifndef QT_NO_NETWORKPROXY +void QNetworkAccessAuthenticationManager::cacheProxyCredentials(const QNetworkProxy &p, + const QAuthenticator *authenticator) +{ + Q_ASSERT(authenticator); + Q_ASSERT(p.type() != QNetworkProxy::DefaultProxy); + Q_ASSERT(p.type() != QNetworkProxy::NoProxy); + + QMutexLocker mutexLocker(&mutex); + + QString realm = authenticator->realm(); + QNetworkProxy proxy = p; + proxy.setUser(authenticator->user()); + // Set two credentials: one with the username and one without + do { + // Set two credentials actually: one with and one without the realm + do { + QByteArray cacheKey = proxyAuthenticationKey(proxy, realm); + if (cacheKey.isEmpty()) + return; // should not happen + + QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache; + auth->insert(QString(), authenticator->user(), authenticator->password()); + authenticationCache.addEntry(cacheKey, auth); // replace the existing one, if there's any + + if (realm.isEmpty()) { + break; + } else { + realm.clear(); + } + } while (true); + + if (proxy.user().isEmpty()) + break; + else + proxy.setUser(QString()); + } while (true); +} + +QNetworkAuthenticationCredential +QNetworkAccessAuthenticationManager::fetchCachedProxyCredentials(const QNetworkProxy &p, + const QAuthenticator *authenticator) +{ + QNetworkProxy proxy = p; + if (proxy.type() == QNetworkProxy::DefaultProxy) { + proxy = QNetworkProxy::applicationProxy(); + } + if (!proxy.password().isEmpty()) + return QNetworkAuthenticationCredential(); // no need to set credentials if it already has them + + QString realm; + if (authenticator) + realm = authenticator->realm(); + + QMutexLocker mutexLocker(&mutex); + QByteArray cacheKey = proxyAuthenticationKey(proxy, realm); + if (cacheKey.isEmpty()) + return QNetworkAuthenticationCredential(); + if (!authenticationCache.hasEntry(cacheKey)) + return QNetworkAuthenticationCredential(); + + QNetworkAuthenticationCache *auth = + static_cast(authenticationCache.requestEntryNow(cacheKey)); + QNetworkAuthenticationCredential cred = *auth->findClosestMatch(QString()); + authenticationCache.releaseEntry(cacheKey); + + // proxy cache credentials always have exactly one item + Q_ASSERT_X(!cred.isNull(), "QNetworkAccessManager", + "Internal inconsistency: found a cache key for a proxy, but it's empty"); + return cred; +} + +#endif + +void QNetworkAccessAuthenticationManager::cacheCredentials(const QUrl &url, + const QAuthenticator *authenticator) +{ + Q_ASSERT(authenticator); + QString domain = QString::fromLatin1("/"); // FIXME: make QAuthenticator return the domain + QString realm = authenticator->realm(); + + QMutexLocker mutexLocker(&mutex); + + // Set two credentials actually: one with and one without the username in the URL + QUrl copy = url; + copy.setUserName(authenticator->user()); + do { + QByteArray cacheKey = authenticationKey(copy, realm); + if (authenticationCache.hasEntry(cacheKey)) { + QNetworkAuthenticationCache *auth = + static_cast(authenticationCache.requestEntryNow(cacheKey)); + auth->insert(domain, authenticator->user(), authenticator->password()); + authenticationCache.releaseEntry(cacheKey); + } else { + QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache; + auth->insert(domain, authenticator->user(), authenticator->password()); + authenticationCache.addEntry(cacheKey, auth); + } + + if (copy.userName().isEmpty()) { + break; + } else { + copy.setUserName(QString()); + } + } while (true); +} + +/*! + Fetch the credential data from the credential cache. + + If auth is 0 (as it is when called from createRequest()), this will try to + look up with an empty realm. That fails in most cases for HTTP (because the + realm is seldom empty for HTTP challenges). In any case, QHttpNetworkConnection + never sends the credentials on the first attempt: it needs to find out what + authentication methods the server supports. + + For FTP, realm is always empty. +*/ +QNetworkAuthenticationCredential +QNetworkAccessAuthenticationManager::fetchCachedCredentials(const QUrl &url, + const QAuthenticator *authentication) +{ + if (!url.password().isEmpty()) + return QNetworkAuthenticationCredential(); // no need to set credentials if it already has them + + QString realm; + if (authentication) + realm = authentication->realm(); + + QByteArray cacheKey = authenticationKey(url, realm); + + QMutexLocker mutexLocker(&mutex); + if (!authenticationCache.hasEntry(cacheKey)) + return QNetworkAuthenticationCredential(); + + QNetworkAuthenticationCache *auth = + static_cast(authenticationCache.requestEntryNow(cacheKey)); + QNetworkAuthenticationCredential cred = *auth->findClosestMatch(url.path()); + authenticationCache.releaseEntry(cacheKey); + return cred; +} + +void QNetworkAccessAuthenticationManager::clearCache() +{ + authenticationCache.clear(); +} + +QT_END_NAMESPACE + diff --git a/src/network/access/qnetworkaccessauthenticationmanager_p.h b/src/network/access/qnetworkaccessauthenticationmanager_p.h new file mode 100644 index 0000000..d2347b1 --- /dev/null +++ b/src/network/access/qnetworkaccessauthenticationmanager_p.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNETWORKACCESSAUTHENTICATIONMANAGER_P_H +#define QNETWORKACCESSAUTHENTICATIONMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the Network Access API. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "qnetworkaccessmanager.h" +#include "qnetworkaccesscache_p.h" +#include "qnetworkaccessbackend_p.h" +#include "QtNetwork/qnetworkproxy.h" +#include "QtCore/QMutex" + +QT_BEGIN_NAMESPACE + +class QAuthenticator; +class QAbstractNetworkCache; +class QNetworkAuthenticationCredential; +class QNetworkCookieJar; + +class QNetworkAuthenticationCredential +{ +public: + QString domain; + QString user; + QString password; + bool isNull() { + return domain.isNull(); + } +}; +Q_DECLARE_TYPEINFO(QNetworkAuthenticationCredential, Q_MOVABLE_TYPE); +inline bool operator<(const QNetworkAuthenticationCredential &t1, const QString &t2) +{ return t1.domain < t2; } + +class QNetworkAccessAuthenticationManager +{ +public: + QNetworkAccessAuthenticationManager() { }; + + void cacheCredentials(const QUrl &url, const QAuthenticator *auth); + QNetworkAuthenticationCredential fetchCachedCredentials(const QUrl &url, + const QAuthenticator *auth = 0); + +#ifndef QT_NO_NETWORKPROXY + void cacheProxyCredentials(const QNetworkProxy &proxy, const QAuthenticator *auth); + QNetworkAuthenticationCredential fetchCachedProxyCredentials(const QNetworkProxy &proxy, + const QAuthenticator *auth = 0); +#endif + + void clearCache(); + +protected: + QNetworkAccessCache authenticationCache; + QMutex mutex; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index fd1fa60..53ae29e 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -329,7 +329,7 @@ void QNetworkAccessBackend::authenticationRequired(QAuthenticator *authenticator void QNetworkAccessBackend::cacheCredentials(QAuthenticator *authenticator) { - manager->cacheCredentials(this->reply->url, authenticator); + manager->authenticationManager->cacheCredentials(this->reply->url, authenticator); } void QNetworkAccessBackend::metaDataChanged() diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 8f050d4..562141b 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -341,107 +341,6 @@ static void ensureInitialized() QNetworkReply::sslConfiguration(), QNetworkReply::ignoreSslErrors() */ -class QNetworkAuthenticationCredential -{ -public: - QString domain; - QString user; - QString password; -}; -Q_DECLARE_TYPEINFO(QNetworkAuthenticationCredential, Q_MOVABLE_TYPE); -inline bool operator<(const QNetworkAuthenticationCredential &t1, const QString &t2) -{ return t1.domain < t2; } - -class QNetworkAuthenticationCache: private QVector, - public QNetworkAccessCache::CacheableObject -{ -public: - QNetworkAuthenticationCache() - { - setExpires(false); - setShareable(true); - reserve(1); - } - - QNetworkAuthenticationCredential *findClosestMatch(const QString &domain) - { - iterator it = qLowerBound(begin(), end(), domain); - if (it == end() && !isEmpty()) - --it; - if (it == end() || !domain.startsWith(it->domain)) - return 0; - return &*it; - } - - void insert(const QString &domain, const QString &user, const QString &password) - { - QNetworkAuthenticationCredential *closestMatch = findClosestMatch(domain); - if (closestMatch && closestMatch->domain == domain) { - // we're overriding the current credentials - closestMatch->user = user; - closestMatch->password = password; - } else { - QNetworkAuthenticationCredential newCredential; - newCredential.domain = domain; - newCredential.user = user; - newCredential.password = password; - - if (closestMatch) - QVector::insert(++closestMatch, newCredential); - else - QVector::insert(end(), newCredential); - } - } - - virtual void dispose() { delete this; } -}; - -#ifndef QT_NO_NETWORKPROXY -static QByteArray proxyAuthenticationKey(const QNetworkProxy &proxy, const QString &realm) -{ - QUrl key; - - switch (proxy.type()) { - case QNetworkProxy::Socks5Proxy: - key.setScheme(QLatin1String("proxy-socks5")); - break; - - case QNetworkProxy::HttpProxy: - case QNetworkProxy::HttpCachingProxy: - key.setScheme(QLatin1String("proxy-http")); - break; - - case QNetworkProxy::FtpCachingProxy: - key.setScheme(QLatin1String("proxy-ftp")); - break; - - case QNetworkProxy::DefaultProxy: - case QNetworkProxy::NoProxy: - // shouldn't happen - return QByteArray(); - - // no default: - // let there be errors if a new proxy type is added in the future - } - - if (key.scheme().isEmpty()) - // proxy type not handled - return QByteArray(); - - key.setUserName(proxy.user()); - key.setHost(proxy.hostName()); - key.setPort(proxy.port()); - key.setFragment(realm); - return "auth:" + key.toEncoded(); -} -#endif - -static inline QByteArray authenticationKey(const QUrl &url, const QString &realm) -{ - QUrl copy = url; - copy.setFragment(realm); - return "auth:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery); -} /*! Constructs a QNetworkAccessManager object that is the center of @@ -1124,10 +1023,10 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QNetworkAccessBackend // also called when last URL is empty, e.g. on first call if (backend->reply->urlForLastAuthentication.isEmpty() || url != backend->reply->urlForLastAuthentication) { - QNetworkAuthenticationCredential *cred = fetchCachedCredentials(url, authenticator); - if (cred) { - authenticator->setUser(cred->user); - authenticator->setPassword(cred->password); + QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedCredentials(url, authenticator); + if (!cred.isNull()) { + authenticator->setUser(cred.user); + authenticator->setPassword(cred.password); backend->reply->urlForLastAuthentication = url; return; } @@ -1140,7 +1039,7 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QNetworkAccessBackend backend->reply->urlForLastAuthentication = url; emit q->authenticationRequired(backend->reply->q_func(), authenticator); - cacheCredentials(url, authenticator); + authenticationManager->cacheCredentials(url, authenticator); } #ifndef QT_NO_NETWORKPROXY @@ -1157,10 +1056,10 @@ void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBac // possible solution: some tracking inside the authenticator // or a new function proxyAuthenticationSucceeded(true|false) if (proxy != backend->reply->lastProxyAuthentication) { - QNetworkAuthenticationCredential *cred = fetchCachedProxyCredentials(proxy); - if (cred) { - authenticator->setUser(cred->user); - authenticator->setPassword(cred->password); + QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedProxyCredentials(proxy); + if (!cred.isNull()) { + authenticator->setUser(cred.user); + authenticator->setPassword(cred.password); return; } } @@ -1172,75 +1071,7 @@ void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(QNetworkAccessBac backend->reply->lastProxyAuthentication = proxy; emit q->proxyAuthenticationRequired(proxy, authenticator); - cacheProxyCredentials(proxy, authenticator); -} - -void QNetworkAccessManagerPrivate::cacheProxyCredentials(const QNetworkProxy &p, - const QAuthenticator *authenticator) -{ - Q_ASSERT(authenticator); - Q_ASSERT(p.type() != QNetworkProxy::DefaultProxy); - Q_ASSERT(p.type() != QNetworkProxy::NoProxy); - - QString realm = authenticator->realm(); - QNetworkProxy proxy = p; - proxy.setUser(authenticator->user()); - // Set two credentials: one with the username and one without - do { - // Set two credentials actually: one with and one without the realm - do { - QByteArray cacheKey = proxyAuthenticationKey(proxy, realm); - if (cacheKey.isEmpty()) - return; // should not happen - - QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache; - auth->insert(QString(), authenticator->user(), authenticator->password()); - objectCache.addEntry(cacheKey, auth); // replace the existing one, if there's any - - if (realm.isEmpty()) { - break; - } else { - realm.clear(); - } - } while (true); - - if (proxy.user().isEmpty()) - break; - else - proxy.setUser(QString()); - } while (true); -} - -QNetworkAuthenticationCredential * -QNetworkAccessManagerPrivate::fetchCachedProxyCredentials(const QNetworkProxy &p, - const QAuthenticator *authenticator) -{ - QNetworkProxy proxy = p; - if (proxy.type() == QNetworkProxy::DefaultProxy) { - proxy = QNetworkProxy::applicationProxy(); - } - if (!proxy.password().isEmpty()) - return 0; // no need to set credentials if it already has them - - QString realm; - if (authenticator) - realm = authenticator->realm(); - - QByteArray cacheKey = proxyAuthenticationKey(proxy, realm); - if (cacheKey.isEmpty()) - return 0; - if (!objectCache.hasEntry(cacheKey)) - return 0; - - QNetworkAuthenticationCache *auth = - static_cast(objectCache.requestEntryNow(cacheKey)); - QNetworkAuthenticationCredential *cred = auth->findClosestMatch(QString()); - objectCache.releaseEntry(cacheKey); - - // proxy cache credentials always have exactly one item - Q_ASSERT_X(cred, "QNetworkAccessManager", - "Internal inconsistency: found a cache key for a proxy, but it's empty"); - return cred; + authenticationManager->cacheProxyCredentials(proxy, authenticator); } QList QNetworkAccessManagerPrivate::queryProxy(const QNetworkProxyQuery &query) @@ -1264,73 +1095,10 @@ QList QNetworkAccessManagerPrivate::queryProxy(const QNetworkProx } #endif -void QNetworkAccessManagerPrivate::cacheCredentials(const QUrl &url, - const QAuthenticator *authenticator) -{ - Q_ASSERT(authenticator); - QString domain = QString::fromLatin1("/"); // FIXME: make QAuthenticator return the domain - QString realm = authenticator->realm(); - - // Set two credentials actually: one with and one without the username in the URL - QUrl copy = url; - copy.setUserName(authenticator->user()); - do { - QByteArray cacheKey = authenticationKey(copy, realm); - if (objectCache.hasEntry(cacheKey)) { - QNetworkAuthenticationCache *auth = - static_cast(objectCache.requestEntryNow(cacheKey)); - auth->insert(domain, authenticator->user(), authenticator->password()); - objectCache.releaseEntry(cacheKey); - } else { - QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache; - auth->insert(domain, authenticator->user(), authenticator->password()); - objectCache.addEntry(cacheKey, auth); - } - - if (copy.userName().isEmpty()) { - break; - } else { - copy.setUserName(QString()); - } - } while (true); -} - -/*! - Fetch the credential data from the credential cache. - - If auth is 0 (as it is when called from createRequest()), this will try to - look up with an empty realm. That fails in most cases for HTTP (because the - realm is seldom empty for HTTP challenges). In any case, QHttpNetworkConnection - never sends the credentials on the first attempt: it needs to find out what - authentication methods the server supports. - - For FTP, realm is always empty. -*/ -QNetworkAuthenticationCredential * -QNetworkAccessManagerPrivate::fetchCachedCredentials(const QUrl &url, - const QAuthenticator *authentication) -{ - if (!url.password().isEmpty()) - return 0; // no need to set credentials if it already has them - - QString realm; - if (authentication) - realm = authentication->realm(); - - QByteArray cacheKey = authenticationKey(url, realm); - if (!objectCache.hasEntry(cacheKey)) - return 0; - - QNetworkAuthenticationCache *auth = - static_cast(objectCache.requestEntryNow(cacheKey)); - QNetworkAuthenticationCredential *cred = auth->findClosestMatch(url.path()); - objectCache.releaseEntry(cacheKey); - return cred; -} - void QNetworkAccessManagerPrivate::clearCache(QNetworkAccessManager *manager) { manager->d_func()->objectCache.clear(); + manager->d_func()->authenticationManager->clearCache(); } QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate() diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h index cf4d2f3..dba1fd2 100644 --- a/src/network/access/qnetworkaccessmanager_p.h +++ b/src/network/access/qnetworkaccessmanager_p.h @@ -59,6 +59,7 @@ #include "private/qobject_p.h" #include "QtNetwork/qnetworkproxy.h" #include "QtNetwork/qnetworksession.h" +#include "qnetworkaccessauthenticationmanager_p.h" QT_BEGIN_NAMESPACE @@ -81,7 +82,8 @@ public: online(false), initializeSession(true), #endif - cookieJarCreated(false) + cookieJarCreated(false), + authenticationManager(new QNetworkAccessAuthenticationManager) { } ~QNetworkAccessManagerPrivate(); @@ -137,6 +139,9 @@ public: bool cookieJarCreated; + // The cache with authorization data: + QNetworkAccessAuthenticationManager* authenticationManager; + // this cache can be used by individual backends to cache e.g. their TCP connections to a server // and use the connections for multiple requests. QNetworkAccessCache objectCache; -- cgit v0.12 From 4985369c26dd6397a8a5b51f6e53b6394efd8bf8 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 4 Feb 2011 14:26:33 +0100 Subject: QNAM: Delete old file Forgot to delete this file. Since 4.8 we use the QNetworkReplyDataImpl instead of a QNetworkAccessDataBackend --- src/network/access/qnetworkaccessdatabackend_p.h | 84 ------------------------ 1 file changed, 84 deletions(-) delete mode 100644 src/network/access/qnetworkaccessdatabackend_p.h diff --git a/src/network/access/qnetworkaccessdatabackend_p.h b/src/network/access/qnetworkaccessdatabackend_p.h deleted file mode 100644 index 18569ec..0000000 --- a/src/network/access/qnetworkaccessdatabackend_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QNETWORKACCESSDATABACKEND_P_H -#define QNETWORKACCESSDATABACKEND_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the Network Access API. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include "qnetworkaccessbackend_p.h" - -QT_BEGIN_NAMESPACE - -class QNetworkAccessDataBackend: public QNetworkAccessBackend -{ -public: - QNetworkAccessDataBackend(); - virtual ~QNetworkAccessDataBackend(); - - virtual void open(); - virtual void closeDownstreamChannel(); - virtual void closeUpstreamChannel(); - virtual bool waitForDownstreamReadyRead(int msecs); - virtual bool waitForUpstreamBytesWritten(int msecs); - - virtual bool processRequestSynchronously(); -}; - -class QNetworkAccessDataBackendFactory: public QNetworkAccessBackendFactory -{ -public: - virtual QNetworkAccessBackend *create(QNetworkAccessManager::Operation op, - const QNetworkRequest &request) const; -}; - -QT_END_NAMESPACE - -#endif -- cgit v0.12 From 59caa5b23104dd1c6fb368fbd840a6b491536130 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 18 Jan 2011 11:49:36 +0100 Subject: tst_qnetworkreply: Some additions --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index fd494c6..fd37ebd 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -342,6 +342,8 @@ private Q_SLOTS: void synchronousRequest(); void synchronousRequestSslFailure(); + void httpAbort(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); }; @@ -4566,7 +4568,7 @@ void tst_QNetworkReply::proxyChange() manager.setProxy(dummyProxy); QNetworkReplyPtr reply3 = manager.get(req); connect(reply3, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::instance().enterLoop(1); + QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(int(reply3->error()) > 0); @@ -5502,6 +5504,18 @@ void tst_QNetworkReply::synchronousRequestSslFailure() QCOMPARE(sslErrorsSpy.count(), 0); } +void tst_QNetworkReply::httpAbort() +{ + // FIXME: Implement a test that aborts a big HTTP reply + // a) after the first readyRead() + // b) immediatly after the get() + // c) after the finished() + // The goal is no crash and no irrelevant signals after the abort + + // FIXME Also implement one where we do a big upload and then abort(). + // It must not crash either. +} + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { -- cgit v0.12 From 5e59a2546f9dbbf58adb3a2169c3fffb58606d7e Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 22 Nov 2010 16:52:18 +0100 Subject: demo browser: Verbose output about Zerocopy usage --- demos/browser/networkaccessmanager.cpp | 9 +++++++-- demos/browser/networkaccessmanager.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/demos/browser/networkaccessmanager.cpp b/demos/browser/networkaccessmanager.cpp index 9e717bb..c63c0eb 100644 --- a/demos/browser/networkaccessmanager.cpp +++ b/demos/browser/networkaccessmanager.cpp @@ -64,7 +64,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) : QNetworkAccessManager(parent), requestFinishedCount(0), requestFinishedFromCacheCount(0), requestFinishedPipelinedCount(0), - requestFinishedSecureCount(0) + requestFinishedSecureCount(0), requestFinishedDownloadBufferCount(0) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); @@ -106,14 +106,19 @@ void NetworkAccessManager::requestFinished(QNetworkReply *reply) if (reply->attribute(QNetworkRequest::ConnectionEncryptedAttribute).toBool() == true) requestFinishedSecureCount++; + if (reply->attribute(QNetworkRequest::DownloadBufferAttribute).isValid() == true) + requestFinishedDownloadBufferCount++; + if (requestFinishedCount % 10) return; double pctCached = (double(requestFinishedFromCacheCount) * 100.0/ double(requestFinishedCount)); double pctPipelined = (double(requestFinishedPipelinedCount) * 100.0/ double(requestFinishedCount)); double pctSecure = (double(requestFinishedSecureCount) * 100.0/ double(requestFinishedCount)); + double pctDownloadBuffer = (double(requestFinishedDownloadBufferCount) * 100.0/ double(requestFinishedCount)); + #ifdef QT_DEBUG - qDebug("STATS [%lli requests total] [%3.2f%% from cache] [%3.2f%% pipelined] [%3.2f%% SSL/TLS]", requestFinishedCount, pctCached, pctPipelined, pctSecure); + qDebug("STATS [%lli requests total] [%3.2f%% from cache] [%3.2f%% pipelined] [%3.2f%% SSL/TLS] [%3.2f%% Zerocopy]", requestFinishedCount, pctCached, pctPipelined, pctSecure, pctDownloadBuffer); #endif } diff --git a/demos/browser/networkaccessmanager.h b/demos/browser/networkaccessmanager.h index 76fc198..d6e6ede 100644 --- a/demos/browser/networkaccessmanager.h +++ b/demos/browser/networkaccessmanager.h @@ -60,6 +60,7 @@ private: qint64 requestFinishedFromCacheCount; qint64 requestFinishedPipelinedCount; qint64 requestFinishedSecureCount; + qint64 requestFinishedDownloadBufferCount; public slots: void loadSettings(); -- cgit v0.12 From 7a98f1eac11fd449f93515ce59b74a6e1ebcc88b Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 7 Feb 2011 14:40:22 +0100 Subject: tst_qnetworkreply: Use proper test server hostname Reviewed-by: Martin Petersson --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index fd37ebd..3715162 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -5323,7 +5323,7 @@ void tst_QNetworkReply::qtbug13431replyThrottling() connect(&nam, SIGNAL(finished(QNetworkReply*)), &helper, SLOT(replyFinished(QNetworkReply*))); // Download a bigger file - QNetworkRequest netRequest(QUrl("http://qt-test-server/qtest/bigfile")); + QNetworkRequest netRequest(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile")); helper.m_reply = nam.get(netRequest); // Set the throttle helper.m_reply->setReadBufferSize(36000); -- cgit v0.12 From cce5cde471cb107924a31c91a05ca299f1668edb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 3 Feb 2011 17:15:27 +0100 Subject: Remove QThreadData::mutex which does not seem to be used. Reviewed-by: Brad --- src/corelib/thread/qthread_p.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 9a2dbec..36e07c0 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -209,8 +209,6 @@ public: bool canWait; QVector tls; - QMutex mutex; - # ifdef Q_OS_SYMBIAN RThread symbian_thread_handle; # endif -- cgit v0.12 From a77ab4c4dd3c0d9c5cf71afc4d3efcc76a068430 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 4 Feb 2011 10:00:35 +0100 Subject: Fix race condition between QEventLoop::exec and QThread::exit As also mentioned in QTBUG-16692 Reviewed-by: brad Task-number: QTBUG-17257 --- src/corelib/kernel/qeventloop.cpp | 5 +++++ src/corelib/thread/qthread_unix.cpp | 5 ++++- src/corelib/thread/qthread_win.cpp | 5 ++++- tests/auto/qthread/tst_qthread.cpp | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index e78f86a..d213b0e 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -175,6 +175,8 @@ bool QEventLoop::processEvents(ProcessEventsFlags flags) int QEventLoop::exec(ProcessEventsFlags flags) { Q_D(QEventLoop); + //we need to protect from race condition with QThread::exit + QMutexLocker locker(&static_cast(QObjectPrivate::get(d->threadData->thread))->mutex); if (d->threadData->quitNow) return -1; @@ -186,6 +188,7 @@ int QEventLoop::exec(ProcessEventsFlags flags) d->exit = false; ++d->threadData->loopLevel; d->threadData->eventLoops.push(this); + locker.unlock(); // remove posted quit events when entering a new event loop QCoreApplication *app = QCoreApplication::instance(); @@ -205,6 +208,7 @@ int QEventLoop::exec(ProcessEventsFlags flags) "reimplement QApplication::notify() and catch all exceptions there.\n"); // copied from below + locker.relock(); QEventLoop *eventLoop = d->threadData->eventLoops.pop(); Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error"); Q_UNUSED(eventLoop); // --release warning @@ -216,6 +220,7 @@ int QEventLoop::exec(ProcessEventsFlags flags) #endif // copied above + locker.relock(); QEventLoop *eventLoop = d->threadData->eventLoops.pop(); Q_ASSERT_X(eventLoop == this, "QEventLoop::exec()", "internal error"); Q_UNUSED(eventLoop); // --release warning diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 891ac77..5e0d2a2 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -327,7 +327,10 @@ void *QThreadPrivate::start(void *arg) set_thread_data(data); data->ref(); - data->quitNow = false; + { + QMutexLocker locker(&thr->d_func()->mutex); + data->quitNow = thr->d_func()->exited; + } // ### TODO: allow the user to create a custom event dispatcher createEventDispatcher(data); diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index cb2d1a9..f2d1310 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -298,7 +298,10 @@ unsigned int __stdcall QThreadPrivate::start(void *arg) QThread::setTerminationEnabled(false); - data->quitNow = false; + { + QMutexLocker locker(&thr->d_func()->mutex); + data->quitNow = !thr->d_func()->exited; + } // ### TODO: allow the user to create a custom event dispatcher createEventDispatcher(data); diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp index 19c6c16..c69052e 100644 --- a/tests/auto/qthread/tst_qthread.cpp +++ b/tests/auto/qthread/tst_qthread.cpp @@ -113,6 +113,7 @@ private slots: void wait3_slowDestructor(); void destroyFinishRace(); void startFinishRace(); + void startAndQuitCustomEventLoop(); void stressTest(); }; @@ -1150,5 +1151,20 @@ void tst_QThread::startFinishRace() } } +void tst_QThread::startAndQuitCustomEventLoop() +{ + struct Thread : QThread { + void run() { QEventLoop().exec(); } + }; + + for (int i = 0; i < 5; i++) { + Thread t; + t.start(); + t.quit(); + t.wait(); + } +} + + QTEST_MAIN(tst_QThread) #include "tst_qthread.moc" -- cgit v0.12 From dce6cb12d22d7356fc2d45fd81f2797f9ae44190 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 7 Feb 2011 12:57:01 +0100 Subject: QMutex: do not use inline mutex in debug. Debugger tools (such as valgrind) hooks into QMutex::lock and QMutex::unlock. So we should continue to call this function if we want to keep those tools working Reviewed-by: brad --- src/corelib/thread/qmutex.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index dfe4aae..5f75195 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -163,6 +163,7 @@ class QMutexData ~QMutexData(); }; +#ifdef QT_NO_DEBUG inline void QMutex::unlockInline() { if (d->recursive) { @@ -189,7 +190,13 @@ inline void QMutex::lockInline() lockInternal(); } } - +#else // QT_NO_DEBUG +//in debug we do not use inline calls in order to allow debugging tools +// to hook the mutex locking functions. +inline void QMutex::unlockInline() { unlock(); } +inline bool QMutex::tryLockInline() { return tryLock(); } +inline void QMutex::lockInline() { lock(); } +#endif // QT_NO_DEBUG #else // QT_NO_THREAD -- cgit v0.12 From ae25e6be41aaba90507022d792e2defcaf4cbfb6 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 7 Feb 2011 16:42:35 +0100 Subject: Removed obsolete code that was incorrectly handling ConfigureNotify The code in question was calling XSync and then processing ConfigureNotify requests, but only using the width/height information from the event, while ignoring the x,y properties. The code was consuming synthetic ConfigureNotify with x,y in root coordinate system that we are supposed to receive from the window manager, which broke mapFromGlobal/mapToGlobal behavior (after cdd776a91e65bf5c30cea1bab9823134a3f797d0) Reviewed-by: Olivier Goffart --- src/gui/kernel/qapplication_x11.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 2c51722..823f1b1 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -5314,18 +5314,6 @@ bool QETWidget::translateConfigEvent(const XEvent *event) } if (wasResize) { - static bool slowResize = qgetenv("QT_SLOW_TOPLEVEL_RESIZE").toInt(); - if (d->extra->compress_events && !slowResize && !data->in_show && isVisible()) { - QApplication::syncX(); - XEvent otherEvent; - while (XCheckTypedWindowEvent(X11->display, internalWinId(), ConfigureNotify, &otherEvent) - && !qt_x11EventFilter(&otherEvent) && !x11Event(&otherEvent) - && otherEvent.xconfigure.event == otherEvent.xconfigure.window) { - data->crect.setWidth(otherEvent.xconfigure.width); - data->crect.setHeight(otherEvent.xconfigure.height); - } - } - if (isVisible() && data->crect.size() != oldSize) { Q_ASSERT(d->extra->topextra); QWidgetBackingStore *bs = d->extra->topextra->backingStore.data(); @@ -5334,7 +5322,7 @@ bool QETWidget::translateConfigEvent(const XEvent *event) // resize optimization in order to get invalidated regions for resized widgets. // The optimization discards all invalidateBuffer() calls since we're going to // repaint everything anyways, but that's not the case with static contents. - if (!slowResize && !hasStaticContents) + if (!hasStaticContents) d->extra->topextra->inTopLevelResize = true; QResizeEvent e(data->crect.size(), oldSize); QApplication::sendSpontaneousEvent(this, &e); -- cgit v0.12 From ed4c28b08412211bf547340a05ca4bd987b4fbf7 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 4 Feb 2011 15:42:02 +0100 Subject: Fixed mapFromGlobal in some window managers on X11 The previous mapFromGlobal optimization in cdd776a91e65bf5c30cea1bab9823134a3f797d0 broke behavior in some window managers like metacity when resizing by dragging the top-left corner. Most likely it is a bad behaviour of the window manager (according to ICCCM 4.1.5 we should get a ConfigureNotify event with x and y in root coordinates if you consider this is a "movement" of a window). Reviewed-by: Olivier Goffart --- src/gui/kernel/qapplication_x11.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 823f1b1..2fdad8d 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -5227,14 +5227,15 @@ bool QETWidget::translateConfigEvent(const XEvent *event) bool trust = isVisible() && (d->topData()->parentWinId == XNone || d->topData()->parentWinId == QX11Info::appRootWindow()); + bool isCPos = false; if (event->xconfigure.send_event || trust) { // if a ConfigureNotify comes from a real sendevent request, we can // trust its values. newCPos.rx() = event->xconfigure.x + event->xconfigure.border_width; newCPos.ry() = event->xconfigure.y + event->xconfigure.border_width; + isCPos = true; } - if (isVisible()) QApplication::syncX(); @@ -5260,6 +5261,7 @@ bool QETWidget::translateConfigEvent(const XEvent *event) otherEvent.xconfigure.border_width; newCPos.ry() = otherEvent.xconfigure.y + otherEvent.xconfigure.border_width; + isCPos = true; } } #ifndef QT_NO_XSYNC @@ -5272,6 +5274,19 @@ bool QETWidget::translateConfigEvent(const XEvent *event) #endif // QT_NO_XSYNC } + if (!isCPos) { + // we didn't get an updated position of the toplevel. + // either we haven't moved or there is a bug in the window manager. + // anyway, let's query the position to be certain. + int x, y; + Window child; + XTranslateCoordinates(X11->display, internalWinId(), + QApplication::desktop()->screen(d->xinfo.screen())->internalWinId(), + 0, 0, &x, &y, &child); + newCPos.rx() = x; + newCPos.ry() = y; + } + QRect cr (geometry()); if (newCPos != cr.topLeft()) { // compare with cpos (exluding frame) QPoint oldPos = geometry().topLeft(); -- cgit v0.12 From 7e35a1f70b69eab892216edd551bf50fecd352f5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Feb 2011 11:57:51 +0100 Subject: Fix warning, unused parametter error Use the Function not implemented error Reviewed-by: Joao --- src/corelib/io/qfilesystemengine_unix.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 8b88ffd..030be1b 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -534,8 +534,7 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst { Q_UNUSED(source); Q_UNUSED(target); - // # we can implement this using sendfile(2) - //when this function returns false, block copy is used in QFile which sets the error code. + error = QSystemError(ENOSYS, QSystemError::StandardLibraryError); //Function not implemented return false; } -- cgit v0.12 From 877da0d056d0b0c078d07165be11a1ffca4730ea Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 8 Feb 2011 17:08:04 +0100 Subject: Fix reversed condition Introduced in my previous fix for QTBUG-17257 --- src/corelib/thread/qthread_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index f2d1310..6b7932b 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -300,7 +300,7 @@ unsigned int __stdcall QThreadPrivate::start(void *arg) { QMutexLocker locker(&thr->d_func()->mutex); - data->quitNow = !thr->d_func()->exited; + data->quitNow = thr->d_func()->exited; } // ### TODO: allow the user to create a custom event dispatcher createEventDispatcher(data); -- cgit v0.12 From 4f7a73a8281623e3d41e527924fe9c0ffd9977e1 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 8 Feb 2011 16:05:53 +0000 Subject: Workaround public header depending on private in symbian^3 f32file.h (public) depends on e32svr.h (private), and in symbian^3 the private headers have been moved to a different include path. Reviewed-by: axis --- mkspecs/features/qt_functions.prf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index f1c3e13..1fb6298 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -46,7 +46,12 @@ defineTest(qtAddLibrary) { } } symbian { - isEqual(LIB_NAME, QtGui) { + isEqual(LIB_NAME, QtCore) { + #workaround for dependency from f32file.h on e32svr.h which has moved location in symbian3 + contains(SYMBIAN_VERSION, Symbian3) { + INCLUDEPATH *= $$OS_LAYER_SYSTEMINCLUDE + } + } else:isEqual(LIB_NAME, QtGui) { # Needed for #include because qs60mainapplication.h includes aknapp.h INCLUDEPATH *= $$MW_LAYER_SYSTEMINCLUDE } else:isEqual(LIB_NAME, QtWebKit) { -- cgit v0.12 From 01f5c74b8ecddfc192895ccb85c1627467bb6ff5 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 08:10:14 +0000 Subject: Generating QFileOpenEvent messages when S60 UI receives OpenFileL S60 applications can receive OpenFileL requests from other apps in the OpenFileL method of their main document class. This S60 main document class is internal to QtGui, so the request is turned into a QFileOpenEvent for the application to pick up if it want to implenment this service. If an application wants to receive the QFileOpenEvent before UI construction, it should do something like: app->sendPostedEvents(app, QEvent::FileOpen); Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/s60framework/qs60mainappui.cpp | 10 ++++++++++ src/gui/s60framework/qs60mainappui.h | 1 + src/gui/s60framework/qs60maindocument.cpp | 20 +++++++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index b5b8b81..454f90d 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -49,6 +49,7 @@ #include #endif #include +#include #include #include "qs60mainappui.h" @@ -401,6 +402,15 @@ void QS60MainAppUi::HandleForegroundEventL(TBool aForeground) QS60MainAppUiBase::HandleForegroundEventL(aForeground); } +/*! + \internal +*/ +TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &aDocumentName, const TDesC8 &/*aTail*/) +{ + // bypass CEikAppUi::ProcessCommandParametersL(..) which modifies aDocumentName, preventing apparc document opening from working. + return ConeUtils::FileExists(aDocumentName); +} + #ifndef Q_WS_S60 void QS60StubAknAppUi::HandleViewDeactivation(const TVwsViewId &, const TVwsViewId &) {} diff --git a/src/gui/s60framework/qs60mainappui.h b/src/gui/s60framework/qs60mainappui.h index ce3b5b0..bf118ff 100644 --- a/src/gui/s60framework/qs60mainappui.h +++ b/src/gui/s60framework/qs60mainappui.h @@ -131,6 +131,7 @@ public: virtual void HandleViewDeactivation(const TVwsViewId &aViewIdToBeDeactivated, const TVwsViewId &aNewlyActivatedViewId); virtual void PrepareToExit(); virtual void HandleTouchPaneSizeChange(); + virtual TBool ProcessCommandParametersL(TApaCommand aCommand, TFileName &aDocumentName, const TDesC8 &aTail); protected: virtual void HandleScreenDeviceChangedL(); diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index a8886ac..071aa5b 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -41,6 +41,8 @@ #include "qs60mainappui.h" #include "qs60maindocument.h" +#include "qcoreapplication.h" +#include "qevent.h" #include @@ -108,9 +110,15 @@ CEikAppUi *QS60MainDocument::CreateAppUiL() /*! \internal */ -CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, RFs &aFs) +CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, RFs &/*aFs*/) { - return QS60MainDocumentBase::OpenFileL(aDoOpen, aFilename, aFs); + if (aDoOpen) { + QCoreApplication* app = QCoreApplication::instance(); + QString qname((QChar*)aFilename.Ptr(), aFilename.Length()); + QFileOpenEvent* event = new QFileOpenEvent(qname); + app->postEvent(app, event); + } + return 0; } /*! @@ -118,7 +126,13 @@ CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, R */ void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) { - QS60MainDocumentBase::OpenFileL(aFileStore, aFile); + QCoreApplication* app = QCoreApplication::instance(); + TFileName name; + aFile.FullName(name); + QString qname((QChar*)name.Ptr(), name.Length()); + QFileOpenEvent* event = new QFileOpenEvent(qname); + app->postEvent(app, event); + aFileStore = 0; } QT_END_NAMESPACE -- cgit v0.12 From edcaa583aa9232f48c92d7c78a7b3e6c71212bc1 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 10:40:44 +0000 Subject: used official descriptor to QString conversion The OpenFileL code now uses qt_TDesC2QString to convert from the TFileName to a QString. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/s60framework/qs60maindocument.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index 071aa5b..95effbc 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -43,6 +43,7 @@ #include "qs60maindocument.h" #include "qcoreapplication.h" #include "qevent.h" +#include "private/qcore_symbian_p.h" #include @@ -114,7 +115,7 @@ CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, R { if (aDoOpen) { QCoreApplication* app = QCoreApplication::instance(); - QString qname((QChar*)aFilename.Ptr(), aFilename.Length()); + QString qname = qt_TDesC2QString(aFilename); QFileOpenEvent* event = new QFileOpenEvent(qname); app->postEvent(app, event); } @@ -129,7 +130,7 @@ void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) QCoreApplication* app = QCoreApplication::instance(); TFileName name; aFile.FullName(name); - QString qname((QChar*)name.Ptr(), name.Length()); + QString qname = qt_TDesC2QString(name); QFileOpenEvent* event = new QFileOpenEvent(qname); app->postEvent(app, event); aFileStore = 0; -- cgit v0.12 From 776a9aeaa8006e789d3f956250876867c350a209 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 13:23:38 +0000 Subject: Added a file handle to QFileOpenEvent on Symbian QFileOpenEvent needs to tell the recipient what file to open. Normally that is by filename. But on Symbian, some files can only be opened from an already-open file handle that has been passed in. For example data caged files in c:\private or z:\sys. So QFileOpenEvent needs to be able to hold a Symbian file handle so that the recipient can access any file requested of it. Coming soon... a method by which the reciever can access the file without knowing about all this messy file handle stuff going on behind the scenes. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.cpp | 28 ++++++++++++++++++++++++++-- src/gui/kernel/qevent.h | 7 +++++++ src/gui/kernel/qevent_p.h | 7 +++++++ src/gui/s60framework/qs60maindocument.cpp | 17 ++++++----------- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index e7abb47..f7bc54c 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -53,6 +53,10 @@ #include "qgesture.h" #include "qgesture_p.h" +#ifdef Q_OS_SYMBIAN +#include "private/qcore_symbian_p.h" +#endif + QT_BEGIN_NAMESPACE /*! @@ -3023,7 +3027,7 @@ QShowEvent::~QShowEvent() This event is only used to notify the application of a request. It may be safely ignored. - \note This class is currently supported for Mac OS X only. + \note This class is currently supported for Mac OS X and Symbian only. */ /*! @@ -3049,11 +3053,31 @@ QFileOpenEvent::QFileOpenEvent(const QUrl &url) f = url.toLocalFile(); } +#ifdef Q_OS_SYMBIAN +/*! \internal +*/ +QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle) + : QEvent(FileOpen) +{ + TFileName fullName; + fileHandle.FullName(fullName); + QString file = qt_TDesC2QString(fullName); + f = file; + QScopedPointer priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(file))); + qt_symbian_throwIfError(priv->file.Duplicate(fileHandle)); + d = reinterpret_cast(priv.take()); +} +#endif + /*! \internal */ QFileOpenEvent::~QFileOpenEvent() { - delete reinterpret_cast(d); + QFileOpenEventPrivate *priv = reinterpret_cast(d); +#ifdef Q_OS_SYMBIAN + priv->file.Close(); +#endif + delete priv; } /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index a7b06f4..2f5c486 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -55,6 +55,10 @@ #include #include +#ifdef Q_OS_SYMBIAN +class RFile; +#endif + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -641,6 +645,9 @@ class Q_GUI_EXPORT QFileOpenEvent : public QEvent public: QFileOpenEvent(const QString &file); QFileOpenEvent(const QUrl &url); +#ifdef Q_OS_SYMBIAN + QFileOpenEvent(const RFile &fileHandle); +#endif ~QFileOpenEvent(); inline QString file() const { return f; } diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 3a27023..01af384 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -46,6 +46,10 @@ #include #include +#ifdef Q_OS_SYMBIAN +#include +#endif + QT_BEGIN_NAMESPACE // @@ -176,6 +180,9 @@ public: } QUrl url; +#ifdef Q_OS_SYMBIAN + RFile file; +#endif }; diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index 95effbc..eafbcb0 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -111,14 +111,12 @@ CEikAppUi *QS60MainDocument::CreateAppUiL() /*! \internal */ -CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, RFs &/*aFs*/) +CFileStore *QS60MainDocument::OpenFileL(TBool /*aDoOpen*/, const TDesC &aFilename, RFs &/*aFs*/) { - if (aDoOpen) { - QCoreApplication* app = QCoreApplication::instance(); - QString qname = qt_TDesC2QString(aFilename); - QFileOpenEvent* event = new QFileOpenEvent(qname); - app->postEvent(app, event); - } + QCoreApplication* app = QCoreApplication::instance(); + QString qname = qt_TDesC2QString(aFilename); + QFileOpenEvent* event = new QFileOpenEvent(qname); + app->postEvent(app, event); return 0; } @@ -128,10 +126,7 @@ CFileStore *QS60MainDocument::OpenFileL(TBool aDoOpen, const TDesC &aFilename, R void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) { QCoreApplication* app = QCoreApplication::instance(); - TFileName name; - aFile.FullName(name); - QString qname = qt_TDesC2QString(name); - QFileOpenEvent* event = new QFileOpenEvent(qname); + QFileOpenEvent* event = new QFileOpenEvent(aFile); app->postEvent(app, event); aFileStore = 0; } -- cgit v0.12 From 5f5e67e39bfc073d65857f6edae1df0db8507edd Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 16:01:58 +0000 Subject: added an openFile method to QFileOpenEvent An application needs some way to get an open QFile when a QFileOpenEvent contains a Symbian file handle. Rather than exposing that file handle and forcing platform specific code to the application, this method hides the details giving an effective universal method for turning a QFileOpenEvent into an open QFile. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.cpp | 14 ++++++++++++++ src/gui/kernel/qevent.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f7bc54c..8a67b91 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3098,6 +3098,20 @@ QUrl QFileOpenEvent::url() const return reinterpret_cast(d)->url; } +void QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const +{ + file.setFileName(f); +#ifdef Q_OS_SYMBIAN + const QFileOpenEventPrivate *priv = reinterpret_cast(d); + if (priv->file.SubSessionHandle()) { + // TODO return a QFile opened from the file handle + file.open(flags); + return; + } +#endif + file.open(flags); +} + #ifndef QT_NO_TOOLBAR /*! \internal diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 2f5c486..0499a6d 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -54,6 +54,7 @@ #include #include #include +#include #ifdef Q_OS_SYMBIAN class RFile; @@ -652,6 +653,7 @@ public: inline QString file() const { return f; } QUrl url() const; + void openFile(QFile &file, QIODevice::OpenMode flags) const; private: QString f; }; -- cgit v0.12 From 6b452ea0757414965fa00bfb7285f7d687c9c8d0 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 9 Nov 2010 13:02:56 +0000 Subject: documentation for QFileOpenEvent::openFile Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 8a67b91..8f2e6cb 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3098,6 +3098,17 @@ QUrl QFileOpenEvent::url() const return reinterpret_cast(d)->url; } +/*! + \fn void openFile(QFile &file, QIODevice::OpenMode flags) const + + Opens a QFile on the file referenced by this event. + This is necessary as some files cannot be opened with the filename alone, but require specific + information stored in this event. + For example, if this QFileOpenEvent contains a request to open a Symbian data caged file, + this function must be used to open a QFile on it. + + \since 4.8 +*/ void QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const { file.setFileName(f); -- cgit v0.12 From 7322556ec759d25ead3d0ba26ebd44a82a574872 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 08:10:14 +0000 Subject: Generating QFileOpenEvent messages when S60 UI receives OpenFileL S60 applications can receive OpenFileL requests from other apps in the OpenFileL method of their main document class. This S60 main document class is internal to QtGui, so the request is turned into a QFileOpenEvent for the application to pick up if it want to implenment this service. If an application wants to receive the QFileOpenEvent before UI construction, it should do something like: app->sendPostedEvents(app, QEvent::FileOpen); Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/s60framework/qs60maindocument.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index eafbcb0..7114735 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -127,8 +127,10 @@ void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) { QCoreApplication* app = QCoreApplication::instance(); QFileOpenEvent* event = new QFileOpenEvent(aFile); - app->postEvent(app, event); - aFileStore = 0; + TFileName name; + aFile.FullName(name); + QString qname((QChar*)name.Ptr(), name.Length()); + QFileOpenEvent* event = new QFileOpenEvent(qname); } QT_END_NAMESPACE -- cgit v0.12 From 713eed0b830dc11c69adab3bc5a9b1b6b3814a18 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 10:40:44 +0000 Subject: used official descriptor to QString conversion The OpenFileL code now uses qt_TDesC2QString to convert from the TFileName to a QString. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/s60framework/qs60maindocument.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index 7114735..51a6ac9 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -129,7 +129,7 @@ void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) QFileOpenEvent* event = new QFileOpenEvent(aFile); TFileName name; aFile.FullName(name); - QString qname((QChar*)name.Ptr(), name.Length()); + QString qname = qt_TDesC2QString(name); QFileOpenEvent* event = new QFileOpenEvent(qname); } -- cgit v0.12 From 977638104d091dd8780f4d1bee79bf014d6a2fe9 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 5 Nov 2010 13:23:38 +0000 Subject: Added a file handle to QFileOpenEvent on Symbian QFileOpenEvent needs to tell the recipient what file to open. Normally that is by filename. But on Symbian, some files can only be opened from an already-open file handle that has been passed in. For example data caged files in c:\private or z:\sys. So QFileOpenEvent needs to be able to hold a Symbian file handle so that the recipient can access any file requested of it. Coming soon... a method by which the reciever can access the file without knowing about all this messy file handle stuff going on behind the scenes. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.h | 4 ++++ src/gui/s60framework/qs60maindocument.cpp | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 0499a6d..88a7a8a 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -60,6 +60,10 @@ class RFile; #endif +#ifdef Q_OS_SYMBIAN +class RFile; +#endif + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index 51a6ac9..d53aac1 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -127,10 +127,6 @@ void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) { QCoreApplication* app = QCoreApplication::instance(); QFileOpenEvent* event = new QFileOpenEvent(aFile); - TFileName name; - aFile.FullName(name); - QString qname = qt_TDesC2QString(name); - QFileOpenEvent* event = new QFileOpenEvent(qname); } QT_END_NAMESPACE -- cgit v0.12 From f29b95cef0441958050c86d3544cdfde32e9e62e Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 7 Jan 2011 11:07:08 +0000 Subject: Using QFile open by RFile and take ownership of handle QFileOpenEvent's open method now opens the QFile with an RFile handle if possible. It takes a duplicate of the handle and transfers ownership to the QFile, so that the QFile can be used many times and outside of the lifetime of the QFileOpenEvent. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/corelib/kernel/qcore_symbian_p.h | 16 ++++++++++++++++ src/gui/kernel/qevent.cpp | 18 ++++++++++++------ src/gui/kernel/qevent.h | 2 +- src/gui/s60framework/qs60maindocument.cpp | 18 ++++++++++++------ src/s60installs/bwins/QtGuiu.def | 4 +++- src/s60installs/eabi/QtGuiu.def | 8 ++++---- 6 files changed, 48 insertions(+), 18 deletions(-) diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h index 3ef71e0..5b48689 100644 --- a/src/corelib/kernel/qcore_symbian_p.h +++ b/src/corelib/kernel/qcore_symbian_p.h @@ -158,6 +158,22 @@ Q_CORE_EXPORT RFs& qt_s60GetRFs(); // Defined in qlocale_symbian.cpp. Q_CORE_EXPORT QByteArray qt_symbianLocaleName(int code); +template +struct QScopedPointerRCloser +{ + static inline void cleanup(R *rPointer) + { + // Enforce a complete type. + // If you get a compile error here, read the section on forward declared + // classes in the QScopedPointer documentation. + typedef char IsIncompleteType[ sizeof(R) ? 1 : -1 ]; + (void) sizeof(IsIncompleteType); + + if (rPointer) + rPointer->Close(); + } +}; + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 8f2e6cb..17bcbfb 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3099,9 +3099,11 @@ QUrl QFileOpenEvent::url() const } /*! - \fn void openFile(QFile &file, QIODevice::OpenMode flags) const + \fn bool openFile(QFile &file, QIODevice::OpenMode flags) const Opens a QFile on the file referenced by this event. + Returns true if successful; otherwise returns false. + This is necessary as some files cannot be opened with the filename alone, but require specific information stored in this event. For example, if this QFileOpenEvent contains a request to open a Symbian data caged file, @@ -3109,18 +3111,22 @@ QUrl QFileOpenEvent::url() const \since 4.8 */ -void QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const +bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const { file.setFileName(f); #ifdef Q_OS_SYMBIAN const QFileOpenEventPrivate *priv = reinterpret_cast(d); if (priv->file.SubSessionHandle()) { - // TODO return a QFile opened from the file handle - file.open(flags); - return; + RFile dup; + if (dup.Duplicate(priv->file) == KErrNone) { + QScopedPointer > dupCloser(&dup); + bool open = file.open(dup, flags, QFile::AutoCloseHandle); + dupCloser.take(); + return open; + } } #endif - file.open(flags); + return file.open(flags); } #ifndef QT_NO_TOOLBAR diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 88a7a8a..997ac0c 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -657,7 +657,7 @@ public: inline QString file() const { return f; } QUrl url() const; - void openFile(QFile &file, QIODevice::OpenMode flags) const; + bool openFile(QFile &file, QIODevice::OpenMode flags) const; private: QString f; }; diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/gui/s60framework/qs60maindocument.cpp index d53aac1..37bd55f 100644 --- a/src/gui/s60framework/qs60maindocument.cpp +++ b/src/gui/s60framework/qs60maindocument.cpp @@ -113,10 +113,12 @@ CEikAppUi *QS60MainDocument::CreateAppUiL() */ CFileStore *QS60MainDocument::OpenFileL(TBool /*aDoOpen*/, const TDesC &aFilename, RFs &/*aFs*/) { - QCoreApplication* app = QCoreApplication::instance(); - QString qname = qt_TDesC2QString(aFilename); - QFileOpenEvent* event = new QFileOpenEvent(qname); - app->postEvent(app, event); + QT_TRYCATCH_LEAVING( { + QCoreApplication* app = QCoreApplication::instance(); + QString qname = qt_TDesC2QString(aFilename); + QFileOpenEvent* event = new QFileOpenEvent(qname); + app->postEvent(app, event); + }) return 0; } @@ -125,8 +127,12 @@ CFileStore *QS60MainDocument::OpenFileL(TBool /*aDoOpen*/, const TDesC &aFilenam */ void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) { - QCoreApplication* app = QCoreApplication::instance(); - QFileOpenEvent* event = new QFileOpenEvent(aFile); + QT_TRYCATCH_LEAVING( { + QCoreApplication* app = QCoreApplication::instance(); + QFileOpenEvent* event = new QFileOpenEvent(aFile); + app->postEvent(app, event); + aFileStore = 0; + }) } QT_END_NAMESPACE diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 322d88b..9475728 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -13142,4 +13142,6 @@ EXPORTS ?viewportSize@QScrollPrepareEvent@@QBE?AVQSizeF@@XZ @ 13141 NONAME ; class QSizeF QScrollPrepareEvent::viewportSize(void) const ?staticMetaObject@QScroller@@2UQMetaObject@@B @ 13142 NONAME ; struct QMetaObject const QScroller::staticMetaObject ?staticMetaObject@QFlickGesture@@2UQMetaObject@@B @ 13143 NONAME ; struct QMetaObject const QFlickGesture::staticMetaObject - + ?ProcessCommandParametersL@QS60MainAppUi@@UAEHW4TApaCommand@@AAV?$TBuf@$0BAA@@@ABVTDesC8@@@Z @ 13144 NONAME ; int QS60MainAppUi::ProcessCommandParametersL(enum TApaCommand, class TBuf<256> &, class TDesC8 const &) + ?openFile@QFileOpenEvent@@QBE_NAAVQFile@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z @ 13145 NONAME ; bool QFileOpenEvent::openFile(class QFile &, class QFlags) const + ??0QFileOpenEvent@@QAE@ABVRFile@@@Z @ 13146 NONAME ; QFileOpenEvent::QFileOpenEvent(class RFile const &) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 8064fa3..a4937a7 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12227,10 +12227,10 @@ EXPORTS _ZTV19QBlitterPaintEngine @ 12226 NONAME _ZTV20QBlittablePixmapData @ 12227 NONAME _Zls6QDebugPK13QSymbianEvent @ 12228 NONAME - _ZN13QS60MainAppUi25ProcessCommandParametersLE11TApaCommandR4TBufILi256EERK6TDesC8 @ 12229 NONAME ABSENT - _ZN14QFileOpenEventC1ERK5RFile @ 12230 NONAME ABSENT - _ZN14QFileOpenEventC2ERK5RFile @ 12231 NONAME ABSENT - _ZNK14QFileOpenEvent8openFileER5QFile6QFlagsIN9QIODevice12OpenModeFlagEE @ 12232 NONAME ABSENT + _ZN13QS60MainAppUi25ProcessCommandParametersLE11TApaCommandR4TBufILi256EERK6TDesC8 @ 12229 NONAME + _ZN14QFileOpenEventC1ERK5RFile @ 12230 NONAME + _ZN14QFileOpenEventC2ERK5RFile @ 12231 NONAME + _ZNK14QFileOpenEvent8openFileER5QFile6QFlagsIN9QIODevice12OpenModeFlagEE @ 12232 NONAME _ZN11QFontEngine16alphaMapForGlyphEj6QFixed @ 12233 NONAME _ZN11QFontEngine16alphaMapForGlyphEj6QFixedRK10QTransform @ 12234 NONAME _Z32qGamma_correct_back_to_linear_csP6QImage @ 12235 NONAME -- cgit v0.12 From b93dc7717a9d19fef4c9a27145c5fbf0cd68ba81 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 7 Jan 2011 11:29:29 +0000 Subject: Fixed a trailing whitespace Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 17bcbfb..f6f2694 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3103,7 +3103,7 @@ QUrl QFileOpenEvent::url() const Opens a QFile on the file referenced by this event. Returns true if successful; otherwise returns false. - + This is necessary as some files cannot be opened with the filename alone, but require specific information stored in this event. For example, if this QFileOpenEvent contains a request to open a Symbian data caged file, -- cgit v0.12 From 82f3b68a555df557529e8dce5396f1de8242d2d3 Mon Sep 17 00:00:00 2001 From: mread Date: Mon, 10 Jan 2011 16:44:29 +0000 Subject: removed double forward declaration Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 997ac0c..93c2bc5 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -60,10 +60,6 @@ class RFile; #endif -#ifdef Q_OS_SYMBIAN -class RFile; -#endif - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -- cgit v0.12 From f274fac046b041a1d07d935ded50874c501e61fe Mon Sep 17 00:00:00 2001 From: mread Date: Mon, 10 Jan 2011 16:57:47 +0000 Subject: Started a QFileOpenEvent test for Symbian This is an autotest for QFileOpenEvent. Actually it's more generic than just Symbian. So maybe it will move out of the Symbian specific directory in the future. This autotest is not complete yet. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- .../auto/symbian/qfileopenevent/qfileopenevent.pro | 6 + .../symbian/qfileopenevent/tst_qfileopenevent.cpp | 188 +++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 tests/auto/symbian/qfileopenevent/qfileopenevent.pro create mode 100644 tests/auto/symbian/qfileopenevent/tst_qfileopenevent.cpp diff --git a/tests/auto/symbian/qfileopenevent/qfileopenevent.pro b/tests/auto/symbian/qfileopenevent/qfileopenevent.pro new file mode 100644 index 0000000..e2bc537 --- /dev/null +++ b/tests/auto/symbian/qfileopenevent/qfileopenevent.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +HEADERS += +SOURCES += tst_qfileopenevent.cpp +symbian { + LIBS+=-lefsrv +} diff --git a/tests/auto/symbian/qfileopenevent/tst_qfileopenevent.cpp b/tests/auto/symbian/qfileopenevent/tst_qfileopenevent.cpp new file mode 100644 index 0000000..85ec04d --- /dev/null +++ b/tests/auto/symbian/qfileopenevent/tst_qfileopenevent.cpp @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#ifdef Q_OS_SYMBIAN + +class tst_qfileopenevent : public QObject +{ + Q_OBJECT +public: + tst_qfileopenevent(){} + ~tst_qfileopenevent(); + +public slots: + void initTestCase(); + +private slots: + void constructor(); + void fileOpen(); + void handleLifetime(); + void multiOpen(); + void sendAndReceive(); + void viaApparc(); + void viasDocHandler(); + +private: + RFile createRFile(const TDesC& filename, const TDesC8& content); + void checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk); + QString readFileContent(QFileOpenEvent& event); + bool appendFileContent(QFileOpenEvent& event, const QString& writeContent); + +private: + RFs fsSession; +}; + +tst_qfileopenevent::~tst_qfileopenevent() +{ + fsSession.Close(); +}; + +void tst_qfileopenevent::initTestCase() +{ + qt_symbian_throwIfError(fsSession.Connect()); +} + +RFile tst_qfileopenevent::createRFile(const TDesC& filename, const TDesC8& content) +{ + RFile file; + qt_symbian_throwIfError(file.Replace(fsSession, filename, EFileWrite)); + qt_symbian_throwIfError(file.Write(content)); + return file; +} + +void tst_qfileopenevent::constructor() +{ + // check that filename get/set works + QFileOpenEvent nameTest(QLatin1String("fileNameTest")); + QCOMPARE(nameTest.file(), QLatin1String("fileNameTest")); + + // check that url get/set works + QFileOpenEvent urlTest(QUrl(QLatin1String("file:///urlNameTest"))); + QCOMPARE(urlTest.url().toString(), QLatin1String("file:///urlNameTest")); + + // check that RFile construction works + RFile rFile = createRFile(_L("testRFile"), _L8("test content")); + QFileOpenEvent rFileTest(rFile); + QString targetName(QLatin1String("testRFile")); + QCOMPARE(rFileTest.file().right(targetName.size()), targetName); + QCOMPARE(rFileTest.url().toString().right(targetName.size()), targetName); + rFile.Close(); +} + +QString tst_qfileopenevent::readFileContent(QFileOpenEvent& event) +{ + QFile file; + event.openFile(file, QFile::ReadOnly); + file.seek(0); + QByteArray data = file.readAll(); + return QString(data); +} + +bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QString& writeContent) +{ + QFile file; + bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered); + if (ok) + ok = file.write(writeContent.toUtf8()) == writeContent.size(); + return ok; +} + +void tst_qfileopenevent::checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk) +{ + QCOMPARE(readFileContent(event), readContent); + QCOMPARE(appendFileContent(event, writeContent), writeOk); + QCOMPARE(readFileContent(event), writeOk ? readContent+writeContent : readContent); +} + +void tst_qfileopenevent::fileOpen() +{ + // create writeable file + { + RFile rFile = createRFile(_L("testFileOpen"), _L8("test content")); + QFileOpenEvent rFileTest(rFile); + checkReadAndWrite(rFileTest, QLatin1String("test content"), QLatin1String("+RFileWrite"), true); + rFile.Close(); + } + + // open read-only RFile + { + RFile rFile; + int err = rFile.Open(fsSession, _L("testFileOpen"), EFileRead); + QFileOpenEvent rFileTest2(rFile); + checkReadAndWrite(rFileTest2, QLatin1String("test content+RFileWrite"), QLatin1String("+RFileRead"), false); + rFile.Close(); + } + + // test it with read and write + // filename event + // test it with read and write + // url event + // test it with read and write +} + +void tst_qfileopenevent::handleLifetime() +{ +} + +void tst_qfileopenevent::multiOpen() +{ +} + +void tst_qfileopenevent::sendAndReceive() +{ +} + +void tst_qfileopenevent::viaApparc() +{ +} + +void tst_qfileopenevent::viasDocHandler() +{ +} + +QTEST_MAIN(tst_qfileopenevent) +#include "tst_qfileopenevent.moc" +#else +QTEST_NOOP_MAIN +#endif -- cgit v0.12 From 4ef64530ed2f9d939d54aa4fdb5166725345a58c Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 11 Jan 2011 14:38:06 +0000 Subject: Development of QFileOpenEvent testing for Symbian The source has been rearranged so that there is a main test program and a helper app, which helps test data caging. A bunch of new tests have been added. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- .../auto/symbian/qfileopenevent/qfileopenevent.pro | 10 +- .../qfileopeneventexternal.cpp | 40 +++ .../qfileopeneventexternal.pro | 12 + .../qfileopenevent/test/tst_qfileopenevent.cpp | 304 +++++++++++++++++++++ .../qfileopenevent/test/tst_qfileopenevent.pro | 7 + .../symbian/qfileopenevent/tst_qfileopenevent.cpp | 188 ------------- 6 files changed, 368 insertions(+), 193 deletions(-) create mode 100644 tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp create mode 100644 tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro create mode 100644 tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.cpp create mode 100644 tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro delete mode 100644 tests/auto/symbian/qfileopenevent/tst_qfileopenevent.cpp diff --git a/tests/auto/symbian/qfileopenevent/qfileopenevent.pro b/tests/auto/symbian/qfileopenevent/qfileopenevent.pro index e2bc537..e2bb6d8 100644 --- a/tests/auto/symbian/qfileopenevent/qfileopenevent.pro +++ b/tests/auto/symbian/qfileopenevent/qfileopenevent.pro @@ -1,6 +1,6 @@ -load(qttest_p4) -HEADERS += -SOURCES += tst_qfileopenevent.cpp -symbian { - LIBS+=-lefsrv +TEMPLATE = subdirs +symbian:{ + SUBDIRS = test qfileopeneventexternal +} else { + SUBDIRS = } diff --git a/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp new file mode 100644 index 0000000..77e8563 --- /dev/null +++ b/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp @@ -0,0 +1,40 @@ +/* +============================================================================ + Name : QtFileOpeningApp.cpp + Author : + Copyright : Your copyright notice + Description : Main GUI Application +============================================================================ +*/ + +#include +#include +#include + +struct MyApplication : public QApplication +{ + MyApplication(int& argc, char** argv) + : QApplication(argc, argv) + {} + + bool event(QEvent * event) + { + if (event->type() == QEvent::FileOpen) { + QFileOpenEvent* ev = static_cast(event); + QFile file; + bool ok = ev->openFile(file, QFile::Append | QFile::Unbuffered); + if (ok) + file.write(QByteArray("+external")); + return true; + } else { + return QApplication::event(event); + } + } +}; + +int main(int argc, char *argv[]) +{ + MyApplication a(argc, argv); + a.sendPostedEvents(&a, QEvent::FileOpen); + return 0; +} diff --git a/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro b/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro new file mode 100644 index 0000000..1b888b8 --- /dev/null +++ b/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = qfileopeneventexternal +QT += core gui +SOURCES += qfileopeneventexternal.cpp +symbian: { + TARGET.UID3 = 0xe9410b39 + MMP_RULES += DEBUGGABLE_UDEBONLY + RSS_RULES += "embeddability=KAppEmbeddable;" + RSS_RULES.datatype_list += "priority = EDataTypePriorityHigh; type = \"application/x-tst_qfileopenevent\";" + LIBS += -lapparc \ + -leikcore -lefsrv -lcone +} diff --git a/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.cpp new file mode 100644 index 0000000..77d53aa --- /dev/null +++ b/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.cpp @@ -0,0 +1,304 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#ifdef Q_OS_SYMBIAN +#include +#include "private/qcore_symbian_p.h" + +class tst_qfileopenevent : public QObject +{ + Q_OBJECT +public: + tst_qfileopenevent(){} + ~tst_qfileopenevent(); + +public slots: + void initTestCase(); + +private slots: + void constructor(); + void fileOpen(); + void handleLifetime(); + void multiOpen(); + void sendAndReceive(); + void external_data(); + void external(); + +private: + RFile createRFile(const TDesC& filename, const TDesC8& content); + void checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk); + QString readFileContent(QFileOpenEvent& event); + bool appendFileContent(QFileOpenEvent& event, const QString& writeContent); + + bool event(QEvent *); + +private: + RFs fsSession; +}; + +tst_qfileopenevent::~tst_qfileopenevent() +{ + fsSession.Close(); +}; + +void tst_qfileopenevent::initTestCase() +{ + qt_symbian_throwIfError(fsSession.Connect()); + qt_symbian_throwIfError(fsSession.ShareProtected()); +} + +RFile tst_qfileopenevent::createRFile(const TDesC& filename, const TDesC8& content) +{ + RFile file; + qt_symbian_throwIfError(file.Replace(fsSession, filename, EFileWrite)); + qt_symbian_throwIfError(file.Write(content)); + return file; +} + +void tst_qfileopenevent::constructor() +{ + // check that filename get/set works + QFileOpenEvent nameTest(QLatin1String("fileNameTest")); + QCOMPARE(nameTest.file(), QLatin1String("fileNameTest")); + + // check that url get/set works + QFileOpenEvent urlTest(QUrl(QLatin1String("file:///urlNameTest"))); + QCOMPARE(urlTest.url().toString(), QLatin1String("file:///urlNameTest")); + + // check that RFile construction works + RFile rFile = createRFile(_L("testRFile"), _L8("test content")); + QFileOpenEvent rFileTest(rFile); + QString targetName(QLatin1String("testRFile")); + QCOMPARE(rFileTest.file().right(targetName.size()), targetName); + QCOMPARE(rFileTest.url().toString().right(targetName.size()), targetName); + rFile.Close(); +} + +QString tst_qfileopenevent::readFileContent(QFileOpenEvent& event) +{ + QFile file; + event.openFile(file, QFile::ReadOnly); + file.seek(0); + QByteArray data = file.readAll(); + return QString(data); +} + +bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QString& writeContent) +{ + QFile file; + bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered); + if (ok) + ok = file.write(writeContent.toUtf8()) == writeContent.size(); + return ok; +} + +void tst_qfileopenevent::checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk) +{ + QCOMPARE(readFileContent(event), readContent); + QCOMPARE(appendFileContent(event, writeContent), writeOk); + QCOMPARE(readFileContent(event), writeOk ? readContent+writeContent : readContent); +} + +void tst_qfileopenevent::fileOpen() +{ + // create writeable file + { + RFile rFile = createRFile(_L("testFileOpen"), _L8("test content")); + QFileOpenEvent rFileTest(rFile); + checkReadAndWrite(rFileTest, QLatin1String("test content"), QLatin1String("+RFileWrite"), true); + rFile.Close(); + } + + // open read-only RFile + { + RFile rFile; + int err = rFile.Open(fsSession, _L("testFileOpen"), EFileRead); + QFileOpenEvent rFileTest(rFile); + checkReadAndWrite(rFileTest, QLatin1String("test content+RFileWrite"), QLatin1String("+RFileRead"), false); + rFile.Close(); + } + + // filename event + QUrl fileUrl; // need to get the URL during the file test, for use in the URL test + { + QFileOpenEvent nameTest(QLatin1String("testFileOpen")); + fileUrl = nameTest.url(); + checkReadAndWrite(nameTest, QLatin1String("test content+RFileWrite"), QLatin1String("+nameWrite"), true); + } + + // url event + { + QFileOpenEvent urlTest(fileUrl); + checkReadAndWrite(urlTest, QLatin1String("test content+RFileWrite+nameWrite"), QLatin1String("+urlWrite"), true); + } +} + +void tst_qfileopenevent::handleLifetime() +{ + RFile rFile = createRFile(_L("testHandleLifetime"), _L8("test content")); + QScopedPointer event(new QFileOpenEvent(rFile)); + rFile.Close(); + + // open a QFile after the original RFile is closed + QFile qFile; + QCOMPARE(event->openFile(qFile, QFile::Append | QFile::Unbuffered), true); + event.reset(0); + + // write to the QFile after the event is closed + QString writeContent(QLatin1String("+closed original handles")); + QCOMPARE(int(qFile.write(writeContent.toUtf8())), writeContent.size()); + qFile.close(); + + // check the content + QFile check("testHandleLifetime"); + check.open(QFile::ReadOnly); + QString content(check.readAll()); + QCOMPARE(content, QLatin1String("test content+closed original handles")); +} + +void tst_qfileopenevent::multiOpen() +{ + RFile rFile = createRFile(_L("testMultiOpen"), _L8("itlum")); + QFileOpenEvent event(rFile); + rFile.Close(); + + QFile files[5]; + for (int i=0; i<5; i++) { + QCOMPARE(event.openFile(files[i], QFile::ReadOnly), true); + } + for (int i=0; i<5; i++) + files[i].seek(i); + QString str; + for (int i=4; i>=0; i--) { + char c; + files[i].getChar(&c); + str.append(c); + files[i].close(); + } + QCOMPARE(str, QLatin1String("multi")); +} + +bool tst_qfileopenevent::event(QEvent *event) +{ + if (event->type() != QEvent::FileOpen) + return QObject::event(event); + QFileOpenEvent* fileOpenEvent = static_cast(event); + appendFileContent(*fileOpenEvent, "+received"); + return true; +} + +void tst_qfileopenevent::sendAndReceive() +{ + RFile rFile = createRFile(_L("testSendAndReceive"), _L8("sending")); + QFileOpenEvent* event = new QFileOpenEvent(rFile); + rFile.Close(); + QCoreApplication::instance()->postEvent(this, event); + QCoreApplication::instance()->processEvents(); + + // check the content + QFile check("testSendAndReceive"); + QCOMPARE(check.open(QFile::ReadOnly), true); + QString content(check.readAll()); + QCOMPARE(content, QLatin1String("sending+received")); +} + +void tst_qfileopenevent::external_data() +{ + QTest::addColumn("filename"); + QTest::addColumn("targetContent"); + QTest::addColumn("sendHandle"); + + QString privateName(QLatin1String("tst_qfileopenevent_external")); + QString publicName(QLatin1String("C:\\Data\\tst_qfileopenevent_external")); + QByteArray writeSuccess("original+external"); + QByteArray writeFail("original"); + QTest::newRow("public name") << publicName << writeSuccess << false; + QTest::newRow("data caged name") << privateName << writeFail << false; + QTest::newRow("public handle") << publicName << writeSuccess << true; + QTest::newRow("data caged handle") << privateName << writeSuccess << true; +} + +void tst_qfileopenevent::external() +{ + QFETCH(QString, filename); + QFETCH(QByteArray, targetContent); + QFETCH(bool, sendHandle); + + RFile rFile = createRFile(qt_QString2TPtrC(filename), _L8("original")); + + // launch app with the file + RApaLsSession apa; + QCOMPARE(apa.Connect(), KErrNone); + TThreadId threadId; + TDataType type(_L8("application/x-tst_qfileopenevent")); + if (sendHandle) { + QCOMPARE(apa.StartDocument(rFile, type, threadId), KErrNone); + rFile.Close(); + } else { + TFileName fullName; + rFile.FullName(fullName); + rFile.Close(); + QCOMPARE(apa.StartDocument(fullName, type, threadId), KErrNone); + } + + // wait for app exit + RThread appThread; + if (appThread.Open(threadId) == KErrNone) { + TRequestStatus status; + appThread.Logon(status); + User::WaitForRequest(status); + } + + // check the contents + QFile check(filename); + QCOMPARE(check.open(QFile::ReadOnly), true); + QCOMPARE(check.readAll(), targetContent); + bool ok = check.remove(); +} + +QTEST_MAIN(tst_qfileopenevent) +#include "tst_qfileopenevent.moc" +#else +QTEST_NOOP_MAIN +#endif diff --git a/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro b/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro new file mode 100644 index 0000000..3f16dcf --- /dev/null +++ b/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TARGET = tst_qfileopenevent +HEADERS += +SOURCES += tst_qfileopenevent.cpp +symbian { + LIBS+=-lefsrv -lapgrfx -lapmime +} diff --git a/tests/auto/symbian/qfileopenevent/tst_qfileopenevent.cpp b/tests/auto/symbian/qfileopenevent/tst_qfileopenevent.cpp deleted file mode 100644 index 85ec04d..0000000 --- a/tests/auto/symbian/qfileopenevent/tst_qfileopenevent.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#ifdef Q_OS_SYMBIAN - -class tst_qfileopenevent : public QObject -{ - Q_OBJECT -public: - tst_qfileopenevent(){} - ~tst_qfileopenevent(); - -public slots: - void initTestCase(); - -private slots: - void constructor(); - void fileOpen(); - void handleLifetime(); - void multiOpen(); - void sendAndReceive(); - void viaApparc(); - void viasDocHandler(); - -private: - RFile createRFile(const TDesC& filename, const TDesC8& content); - void checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk); - QString readFileContent(QFileOpenEvent& event); - bool appendFileContent(QFileOpenEvent& event, const QString& writeContent); - -private: - RFs fsSession; -}; - -tst_qfileopenevent::~tst_qfileopenevent() -{ - fsSession.Close(); -}; - -void tst_qfileopenevent::initTestCase() -{ - qt_symbian_throwIfError(fsSession.Connect()); -} - -RFile tst_qfileopenevent::createRFile(const TDesC& filename, const TDesC8& content) -{ - RFile file; - qt_symbian_throwIfError(file.Replace(fsSession, filename, EFileWrite)); - qt_symbian_throwIfError(file.Write(content)); - return file; -} - -void tst_qfileopenevent::constructor() -{ - // check that filename get/set works - QFileOpenEvent nameTest(QLatin1String("fileNameTest")); - QCOMPARE(nameTest.file(), QLatin1String("fileNameTest")); - - // check that url get/set works - QFileOpenEvent urlTest(QUrl(QLatin1String("file:///urlNameTest"))); - QCOMPARE(urlTest.url().toString(), QLatin1String("file:///urlNameTest")); - - // check that RFile construction works - RFile rFile = createRFile(_L("testRFile"), _L8("test content")); - QFileOpenEvent rFileTest(rFile); - QString targetName(QLatin1String("testRFile")); - QCOMPARE(rFileTest.file().right(targetName.size()), targetName); - QCOMPARE(rFileTest.url().toString().right(targetName.size()), targetName); - rFile.Close(); -} - -QString tst_qfileopenevent::readFileContent(QFileOpenEvent& event) -{ - QFile file; - event.openFile(file, QFile::ReadOnly); - file.seek(0); - QByteArray data = file.readAll(); - return QString(data); -} - -bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QString& writeContent) -{ - QFile file; - bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered); - if (ok) - ok = file.write(writeContent.toUtf8()) == writeContent.size(); - return ok; -} - -void tst_qfileopenevent::checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk) -{ - QCOMPARE(readFileContent(event), readContent); - QCOMPARE(appendFileContent(event, writeContent), writeOk); - QCOMPARE(readFileContent(event), writeOk ? readContent+writeContent : readContent); -} - -void tst_qfileopenevent::fileOpen() -{ - // create writeable file - { - RFile rFile = createRFile(_L("testFileOpen"), _L8("test content")); - QFileOpenEvent rFileTest(rFile); - checkReadAndWrite(rFileTest, QLatin1String("test content"), QLatin1String("+RFileWrite"), true); - rFile.Close(); - } - - // open read-only RFile - { - RFile rFile; - int err = rFile.Open(fsSession, _L("testFileOpen"), EFileRead); - QFileOpenEvent rFileTest2(rFile); - checkReadAndWrite(rFileTest2, QLatin1String("test content+RFileWrite"), QLatin1String("+RFileRead"), false); - rFile.Close(); - } - - // test it with read and write - // filename event - // test it with read and write - // url event - // test it with read and write -} - -void tst_qfileopenevent::handleLifetime() -{ -} - -void tst_qfileopenevent::multiOpen() -{ -} - -void tst_qfileopenevent::sendAndReceive() -{ -} - -void tst_qfileopenevent::viaApparc() -{ -} - -void tst_qfileopenevent::viasDocHandler() -{ -} - -QTEST_MAIN(tst_qfileopenevent) -#include "tst_qfileopenevent.moc" -#else -QTEST_NOOP_MAIN -#endif -- cgit v0.12 From c618f06e39eee1bf8110f5a0c56578fb44e986f5 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 11 Jan 2011 14:48:30 +0000 Subject: renamed .pro file to make qmake happy qmake got upset because tst_qfileopenevent.pro was not called test.pro. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- tests/auto/symbian/qfileopenevent/test/test.pro | 7 +++++++ tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 tests/auto/symbian/qfileopenevent/test/test.pro delete mode 100644 tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro diff --git a/tests/auto/symbian/qfileopenevent/test/test.pro b/tests/auto/symbian/qfileopenevent/test/test.pro new file mode 100644 index 0000000..3f16dcf --- /dev/null +++ b/tests/auto/symbian/qfileopenevent/test/test.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TARGET = tst_qfileopenevent +HEADERS += +SOURCES += tst_qfileopenevent.cpp +symbian { + LIBS+=-lefsrv -lapgrfx -lapmime +} diff --git a/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro b/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro deleted file mode 100644 index 3f16dcf..0000000 --- a/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.pro +++ /dev/null @@ -1,7 +0,0 @@ -load(qttest_p4) -TARGET = tst_qfileopenevent -HEADERS += -SOURCES += tst_qfileopenevent.cpp -symbian { - LIBS+=-lefsrv -lapgrfx -lapmime -} -- cgit v0.12 From 8f34fc6776fbd30bdae482a3f6bb683435544215 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 11 Jan 2011 15:49:46 +0000 Subject: removed dodgy file header The comment block at the top of the file had tabs in it. Git didn't like that. It's now removed, it was just the default comment added by Carbide. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- .../qfileopeneventexternal/qfileopeneventexternal.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp index 77e8563..45e7acc 100644 --- a/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp +++ b/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp @@ -1,12 +1,3 @@ -/* -============================================================================ - Name : QtFileOpeningApp.cpp - Author : - Copyright : Your copyright notice - Description : Main GUI Application -============================================================================ -*/ - #include #include #include -- cgit v0.12 From 2abcd8e2ec986a4862de669f2ddec30877d9a853 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 11 Jan 2011 15:55:42 +0000 Subject: added qfileopenevent test to the symbian tests Previously it had not been added to the symbian tests .pro file Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- tests/auto/symbian/qsymbiantests.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/symbian/qsymbiantests.pro b/tests/auto/symbian/qsymbiantests.pro index a752c86..dcace63 100644 --- a/tests/auto/symbian/qsymbiantests.pro +++ b/tests/auto/symbian/qsymbiantests.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS = qmainexceptions orientationchange +SUBDIRS = qmainexceptions orientationchange qfileopenevent requires(symbian) -- cgit v0.12 From 30f845abdad6dcff620f93122495aee8aac7452f Mon Sep 17 00:00:00 2001 From: mread Date: Mon, 17 Jan 2011 15:12:25 +0000 Subject: review improvements for QFileOpenEvent changes removed an unnecessary local QString Improved some comment wording Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f6f2694..5027aa2 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -728,12 +728,12 @@ QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta, The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride. - Int \a key is the code for the Qt::Key that the event loop should listen - for. If \a key is 0, the event is not a result of a known key; for + Int \a key is the code for the Qt::Key that the event loop should listen + for. If \a key is 0, the event is not a result of a known key; for example, it may be the result of a compose sequence or keyboard macro. - The \a modifiers holds the keyboard modifiers, and the given \a text - is the Unicode text that the key generated. If \a autorep is true, - isAutoRepeat() will be true. \a count is the number of keys involved + The \a modifiers holds the keyboard modifiers, and the given \a text + is the Unicode text that the key generated. If \a autorep is true, + isAutoRepeat() will be true. \a count is the number of keys involved in the event. */ QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text, @@ -1662,7 +1662,7 @@ Qt::ButtonState QContextMenuEvent::state() const string is controlled by the widget only). The AttributeType enum describes the different attributes that can be set. - A class implementing QWidget::inputMethodEvent() or + A class implementing QWidget::inputMethodEvent() or QGraphicsItem::inputMethodEvent() should at least understand and honor the \l TextFormat and \l Cursor attributes. @@ -3061,9 +3061,8 @@ QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle) { TFileName fullName; fileHandle.FullName(fullName); - QString file = qt_TDesC2QString(fullName); - f = file; - QScopedPointer priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(file))); + f = qt_TDesC2QString(fullName); + QScopedPointer priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(f))); qt_symbian_throwIfError(priv->file.Duplicate(fileHandle)); d = reinterpret_cast(priv.take()); } @@ -3104,10 +3103,10 @@ QUrl QFileOpenEvent::url() const Opens a QFile on the file referenced by this event. Returns true if successful; otherwise returns false. - This is necessary as some files cannot be opened with the filename alone, but require specific + This is necessary as some files cannot be opened by name, but require specific information stored in this event. For example, if this QFileOpenEvent contains a request to open a Symbian data caged file, - this function must be used to open a QFile on it. + the QFile could only be opened from the Symbian RFile used in the construction of this event. \since 4.8 */ @@ -3677,7 +3676,7 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar) #endif -/*! +/*! \class QTouchEvent \brief The QTouchEvent class contains parameters that describe a touch event. \since 4.6 -- cgit v0.12 From d35e6856c4fb7e98dac5db3aaa94ac271375405e Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 18 Jan 2011 16:50:09 +0000 Subject: Updates after review comments Tidied up QFileOpenEventPrivate destruction. Commented the Duplicates to explain their benefit. Remove the file exists check from ProcessCommandParametersL Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/kernel/qevent.cpp | 16 +++++++++++----- src/gui/kernel/qevent_p.h | 1 + src/gui/s60framework/qs60mainappui.cpp | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 5027aa2..698c94b 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3030,6 +3030,13 @@ QShowEvent::~QShowEvent() \note This class is currently supported for Mac OS X and Symbian only. */ +QFileOpenEventPrivate::~QFileOpenEventPrivate() +{ +#ifdef Q_OS_SYMBIAN + file.Close(); +#endif +} + /*! \internal @@ -3063,6 +3070,7 @@ QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle) fileHandle.FullName(fullName); f = qt_TDesC2QString(fullName); QScopedPointer priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(f))); + // Duplicate here allows the file handle to be valid after S60 app construction is complete. qt_symbian_throwIfError(priv->file.Duplicate(fileHandle)); d = reinterpret_cast(priv.take()); } @@ -3072,11 +3080,7 @@ QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle) */ QFileOpenEvent::~QFileOpenEvent() { - QFileOpenEventPrivate *priv = reinterpret_cast(d); -#ifdef Q_OS_SYMBIAN - priv->file.Close(); -#endif - delete priv; + delete reinterpret_cast(d); } /*! @@ -3117,6 +3121,8 @@ bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const const QFileOpenEventPrivate *priv = reinterpret_cast(d); if (priv->file.SubSessionHandle()) { RFile dup; + // Duplicate here means that the opened QFile will continue to be valid beyond the lifetime of this QFileOpenEvent. + // It also allows openFile to be used in threads other than the thread in which the QFileOpenEvent was created. if (dup.Duplicate(priv->file) == KErrNone) { QScopedPointer > dupCloser(&dup); bool open = file.open(dup, flags, QFile::AutoCloseHandle); diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 01af384..b79f372 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -178,6 +178,7 @@ public: : url(url) { } + ~QFileOpenEventPrivate(); QUrl url; #ifdef Q_OS_SYMBIAN diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index 454f90d..8ae43a5 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -408,7 +408,8 @@ void QS60MainAppUi::HandleForegroundEventL(TBool aForeground) TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &aDocumentName, const TDesC8 &/*aTail*/) { // bypass CEikAppUi::ProcessCommandParametersL(..) which modifies aDocumentName, preventing apparc document opening from working. - return ConeUtils::FileExists(aDocumentName); + // The return value is effectively unused in Qt apps (see QS60MainDocument::OpenFileL) + return EFalse; } #ifndef Q_WS_S60 -- cgit v0.12 From 707cc8bfb51af5a777001df0f445a79863850f3a Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 18 Jan 2011 16:54:42 +0000 Subject: Started move of QFileOpenEvent autotest to generic The QFileOpenEvent autotest was written as Symbian specific. But it is going to be modified to be applicable to all platforms. So this is the file move to reflect that change. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- tests/auto/gui.pro | 3 +- tests/auto/qfileopenevent/qfileopenevent.pro | 6 + .../qfileopeneventexternal.cpp | 31 +++ .../qfileopeneventexternal.pro | 12 + tests/auto/qfileopenevent/test/test.pro | 7 + .../qfileopenevent/test/tst_qfileopenevent.cpp | 304 +++++++++++++++++++++ .../auto/symbian/qfileopenevent/qfileopenevent.pro | 6 - .../qfileopeneventexternal.cpp | 31 --- .../qfileopeneventexternal.pro | 12 - tests/auto/symbian/qfileopenevent/test/test.pro | 7 - .../qfileopenevent/test/tst_qfileopenevent.cpp | 304 --------------------- tests/auto/symbian/qsymbiantests.pro | 2 +- 12 files changed, 363 insertions(+), 362 deletions(-) create mode 100644 tests/auto/qfileopenevent/qfileopenevent.pro create mode 100644 tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp create mode 100644 tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro create mode 100644 tests/auto/qfileopenevent/test/test.pro create mode 100644 tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp delete mode 100644 tests/auto/symbian/qfileopenevent/qfileopenevent.pro delete mode 100644 tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp delete mode 100644 tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro delete mode 100644 tests/auto/symbian/qfileopenevent/test/test.pro delete mode 100644 tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.cpp diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index f74da54..30155ea 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -2,7 +2,7 @@ # (i.e. QT=core gui network). # The test system is allowed to run these tests before the rest of Qt has # been compiled. -# +# TEMPLATE=subdirs SUBDIRS=\ gestures \ @@ -49,6 +49,7 @@ SUBDIRS=\ qfiledialog \ qfiledialog2 \ qfileiconprovider \ + qfileopenevent \ qfilesystemmodel \ qfocusframe \ qfont \ diff --git a/tests/auto/qfileopenevent/qfileopenevent.pro b/tests/auto/qfileopenevent/qfileopenevent.pro new file mode 100644 index 0000000..e2bb6d8 --- /dev/null +++ b/tests/auto/qfileopenevent/qfileopenevent.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +symbian:{ + SUBDIRS = test qfileopeneventexternal +} else { + SUBDIRS = +} diff --git a/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp new file mode 100644 index 0000000..45e7acc --- /dev/null +++ b/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp @@ -0,0 +1,31 @@ +#include +#include +#include + +struct MyApplication : public QApplication +{ + MyApplication(int& argc, char** argv) + : QApplication(argc, argv) + {} + + bool event(QEvent * event) + { + if (event->type() == QEvent::FileOpen) { + QFileOpenEvent* ev = static_cast(event); + QFile file; + bool ok = ev->openFile(file, QFile::Append | QFile::Unbuffered); + if (ok) + file.write(QByteArray("+external")); + return true; + } else { + return QApplication::event(event); + } + } +}; + +int main(int argc, char *argv[]) +{ + MyApplication a(argc, argv); + a.sendPostedEvents(&a, QEvent::FileOpen); + return 0; +} diff --git a/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro b/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro new file mode 100644 index 0000000..1b888b8 --- /dev/null +++ b/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = qfileopeneventexternal +QT += core gui +SOURCES += qfileopeneventexternal.cpp +symbian: { + TARGET.UID3 = 0xe9410b39 + MMP_RULES += DEBUGGABLE_UDEBONLY + RSS_RULES += "embeddability=KAppEmbeddable;" + RSS_RULES.datatype_list += "priority = EDataTypePriorityHigh; type = \"application/x-tst_qfileopenevent\";" + LIBS += -lapparc \ + -leikcore -lefsrv -lcone +} diff --git a/tests/auto/qfileopenevent/test/test.pro b/tests/auto/qfileopenevent/test/test.pro new file mode 100644 index 0000000..3f16dcf --- /dev/null +++ b/tests/auto/qfileopenevent/test/test.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TARGET = tst_qfileopenevent +HEADERS += +SOURCES += tst_qfileopenevent.cpp +symbian { + LIBS+=-lefsrv -lapgrfx -lapmime +} diff --git a/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp new file mode 100644 index 0000000..77d53aa --- /dev/null +++ b/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp @@ -0,0 +1,304 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#ifdef Q_OS_SYMBIAN +#include +#include "private/qcore_symbian_p.h" + +class tst_qfileopenevent : public QObject +{ + Q_OBJECT +public: + tst_qfileopenevent(){} + ~tst_qfileopenevent(); + +public slots: + void initTestCase(); + +private slots: + void constructor(); + void fileOpen(); + void handleLifetime(); + void multiOpen(); + void sendAndReceive(); + void external_data(); + void external(); + +private: + RFile createRFile(const TDesC& filename, const TDesC8& content); + void checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk); + QString readFileContent(QFileOpenEvent& event); + bool appendFileContent(QFileOpenEvent& event, const QString& writeContent); + + bool event(QEvent *); + +private: + RFs fsSession; +}; + +tst_qfileopenevent::~tst_qfileopenevent() +{ + fsSession.Close(); +}; + +void tst_qfileopenevent::initTestCase() +{ + qt_symbian_throwIfError(fsSession.Connect()); + qt_symbian_throwIfError(fsSession.ShareProtected()); +} + +RFile tst_qfileopenevent::createRFile(const TDesC& filename, const TDesC8& content) +{ + RFile file; + qt_symbian_throwIfError(file.Replace(fsSession, filename, EFileWrite)); + qt_symbian_throwIfError(file.Write(content)); + return file; +} + +void tst_qfileopenevent::constructor() +{ + // check that filename get/set works + QFileOpenEvent nameTest(QLatin1String("fileNameTest")); + QCOMPARE(nameTest.file(), QLatin1String("fileNameTest")); + + // check that url get/set works + QFileOpenEvent urlTest(QUrl(QLatin1String("file:///urlNameTest"))); + QCOMPARE(urlTest.url().toString(), QLatin1String("file:///urlNameTest")); + + // check that RFile construction works + RFile rFile = createRFile(_L("testRFile"), _L8("test content")); + QFileOpenEvent rFileTest(rFile); + QString targetName(QLatin1String("testRFile")); + QCOMPARE(rFileTest.file().right(targetName.size()), targetName); + QCOMPARE(rFileTest.url().toString().right(targetName.size()), targetName); + rFile.Close(); +} + +QString tst_qfileopenevent::readFileContent(QFileOpenEvent& event) +{ + QFile file; + event.openFile(file, QFile::ReadOnly); + file.seek(0); + QByteArray data = file.readAll(); + return QString(data); +} + +bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QString& writeContent) +{ + QFile file; + bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered); + if (ok) + ok = file.write(writeContent.toUtf8()) == writeContent.size(); + return ok; +} + +void tst_qfileopenevent::checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk) +{ + QCOMPARE(readFileContent(event), readContent); + QCOMPARE(appendFileContent(event, writeContent), writeOk); + QCOMPARE(readFileContent(event), writeOk ? readContent+writeContent : readContent); +} + +void tst_qfileopenevent::fileOpen() +{ + // create writeable file + { + RFile rFile = createRFile(_L("testFileOpen"), _L8("test content")); + QFileOpenEvent rFileTest(rFile); + checkReadAndWrite(rFileTest, QLatin1String("test content"), QLatin1String("+RFileWrite"), true); + rFile.Close(); + } + + // open read-only RFile + { + RFile rFile; + int err = rFile.Open(fsSession, _L("testFileOpen"), EFileRead); + QFileOpenEvent rFileTest(rFile); + checkReadAndWrite(rFileTest, QLatin1String("test content+RFileWrite"), QLatin1String("+RFileRead"), false); + rFile.Close(); + } + + // filename event + QUrl fileUrl; // need to get the URL during the file test, for use in the URL test + { + QFileOpenEvent nameTest(QLatin1String("testFileOpen")); + fileUrl = nameTest.url(); + checkReadAndWrite(nameTest, QLatin1String("test content+RFileWrite"), QLatin1String("+nameWrite"), true); + } + + // url event + { + QFileOpenEvent urlTest(fileUrl); + checkReadAndWrite(urlTest, QLatin1String("test content+RFileWrite+nameWrite"), QLatin1String("+urlWrite"), true); + } +} + +void tst_qfileopenevent::handleLifetime() +{ + RFile rFile = createRFile(_L("testHandleLifetime"), _L8("test content")); + QScopedPointer event(new QFileOpenEvent(rFile)); + rFile.Close(); + + // open a QFile after the original RFile is closed + QFile qFile; + QCOMPARE(event->openFile(qFile, QFile::Append | QFile::Unbuffered), true); + event.reset(0); + + // write to the QFile after the event is closed + QString writeContent(QLatin1String("+closed original handles")); + QCOMPARE(int(qFile.write(writeContent.toUtf8())), writeContent.size()); + qFile.close(); + + // check the content + QFile check("testHandleLifetime"); + check.open(QFile::ReadOnly); + QString content(check.readAll()); + QCOMPARE(content, QLatin1String("test content+closed original handles")); +} + +void tst_qfileopenevent::multiOpen() +{ + RFile rFile = createRFile(_L("testMultiOpen"), _L8("itlum")); + QFileOpenEvent event(rFile); + rFile.Close(); + + QFile files[5]; + for (int i=0; i<5; i++) { + QCOMPARE(event.openFile(files[i], QFile::ReadOnly), true); + } + for (int i=0; i<5; i++) + files[i].seek(i); + QString str; + for (int i=4; i>=0; i--) { + char c; + files[i].getChar(&c); + str.append(c); + files[i].close(); + } + QCOMPARE(str, QLatin1String("multi")); +} + +bool tst_qfileopenevent::event(QEvent *event) +{ + if (event->type() != QEvent::FileOpen) + return QObject::event(event); + QFileOpenEvent* fileOpenEvent = static_cast(event); + appendFileContent(*fileOpenEvent, "+received"); + return true; +} + +void tst_qfileopenevent::sendAndReceive() +{ + RFile rFile = createRFile(_L("testSendAndReceive"), _L8("sending")); + QFileOpenEvent* event = new QFileOpenEvent(rFile); + rFile.Close(); + QCoreApplication::instance()->postEvent(this, event); + QCoreApplication::instance()->processEvents(); + + // check the content + QFile check("testSendAndReceive"); + QCOMPARE(check.open(QFile::ReadOnly), true); + QString content(check.readAll()); + QCOMPARE(content, QLatin1String("sending+received")); +} + +void tst_qfileopenevent::external_data() +{ + QTest::addColumn("filename"); + QTest::addColumn("targetContent"); + QTest::addColumn("sendHandle"); + + QString privateName(QLatin1String("tst_qfileopenevent_external")); + QString publicName(QLatin1String("C:\\Data\\tst_qfileopenevent_external")); + QByteArray writeSuccess("original+external"); + QByteArray writeFail("original"); + QTest::newRow("public name") << publicName << writeSuccess << false; + QTest::newRow("data caged name") << privateName << writeFail << false; + QTest::newRow("public handle") << publicName << writeSuccess << true; + QTest::newRow("data caged handle") << privateName << writeSuccess << true; +} + +void tst_qfileopenevent::external() +{ + QFETCH(QString, filename); + QFETCH(QByteArray, targetContent); + QFETCH(bool, sendHandle); + + RFile rFile = createRFile(qt_QString2TPtrC(filename), _L8("original")); + + // launch app with the file + RApaLsSession apa; + QCOMPARE(apa.Connect(), KErrNone); + TThreadId threadId; + TDataType type(_L8("application/x-tst_qfileopenevent")); + if (sendHandle) { + QCOMPARE(apa.StartDocument(rFile, type, threadId), KErrNone); + rFile.Close(); + } else { + TFileName fullName; + rFile.FullName(fullName); + rFile.Close(); + QCOMPARE(apa.StartDocument(fullName, type, threadId), KErrNone); + } + + // wait for app exit + RThread appThread; + if (appThread.Open(threadId) == KErrNone) { + TRequestStatus status; + appThread.Logon(status); + User::WaitForRequest(status); + } + + // check the contents + QFile check(filename); + QCOMPARE(check.open(QFile::ReadOnly), true); + QCOMPARE(check.readAll(), targetContent); + bool ok = check.remove(); +} + +QTEST_MAIN(tst_qfileopenevent) +#include "tst_qfileopenevent.moc" +#else +QTEST_NOOP_MAIN +#endif diff --git a/tests/auto/symbian/qfileopenevent/qfileopenevent.pro b/tests/auto/symbian/qfileopenevent/qfileopenevent.pro deleted file mode 100644 index e2bb6d8..0000000 --- a/tests/auto/symbian/qfileopenevent/qfileopenevent.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = subdirs -symbian:{ - SUBDIRS = test qfileopeneventexternal -} else { - SUBDIRS = -} diff --git a/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp deleted file mode 100644 index 45e7acc..0000000 --- a/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include - -struct MyApplication : public QApplication -{ - MyApplication(int& argc, char** argv) - : QApplication(argc, argv) - {} - - bool event(QEvent * event) - { - if (event->type() == QEvent::FileOpen) { - QFileOpenEvent* ev = static_cast(event); - QFile file; - bool ok = ev->openFile(file, QFile::Append | QFile::Unbuffered); - if (ok) - file.write(QByteArray("+external")); - return true; - } else { - return QApplication::event(event); - } - } -}; - -int main(int argc, char *argv[]) -{ - MyApplication a(argc, argv); - a.sendPostedEvents(&a, QEvent::FileOpen); - return 0; -} diff --git a/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro b/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro deleted file mode 100644 index 1b888b8..0000000 --- a/tests/auto/symbian/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = app -TARGET = qfileopeneventexternal -QT += core gui -SOURCES += qfileopeneventexternal.cpp -symbian: { - TARGET.UID3 = 0xe9410b39 - MMP_RULES += DEBUGGABLE_UDEBONLY - RSS_RULES += "embeddability=KAppEmbeddable;" - RSS_RULES.datatype_list += "priority = EDataTypePriorityHigh; type = \"application/x-tst_qfileopenevent\";" - LIBS += -lapparc \ - -leikcore -lefsrv -lcone -} diff --git a/tests/auto/symbian/qfileopenevent/test/test.pro b/tests/auto/symbian/qfileopenevent/test/test.pro deleted file mode 100644 index 3f16dcf..0000000 --- a/tests/auto/symbian/qfileopenevent/test/test.pro +++ /dev/null @@ -1,7 +0,0 @@ -load(qttest_p4) -TARGET = tst_qfileopenevent -HEADERS += -SOURCES += tst_qfileopenevent.cpp -symbian { - LIBS+=-lefsrv -lapgrfx -lapmime -} diff --git a/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.cpp deleted file mode 100644 index 77d53aa..0000000 --- a/tests/auto/symbian/qfileopenevent/test/tst_qfileopenevent.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#ifdef Q_OS_SYMBIAN -#include -#include "private/qcore_symbian_p.h" - -class tst_qfileopenevent : public QObject -{ - Q_OBJECT -public: - tst_qfileopenevent(){} - ~tst_qfileopenevent(); - -public slots: - void initTestCase(); - -private slots: - void constructor(); - void fileOpen(); - void handleLifetime(); - void multiOpen(); - void sendAndReceive(); - void external_data(); - void external(); - -private: - RFile createRFile(const TDesC& filename, const TDesC8& content); - void checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk); - QString readFileContent(QFileOpenEvent& event); - bool appendFileContent(QFileOpenEvent& event, const QString& writeContent); - - bool event(QEvent *); - -private: - RFs fsSession; -}; - -tst_qfileopenevent::~tst_qfileopenevent() -{ - fsSession.Close(); -}; - -void tst_qfileopenevent::initTestCase() -{ - qt_symbian_throwIfError(fsSession.Connect()); - qt_symbian_throwIfError(fsSession.ShareProtected()); -} - -RFile tst_qfileopenevent::createRFile(const TDesC& filename, const TDesC8& content) -{ - RFile file; - qt_symbian_throwIfError(file.Replace(fsSession, filename, EFileWrite)); - qt_symbian_throwIfError(file.Write(content)); - return file; -} - -void tst_qfileopenevent::constructor() -{ - // check that filename get/set works - QFileOpenEvent nameTest(QLatin1String("fileNameTest")); - QCOMPARE(nameTest.file(), QLatin1String("fileNameTest")); - - // check that url get/set works - QFileOpenEvent urlTest(QUrl(QLatin1String("file:///urlNameTest"))); - QCOMPARE(urlTest.url().toString(), QLatin1String("file:///urlNameTest")); - - // check that RFile construction works - RFile rFile = createRFile(_L("testRFile"), _L8("test content")); - QFileOpenEvent rFileTest(rFile); - QString targetName(QLatin1String("testRFile")); - QCOMPARE(rFileTest.file().right(targetName.size()), targetName); - QCOMPARE(rFileTest.url().toString().right(targetName.size()), targetName); - rFile.Close(); -} - -QString tst_qfileopenevent::readFileContent(QFileOpenEvent& event) -{ - QFile file; - event.openFile(file, QFile::ReadOnly); - file.seek(0); - QByteArray data = file.readAll(); - return QString(data); -} - -bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QString& writeContent) -{ - QFile file; - bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered); - if (ok) - ok = file.write(writeContent.toUtf8()) == writeContent.size(); - return ok; -} - -void tst_qfileopenevent::checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk) -{ - QCOMPARE(readFileContent(event), readContent); - QCOMPARE(appendFileContent(event, writeContent), writeOk); - QCOMPARE(readFileContent(event), writeOk ? readContent+writeContent : readContent); -} - -void tst_qfileopenevent::fileOpen() -{ - // create writeable file - { - RFile rFile = createRFile(_L("testFileOpen"), _L8("test content")); - QFileOpenEvent rFileTest(rFile); - checkReadAndWrite(rFileTest, QLatin1String("test content"), QLatin1String("+RFileWrite"), true); - rFile.Close(); - } - - // open read-only RFile - { - RFile rFile; - int err = rFile.Open(fsSession, _L("testFileOpen"), EFileRead); - QFileOpenEvent rFileTest(rFile); - checkReadAndWrite(rFileTest, QLatin1String("test content+RFileWrite"), QLatin1String("+RFileRead"), false); - rFile.Close(); - } - - // filename event - QUrl fileUrl; // need to get the URL during the file test, for use in the URL test - { - QFileOpenEvent nameTest(QLatin1String("testFileOpen")); - fileUrl = nameTest.url(); - checkReadAndWrite(nameTest, QLatin1String("test content+RFileWrite"), QLatin1String("+nameWrite"), true); - } - - // url event - { - QFileOpenEvent urlTest(fileUrl); - checkReadAndWrite(urlTest, QLatin1String("test content+RFileWrite+nameWrite"), QLatin1String("+urlWrite"), true); - } -} - -void tst_qfileopenevent::handleLifetime() -{ - RFile rFile = createRFile(_L("testHandleLifetime"), _L8("test content")); - QScopedPointer event(new QFileOpenEvent(rFile)); - rFile.Close(); - - // open a QFile after the original RFile is closed - QFile qFile; - QCOMPARE(event->openFile(qFile, QFile::Append | QFile::Unbuffered), true); - event.reset(0); - - // write to the QFile after the event is closed - QString writeContent(QLatin1String("+closed original handles")); - QCOMPARE(int(qFile.write(writeContent.toUtf8())), writeContent.size()); - qFile.close(); - - // check the content - QFile check("testHandleLifetime"); - check.open(QFile::ReadOnly); - QString content(check.readAll()); - QCOMPARE(content, QLatin1String("test content+closed original handles")); -} - -void tst_qfileopenevent::multiOpen() -{ - RFile rFile = createRFile(_L("testMultiOpen"), _L8("itlum")); - QFileOpenEvent event(rFile); - rFile.Close(); - - QFile files[5]; - for (int i=0; i<5; i++) { - QCOMPARE(event.openFile(files[i], QFile::ReadOnly), true); - } - for (int i=0; i<5; i++) - files[i].seek(i); - QString str; - for (int i=4; i>=0; i--) { - char c; - files[i].getChar(&c); - str.append(c); - files[i].close(); - } - QCOMPARE(str, QLatin1String("multi")); -} - -bool tst_qfileopenevent::event(QEvent *event) -{ - if (event->type() != QEvent::FileOpen) - return QObject::event(event); - QFileOpenEvent* fileOpenEvent = static_cast(event); - appendFileContent(*fileOpenEvent, "+received"); - return true; -} - -void tst_qfileopenevent::sendAndReceive() -{ - RFile rFile = createRFile(_L("testSendAndReceive"), _L8("sending")); - QFileOpenEvent* event = new QFileOpenEvent(rFile); - rFile.Close(); - QCoreApplication::instance()->postEvent(this, event); - QCoreApplication::instance()->processEvents(); - - // check the content - QFile check("testSendAndReceive"); - QCOMPARE(check.open(QFile::ReadOnly), true); - QString content(check.readAll()); - QCOMPARE(content, QLatin1String("sending+received")); -} - -void tst_qfileopenevent::external_data() -{ - QTest::addColumn("filename"); - QTest::addColumn("targetContent"); - QTest::addColumn("sendHandle"); - - QString privateName(QLatin1String("tst_qfileopenevent_external")); - QString publicName(QLatin1String("C:\\Data\\tst_qfileopenevent_external")); - QByteArray writeSuccess("original+external"); - QByteArray writeFail("original"); - QTest::newRow("public name") << publicName << writeSuccess << false; - QTest::newRow("data caged name") << privateName << writeFail << false; - QTest::newRow("public handle") << publicName << writeSuccess << true; - QTest::newRow("data caged handle") << privateName << writeSuccess << true; -} - -void tst_qfileopenevent::external() -{ - QFETCH(QString, filename); - QFETCH(QByteArray, targetContent); - QFETCH(bool, sendHandle); - - RFile rFile = createRFile(qt_QString2TPtrC(filename), _L8("original")); - - // launch app with the file - RApaLsSession apa; - QCOMPARE(apa.Connect(), KErrNone); - TThreadId threadId; - TDataType type(_L8("application/x-tst_qfileopenevent")); - if (sendHandle) { - QCOMPARE(apa.StartDocument(rFile, type, threadId), KErrNone); - rFile.Close(); - } else { - TFileName fullName; - rFile.FullName(fullName); - rFile.Close(); - QCOMPARE(apa.StartDocument(fullName, type, threadId), KErrNone); - } - - // wait for app exit - RThread appThread; - if (appThread.Open(threadId) == KErrNone) { - TRequestStatus status; - appThread.Logon(status); - User::WaitForRequest(status); - } - - // check the contents - QFile check(filename); - QCOMPARE(check.open(QFile::ReadOnly), true); - QCOMPARE(check.readAll(), targetContent); - bool ok = check.remove(); -} - -QTEST_MAIN(tst_qfileopenevent) -#include "tst_qfileopenevent.moc" -#else -QTEST_NOOP_MAIN -#endif diff --git a/tests/auto/symbian/qsymbiantests.pro b/tests/auto/symbian/qsymbiantests.pro index dcace63..a752c86 100644 --- a/tests/auto/symbian/qsymbiantests.pro +++ b/tests/auto/symbian/qsymbiantests.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS = qmainexceptions orientationchange qfileopenevent +SUBDIRS = qmainexceptions orientationchange requires(symbian) -- cgit v0.12 From 6cd0dfcecd3efff882d04bb8c6358c706383a3af Mon Sep 17 00:00:00 2001 From: mread Date: Wed, 19 Jan 2011 12:42:37 +0000 Subject: tst_qfileopenevent changed to run on all platforms The Symbian specific bits are hidden behind #ifdef, but most of this test is valid on all platforms now. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- tests/auto/qfileopenevent/qfileopenevent.pro | 6 +- .../qfileopenevent/test/tst_qfileopenevent.cpp | 115 +++++++++++++++------ 2 files changed, 86 insertions(+), 35 deletions(-) diff --git a/tests/auto/qfileopenevent/qfileopenevent.pro b/tests/auto/qfileopenevent/qfileopenevent.pro index e2bb6d8..45978d7 100644 --- a/tests/auto/qfileopenevent/qfileopenevent.pro +++ b/tests/auto/qfileopenevent/qfileopenevent.pro @@ -1,6 +1,2 @@ TEMPLATE = subdirs -symbian:{ - SUBDIRS = test qfileopeneventexternal -} else { - SUBDIRS = -} +SUBDIRS = test qfileopeneventexternal diff --git a/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp index 77d53aa..4f10d31 100644 --- a/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp +++ b/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp @@ -45,6 +45,7 @@ #ifdef Q_OS_SYMBIAN #include #include "private/qcore_symbian_p.h" +#endif class tst_qfileopenevent : public QObject { @@ -66,28 +67,46 @@ private slots: void external(); private: +#ifdef Q_OS_SYMBIAN RFile createRFile(const TDesC& filename, const TDesC8& content); - void checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk); - QString readFileContent(QFileOpenEvent& event); - bool appendFileContent(QFileOpenEvent& event, const QString& writeContent); +#else + void createFile(const QString &filename, const QByteArray &content); +#endif + QFileOpenEvent * createFileAndEvent(const QString &filename, const QByteArray &content); + void checkReadAndWrite(QFileOpenEvent& event, const QByteArray& readContent, const QByteArray& writeContent, bool writeOk); + QByteArray readFileContent(QFileOpenEvent& event); + bool appendFileContent(QFileOpenEvent& event, const QByteArray& writeContent); bool event(QEvent *); private: - RFs fsSession; +#ifdef Q_OS_SYMBIAN + struct AutoRFs : public RFs + { + AutoRFs() + { + qt_symbian_throwIfError(Connect()); + qt_symbian_throwIfError(ShareProtected()); + } + + ~AutoRFs() + { + Close(); + } + }; + AutoRFs fsSession; +#endif }; tst_qfileopenevent::~tst_qfileopenevent() { - fsSession.Close(); }; void tst_qfileopenevent::initTestCase() { - qt_symbian_throwIfError(fsSession.Connect()); - qt_symbian_throwIfError(fsSession.ShareProtected()); } +#ifdef Q_OS_SYMBIAN RFile tst_qfileopenevent::createRFile(const TDesC& filename, const TDesC8& content) { RFile file; @@ -95,6 +114,27 @@ RFile tst_qfileopenevent::createRFile(const TDesC& filename, const TDesC8& conte qt_symbian_throwIfError(file.Write(content)); return file; } +#else +void tst_qfileopenevent::createFile(const QString &filename, const QByteArray &content) +{ + QFile file(filename); + file.open(QFile::WriteOnly); + file.write(content); + file.close(); +} +#endif + +QFileOpenEvent * tst_qfileopenevent::createFileAndEvent(const QString &filename, const QByteArray &content) +{ +#ifdef Q_OS_SYMBIAN + RFile rFile = createRFile(qt_QString2TPtrC(filename), TPtrC8((TText8*)content.constData(), content.size())); + QScopedPointer > closeRFile(&rFile); + return new QFileOpenEvent(rFile); +#else + createFile(filename, content); + return new QFileOpenEvent(filename); +#endif +} void tst_qfileopenevent::constructor() { @@ -106,6 +146,7 @@ void tst_qfileopenevent::constructor() QFileOpenEvent urlTest(QUrl(QLatin1String("file:///urlNameTest"))); QCOMPARE(urlTest.url().toString(), QLatin1String("file:///urlNameTest")); +#ifdef Q_OS_SYMBIAN // check that RFile construction works RFile rFile = createRFile(_L("testRFile"), _L8("test content")); QFileOpenEvent rFileTest(rFile); @@ -113,27 +154,28 @@ void tst_qfileopenevent::constructor() QCOMPARE(rFileTest.file().right(targetName.size()), targetName); QCOMPARE(rFileTest.url().toString().right(targetName.size()), targetName); rFile.Close(); +#endif } -QString tst_qfileopenevent::readFileContent(QFileOpenEvent& event) +QByteArray tst_qfileopenevent::readFileContent(QFileOpenEvent& event) { QFile file; event.openFile(file, QFile::ReadOnly); file.seek(0); QByteArray data = file.readAll(); - return QString(data); + return data; } -bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QString& writeContent) +bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QByteArray& writeContent) { QFile file; bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered); if (ok) - ok = file.write(writeContent.toUtf8()) == writeContent.size(); + ok = file.write(writeContent) == writeContent.size(); return ok; } -void tst_qfileopenevent::checkReadAndWrite(QFileOpenEvent& event, const QString& readContent, const QString& writeContent, bool writeOk) +void tst_qfileopenevent::checkReadAndWrite(QFileOpenEvent& event, const QByteArray& readContent, const QByteArray& writeContent, bool writeOk) { QCOMPARE(readFileContent(event), readContent); QCOMPARE(appendFileContent(event, writeContent), writeOk); @@ -142,11 +184,12 @@ void tst_qfileopenevent::checkReadAndWrite(QFileOpenEvent& event, const QString& void tst_qfileopenevent::fileOpen() { +#ifdef Q_OS_SYMBIAN // create writeable file { RFile rFile = createRFile(_L("testFileOpen"), _L8("test content")); QFileOpenEvent rFileTest(rFile); - checkReadAndWrite(rFileTest, QLatin1String("test content"), QLatin1String("+RFileWrite"), true); + checkReadAndWrite(rFileTest, QByteArray("test content"), QByteArray("+RFileWrite"), true); rFile.Close(); } @@ -155,30 +198,33 @@ void tst_qfileopenevent::fileOpen() RFile rFile; int err = rFile.Open(fsSession, _L("testFileOpen"), EFileRead); QFileOpenEvent rFileTest(rFile); - checkReadAndWrite(rFileTest, QLatin1String("test content+RFileWrite"), QLatin1String("+RFileRead"), false); + checkReadAndWrite(rFileTest, QByteArray("test content+RFileWrite"), QByteArray("+RFileRead"), false); rFile.Close(); } +#else + createFile(QLatin1String("testFileOpen"), QByteArray("test content+RFileWrite")); +#endif // filename event QUrl fileUrl; // need to get the URL during the file test, for use in the URL test { QFileOpenEvent nameTest(QLatin1String("testFileOpen")); fileUrl = nameTest.url(); - checkReadAndWrite(nameTest, QLatin1String("test content+RFileWrite"), QLatin1String("+nameWrite"), true); + checkReadAndWrite(nameTest, QByteArray("test content+RFileWrite"), QByteArray("+nameWrite"), true); } // url event { QFileOpenEvent urlTest(fileUrl); - checkReadAndWrite(urlTest, QLatin1String("test content+RFileWrite+nameWrite"), QLatin1String("+urlWrite"), true); + checkReadAndWrite(urlTest, QByteArray("test content+RFileWrite+nameWrite"), QByteArray("+urlWrite"), true); } + + QFile::remove(QLatin1String("testFileOpen")); } void tst_qfileopenevent::handleLifetime() { - RFile rFile = createRFile(_L("testHandleLifetime"), _L8("test content")); - QScopedPointer event(new QFileOpenEvent(rFile)); - rFile.Close(); + QScopedPointer event(createFileAndEvent(QLatin1String("testHandleLifetime"), QByteArray("test content"))); // open a QFile after the original RFile is closed QFile qFile; @@ -195,17 +241,18 @@ void tst_qfileopenevent::handleLifetime() check.open(QFile::ReadOnly); QString content(check.readAll()); QCOMPARE(content, QLatin1String("test content+closed original handles")); + check.close(); + + QFile::remove(QLatin1String("testHandleLifetime")); } void tst_qfileopenevent::multiOpen() { - RFile rFile = createRFile(_L("testMultiOpen"), _L8("itlum")); - QFileOpenEvent event(rFile); - rFile.Close(); + QScopedPointer event(createFileAndEvent(QLatin1String("testMultiOpen"), QByteArray("itlum"))); QFile files[5]; for (int i=0; i<5; i++) { - QCOMPARE(event.openFile(files[i], QFile::ReadOnly), true); + QCOMPARE(event->openFile(files[i], QFile::ReadOnly), true); } for (int i=0; i<5; i++) files[i].seek(i); @@ -217,6 +264,8 @@ void tst_qfileopenevent::multiOpen() files[i].close(); } QCOMPARE(str, QLatin1String("multi")); + + QFile::remove(QLatin1String("testMultiOpen")); } bool tst_qfileopenevent::event(QEvent *event) @@ -230,10 +279,9 @@ bool tst_qfileopenevent::event(QEvent *event) void tst_qfileopenevent::sendAndReceive() { - RFile rFile = createRFile(_L("testSendAndReceive"), _L8("sending")); - QFileOpenEvent* event = new QFileOpenEvent(rFile); - rFile.Close(); - QCoreApplication::instance()->postEvent(this, event); + QScopedPointer event(createFileAndEvent(QLatin1String("testSendAndReceive"), QByteArray("sending"))); + + QCoreApplication::instance()->postEvent(this, event.take()); QCoreApplication::instance()->processEvents(); // check the content @@ -241,6 +289,9 @@ void tst_qfileopenevent::sendAndReceive() QCOMPARE(check.open(QFile::ReadOnly), true); QString content(check.readAll()); QCOMPARE(content, QLatin1String("sending+received")); + check.close(); + + QFile::remove(QLatin1String("testSendAndReceive")); } void tst_qfileopenevent::external_data() @@ -261,6 +312,10 @@ void tst_qfileopenevent::external_data() void tst_qfileopenevent::external() { +#ifndef Q_OS_SYMBIAN + QSKIP("external app file open test only valid in Symbian", SkipAll); +#else + QFETCH(QString, filename); QFETCH(QByteArray, targetContent); QFETCH(bool, sendHandle); @@ -295,10 +350,10 @@ void tst_qfileopenevent::external() QCOMPARE(check.open(QFile::ReadOnly), true); QCOMPARE(check.readAll(), targetContent); bool ok = check.remove(); + + QFile::remove(filename); +#endif } QTEST_MAIN(tst_qfileopenevent) #include "tst_qfileopenevent.moc" -#else -QTEST_NOOP_MAIN -#endif -- cgit v0.12 From 4a7d16cf81c0d66f18b228359dbad983d5057ea9 Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 20 Jan 2011 15:44:02 +0000 Subject: Fixed qfilesystemmodel autotest The qfilesystemmodel autotest was failing on Symbian devices where there were bad drives. These do not appear in the file system model root list, but do appear in QDir::drives, giving different results. The test now filters the bad drives out of the drives list before comparing the counts. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index cf0406c..53781c9 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -980,8 +980,12 @@ void tst_QFileSystemModel::drives() model.setRootPath(path); model.fetchMore(QModelIndex()); QFileInfoList drives = QDir::drives(); + int driveCount = 0; + foreach(const QFileInfo& driveRoot, drives) + if (driveRoot.exists()) + driveCount++; QTest::qWait(5000); - QTRY_COMPARE(model.rowCount(), drives.count()); + QTRY_COMPARE(model.rowCount(), driveCount); } void tst_QFileSystemModel::dirsBeforeFiles() -- cgit v0.12 From 4aa2a69e82aa306735884c6c6b763eb2d5cb6c9e Mon Sep 17 00:00:00 2001 From: mread Date: Wed, 26 Jan 2011 14:29:50 +0000 Subject: commented out unused function argument Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- src/gui/s60framework/qs60mainappui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index 8ae43a5..0c99f80 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -405,7 +405,7 @@ void QS60MainAppUi::HandleForegroundEventL(TBool aForeground) /*! \internal */ -TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &aDocumentName, const TDesC8 &/*aTail*/) +TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &/*aDocumentName*/, const TDesC8 &/*aTail*/) { // bypass CEikAppUi::ProcessCommandParametersL(..) which modifies aDocumentName, preventing apparc document opening from working. // The return value is effectively unused in Qt apps (see QS60MainDocument::OpenFileL) -- cgit v0.12 From 50472582da88bcbe2f32f7d0d31c0b74ea362404 Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 27 Jan 2011 11:42:37 +0000 Subject: Removing unnecessary settings from test app .pro file From review, UID does not need to be specified and DEBUGGABLE_UDEBONLY is also unnecessary. Task-number: QTBUG-15015 Reviewed-by: Shane Kearns --- .../qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro b/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro index 1b888b8..b95ed45 100644 --- a/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro +++ b/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro @@ -3,8 +3,6 @@ TARGET = qfileopeneventexternal QT += core gui SOURCES += qfileopeneventexternal.cpp symbian: { - TARGET.UID3 = 0xe9410b39 - MMP_RULES += DEBUGGABLE_UDEBONLY RSS_RULES += "embeddability=KAppEmbeddable;" RSS_RULES.datatype_list += "priority = EDataTypePriorityHigh; type = \"application/x-tst_qfileopenevent\";" LIBS += -lapparc \ -- cgit v0.12 From 6752786243d3aaa463ccf5055b209586aa4c6091 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 4 Feb 2011 13:04:41 +0000 Subject: Added file header autotest detected that qfileopeneventexternal.cpp was failing the licenseCheck (headers) test - so the right header was added Task-number: QTBUG-15015 Reviewed-by: joao --- .../qfileopeneventexternal.cpp | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp index 45e7acc..0a5e032 100644 --- a/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp +++ b/tests/auto/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include #include -- cgit v0.12 From 7ed338b87ae50388101176ee29e72df55208a12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 4 Feb 2011 15:21:25 +0100 Subject: Add QDir/tree benchmark to "trusted" list --- tests/benchmarks/corelib/corelib.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/corelib/corelib.pro b/tests/benchmarks/corelib/corelib.pro index 335280e..a2efe91 100644 --- a/tests/benchmarks/corelib/corelib.pro +++ b/tests/benchmarks/corelib/corelib.pro @@ -11,6 +11,7 @@ TRUSTED_BENCHMARKS += \ kernel/qmetaobject \ kernel/qmetatype \ kernel/qobject \ - thread/qthreadstorage + thread/qthreadstorage \ + io/qdir/tree include(../trusted-benchmarks.pri) \ No newline at end of file -- cgit v0.12 From 20097c27f55d8bc61ba41de5997d25f86daa18ed Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 10 Feb 2011 13:34:20 +0100 Subject: fix QMAKE_COPY_DIR for mingw+sh Task-number: QTBUG-17315 --- mkspecs/win32-g++/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf index 2d9833b..65ae590 100644 --- a/mkspecs/win32-g++/qmake.conf +++ b/mkspecs/win32-g++/qmake.conf @@ -77,7 +77,7 @@ QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain QMAKE_DIR_SEP = / QMAKE_QMAKE ~= s,\\\\,/, QMAKE_COPY = cp - QMAKE_COPY_DIR = xcopy /s /q /y /i + QMAKE_COPY_DIR = cp -r QMAKE_MOVE = mv QMAKE_DEL_FILE = rm QMAKE_MKDIR = mkdir -- cgit v0.12 From 5ec67c969dce335a26c402b73bb19a6751401871 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 10 Feb 2011 14:39:41 +0200 Subject: Fix QFileDialog Symbian native file dialog filename filtering. Now QFileDialog static functions that use Symbian native file dialog should find the same files as non-native QFileDialog for any given filename filter. Task-number: QTBUG-17298 Reviewed-by: Janne Koskinen --- src/gui/dialogs/qfiledialog_symbian.cpp | 52 ++++++++++++--------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/gui/dialogs/qfiledialog_symbian.cpp b/src/gui/dialogs/qfiledialog_symbian.cpp index b8ea5e5..ed98950 100644 --- a/src/gui/dialogs/qfiledialog_symbian.cpp +++ b/src/gui/dialogs/qfiledialog_symbian.cpp @@ -54,6 +54,9 @@ QT_BEGIN_NAMESPACE +extern QStringList qt_make_filter_list(const QString &filter); // defined in qfiledialog.cpp +extern QStringList qt_clean_filter_list(const QString &filter); // defined in qfiledialog.cpp + enum DialogMode { DialogOpen, DialogSave, DialogFolder }; #if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3) class CExtensionFilter : public MAknFileFilter @@ -61,56 +64,39 @@ class CExtensionFilter : public MAknFileFilter public: void setFilter(const QString filter) { - filterList.clear(); - if (filter.left(2) == QLatin1String("*.")) { - //Filter has only extensions - filterList << filter.split(QLatin1String(" ")); - return; - } else { - //Extensions are in parenthesis and there may be several filters - QStringList separatedFilters(filter.split(QLatin1String(";;"))); - for (int i = 0; i < separatedFilters.size(); i++) { - if (separatedFilters.at(i).contains(QLatin1String("(*)"))) { - filterList << QLatin1String("(*)"); - return; - } - } - QRegExp rx(QLatin1String("\\(([^\\)]*)\\)")); - int pos = 0; - while ((pos = rx.indexIn(filter, pos)) != -1) { - filterList << rx.cap(1).split(QLatin1String(" ")); - pos += rx.matchedLength(); - } + QStringList unparsedFiltersList = qt_make_filter_list(filter); + QStringList filterList; + filterRxList.clear(); + + foreach (QString unparsedFilter, unparsedFiltersList) { + filterList << qt_clean_filter_list(unparsedFilter); + } + foreach (QString currentFilter, filterList) { + QRegExp filterRx(currentFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + filterRxList << filterRx; } } TBool Accept(const TDesC &/*aDriveAndPath*/, const TEntry &aEntry) const { - if (aEntry.IsDir()) - return ETrue; - //If no filter for files, all can be accepted - if (filterList.isEmpty()) + if (filterRxList.isEmpty()) return ETrue; - if (filterList == QStringList(QLatin1String("(*)"))) + if (aEntry.IsDir()) return ETrue; - for (int i = 0; i < filterList.size(); ++i) { - QString extension = filterList.at(i); - //remove '*' from the beginning of the extension - if (extension.at(0) == QLatin1Char('*')) - extension = extension.mid(1); - + foreach (QRegExp rx, filterRxList) { QString fileName = qt_TDesC2QString(aEntry.iName); - if (fileName.endsWith(extension)) + if (rx.exactMatch(fileName)) return ETrue; } + return EFalse; } private: - QStringList filterList; + QList filterRxList; }; #endif -- cgit v0.12 From ab38731fe5dcfaa1a7a70bc290a8856b5b01524d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 10 Feb 2011 15:01:58 +0100 Subject: My 4.7.2 changes --- dist/changes-4.7.2 | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/dist/changes-4.7.2 b/dist/changes-4.7.2 index d351856..cf20e2e 100644 --- a/dist/changes-4.7.2 +++ b/dist/changes-4.7.2 @@ -39,8 +39,8 @@ Optimizations QtCore ------ - - foo - * bar + - QStateMachine + * [QTBUG-14491] Fix compilation on AIX 5.3 with gcc. QtGui ----- @@ -73,8 +73,23 @@ QtOpenGL QtScript -------- - - foo - * bar + - QScriptContext + * [QTBUG-17137] Fix crash when generating backtrace involving a + built-in (ECMA) function. + - QScriptEngine + * [QTBUG-16987] Ensure QScriptProgram objects are invalidated + when engine is destroyed. + * [QTBUG-16828] Fix alignment issue causing crashes on platforms + with only 4-byte-aligned malloc'ed memory (e.g. Symbian debug + builds). + * [QTBUG-15144] Fix GC-related crash in QScriptValue::setData(). + * [QTBUG-15079] Fix crash when QScriptClass property getter + returns an invalid value. + * [QTBUG-13440] Fix bug that caused Math.random() not to + produce random values. + - QScriptValue + * [QTBUG-14801] Fix crash in QScriptValue::construct() when + the function throws a non-Object value. QtSql ----- @@ -155,6 +170,11 @@ Qt for Symbian - QLineEdit * [QTBUG-16238] Fix one character displacement for cursor in line edits. + - QtScript + * [QTBUG-16685] Fix crash in JavaScript stack allocator. + * [QTBUG-15847] Add compiler optimizations. + * [QTBUG-14293] Enhanced JavaScript heap allocator. + - qmake & mkspecs * [QT-4193] Only add ICON for application projects in symbianpkgrules.pri * [QTBUG-13159] Allow pkg_prerules and pkg_postrules to be targeted to separate files. -- cgit v0.12 From b5e5f72faea7ae278572660f8fb6968d635e548f Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Thu, 10 Feb 2011 16:17:58 +0100 Subject: fix crash when setting QPROCESS_DEBUG don't pass QStrings to printf, but use qPrintable instead. --- src/corelib/io/qprocess_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index f9f5362..ba61bda 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -645,7 +645,7 @@ void QProcessPrivate::startProcess() if (childPid < 0) { // Cleanup, report error and return #if defined (QPROCESS_DEBUG) - qDebug("qt_fork failed: %s", qt_error_string(lastForkErrno)); + qDebug("qt_fork failed: %s", qPrintable(qt_error_string(lastForkErrno))); #endif processManager()->unlock(); q->setProcessState(QProcess::NotRunning); @@ -849,7 +849,7 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen) qDebug("QProcessPrivate::writeToStdin(%p \"%s\", %lld) == %lld", data, qt_prettyDebug(data, maxlen, 16).constData(), maxlen, written); if (written == -1) - qDebug("QProcessPrivate::writeToStdin(), failed to write (%s)", qt_error_string(errno)); + qDebug("QProcessPrivate::writeToStdin(), failed to write (%s)", qPrintable(qt_error_string(errno))); #endif // If the O_NONBLOCK flag is set and If some data can be written without blocking // the process, write() will transfer what it can and return the number of bytes written. -- cgit v0.12 From 690579bda36ad3ba039431ebaa5d0cb57f4536b9 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 10 Feb 2011 16:05:02 +0100 Subject: Fixed resizing popups with QSizeGrip on X11 Qt::Popup implicitly means Qt::X11BypassWindowManagerHint, and according to ICCCM 4.1.5 window manager should not move or resize windows that have override-redirect flag set (i.e. X11BypassWindowManagerHint). Task-number: QTBUG-11447 Reviewed-by: Olivier Goffart --- src/gui/widgets/qsizegrip.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qsizegrip.cpp b/src/gui/widgets/qsizegrip.cpp index f2ea1bf..630aecf 100644 --- a/src/gui/widgets/qsizegrip.cpp +++ b/src/gui/widgets/qsizegrip.cpp @@ -309,6 +309,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) #ifdef Q_WS_X11 // Use a native X11 sizegrip for "real" top-level windows if supported. if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) + && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint) && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { XEvent xev; xev.xclient.type = ClientMessage; @@ -420,7 +421,8 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e) #ifdef Q_WS_X11 if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) - && tlw->isTopLevel() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) + && tlw->isTopLevel() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint) + && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) return; #endif #ifdef Q_WS_WIN -- cgit v0.12 From 5a1676af979ab75c8939e53e0223ccbea7708de4 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 11 Feb 2011 13:10:12 +0100 Subject: Add experimental support for armCC on Linux Reviewed by our Anttis --- mkspecs/unsupported/linux-armcc/qmake.conf | 32 ++++++++ mkspecs/unsupported/linux-armcc/qplatformdefs.h | 100 ++++++++++++++++++++++++ qmake/generators/unix/unixmake.cpp | 4 +- src/corelib/global/global.pri | 2 +- src/corelib/global/qglobal.h | 8 ++ 5 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 mkspecs/unsupported/linux-armcc/qmake.conf create mode 100644 mkspecs/unsupported/linux-armcc/qplatformdefs.h diff --git a/mkspecs/unsupported/linux-armcc/qmake.conf b/mkspecs/unsupported/linux-armcc/qmake.conf new file mode 100644 index 0000000..77891c3 --- /dev/null +++ b/mkspecs/unsupported/linux-armcc/qmake.conf @@ -0,0 +1,32 @@ +# +# qmake configuration for linux-armcc +# + +MAKEFILE_GENERATOR = UNIX +TARGET_PLATFORM = unix +TEMPLATE = app +CONFIG += qt warn_on release incremental link_prl armcc_linker +QT += core gui +QMAKE_INCREMENTAL_STYLE = sublib + +include(../../common/linux.conf) +include(../../common/armcc.conf) +load(qt_config) + +# use armcc for linking since armlink doesn't understand the arm_linux_config_file option +QMAKE_LINK = armcc +QMAKE_LINK_SHLIB = armcc +QMAKE_LINK_C = armcc +QMAKE_LINK_C_SHLIB = armcc + +QMAKE_LFLAGS_SHLIB += --apcs=/fpic --shared +QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB + +QMAKE_LIBS += libstdc++.so librt.so + +CONFIG -= rvct_linker + +QMAKE_CFLAGS += --gnu --arm_linux --dllimport_runtime --thumb --cpu Cortex-A9 --arm_linux_config_file="$(HOME)/qt_rvct_config" --arm-linux-paths --apcs=/interwork --visibility_inlines_hidden --diag_suppress 1300,2523 +QMAKE_CXXFLAGS += $$QMAKE_CFLAGS --cpp + +QMAKE_LFLAGS += --diag_suppress 6331,6780,6439 --arm_linux_config_file="$(HOME)/qt_rvct_config" --arm-linux-paths diff --git a/mkspecs/unsupported/linux-armcc/qplatformdefs.h b/mkspecs/unsupported/linux-armcc/qplatformdefs.h new file mode 100644 index 0000000..a1ce6a1 --- /dev/null +++ b/mkspecs/unsupported/linux-armcc/qplatformdefs.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMDEFS_H +#define QPLATFORMDEFS_H + +// Get Qt defines/settings + +#include "qglobal.h" + +// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs + +// 1) need to reset default environment if _BSD_SOURCE is defined +// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0 +// 3) it seems older glibc need this to include the X/Open stuff +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif + +#include + + +// We are hot - unistd.h should have turned on the specific APIs we requested + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef QT_NO_IPV6IFNAME +#include +#endif + +#define QT_USE_XOPEN_LFS_EXTENSIONS +#include "../../common/posix/qplatformdefs.h" + +#undef QT_SOCKLEN_T + +#if defined(__GLIBC__) && (__GLIBC__ >= 2) +#define QT_SOCKLEN_T socklen_t +#else +#define QT_SOCKLEN_T int +#endif + +#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) +#define QT_SNPRINTF ::snprintf +#define QT_VSNPRINTF ::vsnprintf +#endif + +#endif // QPLATFORMDEFS_H diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 29d85f7..e659e62 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -148,6 +148,8 @@ UnixMakefileGenerator::init() project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + libdirs[i]; if (project->isActiveConfig("rvct_linker")) { project->values("QMAKE_LIBDIR_FLAGS") += "--userlibpath " + escapeFilePath(libdirs[i]); + } else if (project->isActiveConfig("armcc_linker")) { + project->values("QMAKE_LIBDIR_FLAGS") += "-L--userlibpath=" + escapeFilePath(libdirs[i]); } else { project->values("QMAKE_LIBDIR_FLAGS") += "-L" + escapeFilePath(libdirs[i]); } @@ -486,7 +488,7 @@ UnixMakefileGenerator::findLibraries() } else if(opt.startsWith("-l")) { if (!project->isEmpty("QMAKE_RVCT_LINKSTYLE")) { (*it) = opt.mid(2); - } else if (project->isActiveConfig("rvct_linker")) { + } else if (project->isActiveConfig("rvct_linker") || project->isActiveConfig("armcc_linker")) { (*it) = "lib" + opt.mid(2) + ".so"; } else { stub = opt.mid(2); diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 8eae391..83caa96 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -23,7 +23,7 @@ INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global # Only used on platforms with CONFIG += precompile_header PRECOMPILED_HEADER = global/qt_pch.h -linux*:!static:!symbian-armcc:!symbian-gcce { +linux*:!static:!symbian-gcce:!*-armcc* { QMAKE_LFLAGS += -Wl,-e,qt_core_boilerplate prog=$$quote(if (/program interpreter: (.*)]/) { print $1; }) DEFINES += ELF_INTERPRETER=\\\"$$system(readelf -l /bin/ls | perl -n -e \'$$prog\')\\\" diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 2a41b9e..960fe6e 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -448,6 +448,9 @@ namespace QT_NAMESPACE {} # if __TARGET_ARCH_ARM >= 6 # define QT_HAVE_ARMV6 # endif +/* work-around for missing compiler intrinsics */ +# define __is_empty(X) false +# define __is_pod(X) false #elif defined(__GNUC__) # define Q_CC_GNU # define Q_C_CALLBACKS @@ -1199,6 +1202,11 @@ class QDataStream; #define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE)) +#if defined(Q_OS_LINUX) && defined(Q_CC_RVCT) +# define Q_DECL_EXPORT __attribute__((visibility("default"))) +# define Q_DECL_IMPORT __attribute__((visibility("default"))) +#endif + #ifndef Q_DECL_EXPORT # if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) # define Q_DECL_EXPORT __declspec(dllexport) -- cgit v0.12 From 7478b7f696c66f19dd91fc0be8ecb53def7f5354 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 14 Feb 2011 09:32:26 +0100 Subject: Cocoa/Alien: bugfix corner cases with popups and enter/leave It turns out that we sometimes hit a strange bug with enter/leave events when a popup is showing. If you righpress to show the popup, and then move the mouse outside the window, we get a continues series of leave events. This patch separates more the native vs alien logic for dispatching enter/leave to accommondate this problem --- src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 4 +++ src/gui/kernel/qcocoaview_mac.mm | 2 ++ src/gui/kernel/qt_cocoa_helpers_mac.mm | 33 ++++++++++++------------- src/gui/kernel/qwidget_mac.mm | 7 +++++- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 6d7bc19..77cd890 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -91,6 +91,7 @@ QT_BEGIN_NAMESPACE extern void onApplicationChangedActivation(bool); // qapplication_mac.mm extern void qt_release_apple_event_handler(); //qapplication_mac.mm extern QPointer qt_last_mouse_receiver; // qapplication_mac.cpp +extern QPointer qt_last_native_mouse_receiver; // qt_cocoa_helpers_mac.mm extern QPointer qt_button_down; // qapplication_mac.cpp QT_END_NAMESPACE @@ -268,6 +269,8 @@ static void cleanupCocoaApplicationDelegate() qt_mac_getTargetForMouseEvent(0, QEvent::Enter, qlocal, qglobal, 0, &widgetUnderMouse); QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, 0); qt_last_mouse_receiver = widgetUnderMouse; + qt_last_native_mouse_receiver = widgetUnderMouse ? + (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0; } } @@ -282,6 +285,7 @@ static void cleanupCocoaApplicationDelegate() if (!QWidget::mouseGrabber()) QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver); qt_last_mouse_receiver = 0; + qt_last_native_mouse_receiver = 0; qt_button_down = 0; } diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index f0ae886..3d87a9e 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -78,6 +78,7 @@ QT_BEGIN_NAMESPACE extern void qt_mac_update_cursor(); // qcursor_mac.mm extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp extern QPointer qt_last_mouse_receiver; // qapplication_mac.cpp +extern QPointer qt_last_native_mouse_receiver; // qt_cocoa_helpers_mac.mm extern OSViewRef qt_mac_nativeview_for(const QWidget *w); // qwidget_mac.mm extern OSViewRef qt_mac_effectiveview_for(const QWidget *w); // qwidget_mac.mm extern QPointer qt_button_down; //qapplication_mac.cpp @@ -461,6 +462,7 @@ static int qCocoaViewCount = 0; if (widgetUnderMouse == 0) { QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver); qt_last_mouse_receiver = 0; + qt_last_native_mouse_receiver = 0; } } } diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e50bdd3..c8132e8 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1064,7 +1064,7 @@ QWidget *qt_mac_getTargetForMouseEvent( // Resolve the widget under the mouse: QWidget *widgetUnderMouse = 0; - if (popup || qt_button_down || !nativeWidget) { + if (popup || qt_button_down || !nativeWidget || !nativeWidget->isVisible()) { // Using QApplication::widgetAt for finding the widget under the mouse // is most safe, since it ignores cocoas own mouse down redirections (which // we need to be prepared for when using nativeWidget as starting point). @@ -1139,6 +1139,8 @@ QWidget *qt_mac_getTargetForMouseEvent( return target; } +QPointer qt_last_native_mouse_receiver = 0; + static inline void qt_mac_checkEnterLeaveForNativeWidgets(QWidget *maybeEnterWidget) { // Dispatch enter/leave for the cases where QApplicationPrivate::sendMouseEvent do @@ -1149,29 +1151,25 @@ static inline void qt_mac_checkEnterLeaveForNativeWidgets(QWidget *maybeEnterWid if (qt_button_down || QWidget::mouseGrabber()) return; - if ((maybeEnterWidget == qt_last_mouse_receiver) && qt_last_mouse_receiver) - return; + if ((maybeEnterWidget == qt_last_native_mouse_receiver) && qt_last_native_mouse_receiver) + return; if (maybeEnterWidget) { - if (!qt_last_mouse_receiver) { + if (!qt_last_native_mouse_receiver) { // case 3 QApplicationPrivate::dispatchEnterLeave(maybeEnterWidget, 0); - qt_last_mouse_receiver = maybeEnterWidget; - } else if (qt_last_mouse_receiver->internalWinId() && maybeEnterWidget->internalWinId()) { + qt_last_native_mouse_receiver = maybeEnterWidget->internalWinId() ? maybeEnterWidget : maybeEnterWidget->nativeParentWidget(); + } else if (maybeEnterWidget->internalWinId()) { // case 1 - if (qt_last_mouse_receiver->isVisible()) { - QApplicationPrivate::dispatchEnterLeave(maybeEnterWidget, qt_last_mouse_receiver); - qt_last_mouse_receiver = maybeEnterWidget; - } + QApplicationPrivate::dispatchEnterLeave(maybeEnterWidget, qt_last_native_mouse_receiver); + qt_last_native_mouse_receiver = maybeEnterWidget->internalWinId() ? maybeEnterWidget : maybeEnterWidget->nativeParentWidget(); } // else at lest one of the widgets are alien, so enter/leave will be handled in QApplicationPrivate } else { - if (qt_last_mouse_receiver && qt_last_mouse_receiver->internalWinId()) { + if (qt_last_native_mouse_receiver) { // case 2 - QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver); - // This seems to be the only case where we need to update qt_last_mouse_receiver - // from the mac specific code. Otherwise, QApplicationPrivate::sendMouseEvent - // will handle it: + QApplicationPrivate::dispatchEnterLeave(0, qt_last_native_mouse_receiver); qt_last_mouse_receiver = 0; + qt_last_native_mouse_receiver = 0; } } } @@ -1276,8 +1274,9 @@ bool qt_mac_handleMouseEvent(NSEvent *event, QEvent::Type eventType, Qt::MouseBu if (eventType == QEvent::MouseButtonRelease) { // A mouse button was released, which means that the implicit grab was // released. We therefore need to re-check if should send (delayed) enter leave events: - // qt_button_down has now become NULL since the call at the top of the function. - widgetToGetMouse = qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, nativeWidget, &widgetUnderMouse); + // qt_button_down has now become NULL since the call at the top of the function. Also, since + // the relase might have closed a window, we dont give the nativeWidget hint + qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, nativeWidget, &widgetUnderMouse); qt_mac_checkEnterLeaveForNativeWidgets(widgetUnderMouse); } diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 3ba12cd..9a5a5f1 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -186,6 +186,7 @@ extern void qt_mac_event_release(QWidget *w); //qapplication_mac.mm extern void qt_event_request_showsheet(QWidget *); //qapplication_mac.mm extern void qt_event_request_window_change(QWidget *); //qapplication_mac.mm extern QPointer qt_last_mouse_receiver; //qapplication_mac.mm +extern QPointer qt_last_native_mouse_receiver; //qt_cocoa_helpers_mac.mm extern IconRef qt_mac_create_iconref(const QPixmap &); //qpixmap_mac.cpp extern void qt_mac_set_cursor(const QCursor *, const QPoint &); //qcursor_mac.mm extern void qt_mac_update_cursor(); //qcursor_mac.mm @@ -3524,6 +3525,8 @@ void QWidgetPrivate::show_sys() qt_mac_getTargetForMouseEvent(0, QEvent::Enter, qlocal, qglobal, 0, &widgetUnderMouse); QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, qt_last_mouse_receiver); qt_last_mouse_receiver = widgetUnderMouse; + qt_last_native_mouse_receiver = widgetUnderMouse ? + (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0; } #endif @@ -3676,8 +3679,10 @@ void QWidgetPrivate::hide_sys() QPoint qlocal, qglobal; QWidget *widgetUnderMouse = 0; qt_mac_getTargetForMouseEvent(0, QEvent::Leave, qlocal, qglobal, 0, &widgetUnderMouse); - QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, qt_last_mouse_receiver); + QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, qt_last_native_mouse_receiver); qt_last_mouse_receiver = widgetUnderMouse; + qt_last_native_mouse_receiver = widgetUnderMouse ? + (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0; } #endif -- cgit v0.12 From 78f2ae9c13db383e8aa4f303d0c9ba2c80239c38 Mon Sep 17 00:00:00 2001 From: Eckhart Koppen Date: Mon, 14 Feb 2011 12:00:41 +0200 Subject: Updated QtGui and QtCore DEF files Added new functions needed for QtDeclarative Reviewed-by: TrustMe --- src/s60installs/bwins/QtCoreu.def | 2 ++ src/s60installs/bwins/QtGuiu.def | 4 ++++ src/s60installs/eabi/QtCoreu.def | 2 ++ src/s60installs/eabi/QtGuiu.def | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index a2692f7..dd7d588 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4603,4 +4603,6 @@ EXPORTS ??XQPoint@@QAEAAV0@N@Z @ 4602 NONAME ; class QPoint & QPoint::operator*=(double) ??XQPoint@@QAEAAV0@H@Z @ 4603 NONAME ; class QPoint & QPoint::operator*=(int) ?hasError@QXmlStreamWriter@@QBE_NXZ @ 4604 NONAME ; bool QXmlStreamWriter::hasError(void) const + ?revision@QMetaProperty@@QBEHXZ @ 4605 NONAME ; int QMetaProperty::revision(void) const + ?revision@QMetaMethod@@QBEHXZ @ 4606 NONAME ; int QMetaMethod::revision(void) const diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 322d88b..057238c 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -13142,4 +13142,8 @@ EXPORTS ?viewportSize@QScrollPrepareEvent@@QBE?AVQSizeF@@XZ @ 13141 NONAME ; class QSizeF QScrollPrepareEvent::viewportSize(void) const ?staticMetaObject@QScroller@@2UQMetaObject@@B @ 13142 NONAME ; struct QMetaObject const QScroller::staticMetaObject ?staticMetaObject@QFlickGesture@@2UQMetaObject@@B @ 13143 NONAME ; struct QMetaObject const QFlickGesture::staticMetaObject + ?isDragEnabled@QTextControl@@QBE_NXZ @ 13144 NONAME ; bool QTextControl::isDragEnabled(void) const + ?setWordSelectionEnabled@QTextControl@@QAEX_N@Z @ 13145 NONAME ; void QTextControl::setWordSelectionEnabled(bool) + ?setDragEnabled@QTextControl@@QAEX_N@Z @ 13146 NONAME ; void QTextControl::setDragEnabled(bool) + ?isWordSelectionEnabled@QTextControl@@QBE_NXZ @ 13147 NONAME ; bool QTextControl::isWordSelectionEnabled(void) const diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 0488d0c..207447f 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3804,4 +3804,6 @@ EXPORTS _ZN23QCoreApplicationPrivate18symbianCommandLineEv @ 3803 NONAME _ZNK16QXmlStreamWriter8hasErrorEv @ 3804 NONAME _ZNK13QElapsedTimer12nsecsElapsedEv @ 3805 NONAME + _ZNK11QMetaMethod8revisionEv @ 3806 NONAME + _ZNK13QMetaProperty8revisionEv @ 3807 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 8064fa3..e52b504 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12333,4 +12333,8 @@ EXPORTS _ZTV19QScrollPrepareEvent @ 12332 NONAME _ZTV19QScrollerProperties @ 12333 NONAME _ZTV9QScroller @ 12334 NONAME + _ZN12QTextControl14setDragEnabledEb @ 12335 NONAME + _ZN12QTextControl23setWordSelectionEnabledEb @ 12336 NONAME + _ZNK12QTextControl13isDragEnabledEv @ 12337 NONAME + _ZNK12QTextControl22isWordSelectionEnabledEv @ 12338 NONAME -- cgit v0.12 From b8dd212347560a8c360e31135ef43669cb4ca3e5 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 1 Feb 2011 08:52:05 +0000 Subject: Idle detector thread improvements The idle detector thread was creating its own heap, which was rather unnnecesary as it doesn't actually allocate any objects. Now it shares the main thread's heap. It was also unnamed, which makes life harder when there is a crash. The debugger is given information about all threads in a crash. When a thread is unnamed, you can't easily tell if its relevant to the crash or not. Now it is called "IdleDetectorThread". Task-number: QTBUG-17073 Reviewed-by: axis --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 8872045..d6ab618a 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -657,7 +657,7 @@ public: : m_state(STATE_RUN), m_stop(false) { qt_symbian_throwIfError(m_lock.CreateLocal(0)); - TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, NULL, this); + TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, &User::Allocator(), this); if (err != KErrNone) m_lock.Close(); qt_symbian_throwIfError(err); @@ -692,6 +692,7 @@ public: private: static TInt idleDetectorThreadFunc(TAny* self) { + User::RenameThread(_L("IdleDetectorThread")); static_cast(self)->IdleLoop(); return KErrNone; } -- cgit v0.12 From 1ee9a0865bffd2dc1edc850995ab7ae8da7e1f34 Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 3 Feb 2011 10:29:28 +0000 Subject: Using QElapesedTimer for Symbian idle detector QElapsedTimer is used instead of QTime for event timing in Symbian's idle detector. Task-number: QTBUG-10120 Reviewed-by: Shane Kearns --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 2 +- src/corelib/kernel/qeventdispatcher_symbian_p.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index d6ab618a..53796be 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -810,7 +810,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla m_interrupt = false; #ifdef QT_SYMBIAN_PRIORITY_DROP - QTime eventTimer; + QElapsedTimer eventTimer; #endif while (1) { diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index b785aea..bdb6dce 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -63,6 +63,7 @@ #include #include #include +#include #include @@ -284,7 +285,7 @@ private: int m_delay; int m_avgEventTime; - QTime m_lastIdleRequestTimer; + QElapsedTimer m_lastIdleRequestTimer; }; #ifdef QT_DEBUG -- cgit v0.12 From f8810c52ff754630ee99711fe7a479f8e4967dfa Mon Sep 17 00:00:00 2001 From: mread Date: Thu, 3 Feb 2011 14:51:48 +0000 Subject: Using a better flag to control the fast allocator The Qt fast allocator should be used on any Symbian platform where it is not supplied by euser. But it's better if the code is not there when euser provides the fast allocator as euser's implementation will be better maintained. The previous flag SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS was only associated with euser's fast allocator in S60 10.1. __SYMBIAN_KERNEL_HYBRID_HEAP__ is more accurately associated with it in the new MCL. Task-number: QTBUG-15901 Reviewed-by: Miikka Heikkinen --- src/corelib/arch/symbian/qt_hybridheap_symbian_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/arch/symbian/qt_hybridheap_symbian_p.h b/src/corelib/arch/symbian/qt_hybridheap_symbian_p.h index 4eff0f3..d1ce705 100644 --- a/src/corelib/arch/symbian/qt_hybridheap_symbian_p.h +++ b/src/corelib/arch/symbian/qt_hybridheap_symbian_p.h @@ -43,8 +43,9 @@ #define QT_HYBRIDHEAP_SYMBIAN_H #include +#include -#if !defined(SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS) && !defined(__WINS__) +#if !defined(__SYMBIAN_KERNEL_HYBRID_HEAP__) && !defined(__WINS__) //Enable the (backported) new allocator. When it is available in OS, //this flag should be disabled for that OS version onward #define QT_USE_NEW_SYMBIAN_ALLOCATOR -- cgit v0.12 From cbd778fd823383ec97c4bd27671367da29770f60 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Wed, 9 Feb 2011 10:59:07 +0200 Subject: Phonon MMF backend enabled in configuration and deployment --- config.profiles/symbian/bld.inf | 2 +- config.profiles/symbian/qt.iby | 4 ++-- config.profiles/symbian/qt.pkg | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config.profiles/symbian/bld.inf b/config.profiles/symbian/bld.inf index d2d959b..ddb5157 100644 --- a/config.profiles/symbian/bld.inf +++ b/config.profiles/symbian/bld.inf @@ -78,5 +78,5 @@ translations/qt_zh_tw_symbian.ts /epoc32/include/platform/qt/translations/qt_zh_ PRJ_EXTENSIONS START EXTENSION qt/qtconfig OPTION QT_ROOT .. -OPTION OPTIONS -opensource -confirm-license -openvg -opengl-es-2 -script -no-scripttools -no-webkit -make make -graphicssystem openvg -no-phonon-backend -usedeffiles -dont-process -nomake examples -nomake demos -nomake tools -audio-backend -fpu softvfp+vfpv2 +OPTION OPTIONS -opensource -confirm-license -openvg -opengl-es-2 -script -no-scripttools -no-webkit -make make -graphicssystem openvg -phonon -phonon-backend -usedeffiles -dont-process -nomake examples -nomake demos -nomake tools -audio-backend -fpu softvfp+vfpv2 END \ No newline at end of file diff --git a/config.profiles/symbian/qt.iby b/config.profiles/symbian/qt.iby index 2b3be0a..7431cfa 100644 --- a/config.profiles/symbian/qt.iby +++ b/config.profiles/symbian/qt.iby @@ -43,8 +43,8 @@ file=ABI_DIR\BUILD_DIR\qsvgicon.dll SHARED_LIB_DIR\qsvgicon.dll // This is commented out by default, as normally Helix backend will be used. // If the Helix backend is present, it will override MMF backend, so make sure to remove it from // image creation in addition to uncommenting the following lines if you want to use MMF backend. -//file=ABI_DIR\BUILD_DIR\phonon_mmf.dll SHARED_LIB_DIR\phonon_mmf.dll -//data=\epoc32\data\z\resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin +file=ABI_DIR\BUILD_DIR\phonon_mmf.dll SHARED_LIB_DIR\phonon_mmf.dll +data=\epoc32\data\z\resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin // QtMultimedia audio backend file=ABI_DIR\BUILD_DIR\qaudio.dll SHARED_LIB_DIR\qaudio.dll diff --git a/config.profiles/symbian/qt.pkg b/config.profiles/symbian/qt.pkg index 7bd1c59..6ef51ce 100644 --- a/config.profiles/symbian/qt.pkg +++ b/config.profiles/symbian/qt.pkg @@ -62,7 +62,12 @@ "/epoc32/data/z/resource/qt/plugins/graphicssystems/qglgraphicssystem.qtplugin" - "!:\resource\qt\plugins\graphicssystems\qglgraphicssystem.qtplugin" "/epoc32/release/armv5/urel/qsvgicon.dll" - "!:\sys\bin\qsvgicon.dll" "/epoc32/data/z/resource/qt/plugins/iconengines/qsvgicon.qtplugin" - "!:\resource\qt\plugins\iconengines\qsvgicon.qtplugin" -"/epoc32/data/z/resource/qt/plugins/bearer/qsymbianbearer.qtplugin" - "c:\resource\qt\plugins\bearer\qsymbianbearer.qtplugin" +"/epoc32/data/z/resource/qt/plugins/bearer/qsymbianbearer.qtplugin" - "!:\resource\qt\plugins\bearer\qsymbianbearer.qtplugin" + +; Phonon MMF plugin +"/epoc32/release/armv5/urel/phonon_mmf.dll" - "!:\sys\bin\phonon_mmf.dll" +"/epoc32/data/z/resource/qt/plugins/phonon_backend/phonon_mmf.qtplugin" - "!:\resource\qt\plugins\phonon_backend\phonon_mmf.qtplugin" + "/epoc32/release/armv5/urel/qts60plugin_5_0.dll" - "!:\sys\bin\qts60plugin_5_0.dll" -- cgit v0.12 From 385423699baaec001417cf672b75c54b43ebb9ce Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 10 Feb 2011 13:34:20 +0100 Subject: fix QMAKE_COPY_DIR for mingw+sh Task-number: QTBUG-17315 --- mkspecs/win32-g++/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf index 2d9833b..65ae590 100644 --- a/mkspecs/win32-g++/qmake.conf +++ b/mkspecs/win32-g++/qmake.conf @@ -77,7 +77,7 @@ QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain QMAKE_DIR_SEP = / QMAKE_QMAKE ~= s,\\\\,/, QMAKE_COPY = cp - QMAKE_COPY_DIR = xcopy /s /q /y /i + QMAKE_COPY_DIR = cp -r QMAKE_MOVE = mv QMAKE_DEL_FILE = rm QMAKE_MKDIR = mkdir -- cgit v0.12 From 9c1f0a1a80cf67a9e6f6d44eff8a946bc7a22c91 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 10 Feb 2011 14:39:41 +0200 Subject: Fix QFileDialog Symbian native file dialog filename filtering. Now QFileDialog static functions that use Symbian native file dialog should find the same files as non-native QFileDialog for any given filename filter. Task-number: QTBUG-17298 Reviewed-by: Janne Koskinen --- src/gui/dialogs/qfiledialog_symbian.cpp | 52 ++++++++++++--------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/gui/dialogs/qfiledialog_symbian.cpp b/src/gui/dialogs/qfiledialog_symbian.cpp index b8ea5e5..ed98950 100644 --- a/src/gui/dialogs/qfiledialog_symbian.cpp +++ b/src/gui/dialogs/qfiledialog_symbian.cpp @@ -54,6 +54,9 @@ QT_BEGIN_NAMESPACE +extern QStringList qt_make_filter_list(const QString &filter); // defined in qfiledialog.cpp +extern QStringList qt_clean_filter_list(const QString &filter); // defined in qfiledialog.cpp + enum DialogMode { DialogOpen, DialogSave, DialogFolder }; #if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3) class CExtensionFilter : public MAknFileFilter @@ -61,56 +64,39 @@ class CExtensionFilter : public MAknFileFilter public: void setFilter(const QString filter) { - filterList.clear(); - if (filter.left(2) == QLatin1String("*.")) { - //Filter has only extensions - filterList << filter.split(QLatin1String(" ")); - return; - } else { - //Extensions are in parenthesis and there may be several filters - QStringList separatedFilters(filter.split(QLatin1String(";;"))); - for (int i = 0; i < separatedFilters.size(); i++) { - if (separatedFilters.at(i).contains(QLatin1String("(*)"))) { - filterList << QLatin1String("(*)"); - return; - } - } - QRegExp rx(QLatin1String("\\(([^\\)]*)\\)")); - int pos = 0; - while ((pos = rx.indexIn(filter, pos)) != -1) { - filterList << rx.cap(1).split(QLatin1String(" ")); - pos += rx.matchedLength(); - } + QStringList unparsedFiltersList = qt_make_filter_list(filter); + QStringList filterList; + filterRxList.clear(); + + foreach (QString unparsedFilter, unparsedFiltersList) { + filterList << qt_clean_filter_list(unparsedFilter); + } + foreach (QString currentFilter, filterList) { + QRegExp filterRx(currentFilter, Qt::CaseInsensitive, QRegExp::Wildcard); + filterRxList << filterRx; } } TBool Accept(const TDesC &/*aDriveAndPath*/, const TEntry &aEntry) const { - if (aEntry.IsDir()) - return ETrue; - //If no filter for files, all can be accepted - if (filterList.isEmpty()) + if (filterRxList.isEmpty()) return ETrue; - if (filterList == QStringList(QLatin1String("(*)"))) + if (aEntry.IsDir()) return ETrue; - for (int i = 0; i < filterList.size(); ++i) { - QString extension = filterList.at(i); - //remove '*' from the beginning of the extension - if (extension.at(0) == QLatin1Char('*')) - extension = extension.mid(1); - + foreach (QRegExp rx, filterRxList) { QString fileName = qt_TDesC2QString(aEntry.iName); - if (fileName.endsWith(extension)) + if (rx.exactMatch(fileName)) return ETrue; } + return EFalse; } private: - QStringList filterList; + QList filterRxList; }; #endif -- cgit v0.12 From e5152123c7fea830c522916a2bb9c16583d5f666 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 10 Feb 2011 15:01:58 +0100 Subject: My 4.7.2 changes --- dist/changes-4.7.2 | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/dist/changes-4.7.2 b/dist/changes-4.7.2 index 03a5408..17a066f 100644 --- a/dist/changes-4.7.2 +++ b/dist/changes-4.7.2 @@ -39,8 +39,8 @@ Optimizations QtCore ------ - - foo - * bar + - QStateMachine + * [QTBUG-14491] Fix compilation on AIX 5.3 with gcc. QtGui ----- @@ -73,8 +73,23 @@ QtOpenGL QtScript -------- - - foo - * bar + - QScriptContext + * [QTBUG-17137] Fix crash when generating backtrace involving a + built-in (ECMA) function. + - QScriptEngine + * [QTBUG-16987] Ensure QScriptProgram objects are invalidated + when engine is destroyed. + * [QTBUG-16828] Fix alignment issue causing crashes on platforms + with only 4-byte-aligned malloc'ed memory (e.g. Symbian debug + builds). + * [QTBUG-15144] Fix GC-related crash in QScriptValue::setData(). + * [QTBUG-15079] Fix crash when QScriptClass property getter + returns an invalid value. + * [QTBUG-13440] Fix bug that caused Math.random() not to + produce random values. + - QScriptValue + * [QTBUG-14801] Fix crash in QScriptValue::construct() when + the function throws a non-Object value. QtSql ----- @@ -171,6 +186,11 @@ Qt for Symbian - QLineEdit * [QTBUG-16238] Fix one character displacement for cursor in line edits. + - QtScript + * [QTBUG-16685] Fix crash in JavaScript stack allocator. + * [QTBUG-15847] Add compiler optimizations. + * [QTBUG-14293] Enhanced JavaScript heap allocator. + - qmake & mkspecs * [QT-4193] Only add ICON for application projects in symbianpkgrules.pri * [QTBUG-13159] Allow pkg_prerules and pkg_postrules to be targeted to separate files. -- cgit v0.12 From 6415f2814ae30d162e335d1ffd6d093b12701f03 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 14 Feb 2011 09:32:26 +0100 Subject: Cocoa/Alien: bugfix corner cases with popups and enter/leave It turns out that we sometimes hit a strange bug with enter/leave events when a popup is showing. If you righpress to show the popup, and then move the mouse outside the window, we get a continues series of leave events. This patch separates more the native vs alien logic for dispatching enter/leave to accommondate this problem --- src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 4 +++ src/gui/kernel/qcocoaview_mac.mm | 2 ++ src/gui/kernel/qt_cocoa_helpers_mac.mm | 33 ++++++++++++------------- src/gui/kernel/qwidget_mac.mm | 7 +++++- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 6d7bc19..77cd890 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -91,6 +91,7 @@ QT_BEGIN_NAMESPACE extern void onApplicationChangedActivation(bool); // qapplication_mac.mm extern void qt_release_apple_event_handler(); //qapplication_mac.mm extern QPointer qt_last_mouse_receiver; // qapplication_mac.cpp +extern QPointer qt_last_native_mouse_receiver; // qt_cocoa_helpers_mac.mm extern QPointer qt_button_down; // qapplication_mac.cpp QT_END_NAMESPACE @@ -268,6 +269,8 @@ static void cleanupCocoaApplicationDelegate() qt_mac_getTargetForMouseEvent(0, QEvent::Enter, qlocal, qglobal, 0, &widgetUnderMouse); QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, 0); qt_last_mouse_receiver = widgetUnderMouse; + qt_last_native_mouse_receiver = widgetUnderMouse ? + (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0; } } @@ -282,6 +285,7 @@ static void cleanupCocoaApplicationDelegate() if (!QWidget::mouseGrabber()) QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver); qt_last_mouse_receiver = 0; + qt_last_native_mouse_receiver = 0; qt_button_down = 0; } diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index f0ae886..3d87a9e 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -78,6 +78,7 @@ QT_BEGIN_NAMESPACE extern void qt_mac_update_cursor(); // qcursor_mac.mm extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp extern QPointer qt_last_mouse_receiver; // qapplication_mac.cpp +extern QPointer qt_last_native_mouse_receiver; // qt_cocoa_helpers_mac.mm extern OSViewRef qt_mac_nativeview_for(const QWidget *w); // qwidget_mac.mm extern OSViewRef qt_mac_effectiveview_for(const QWidget *w); // qwidget_mac.mm extern QPointer qt_button_down; //qapplication_mac.cpp @@ -461,6 +462,7 @@ static int qCocoaViewCount = 0; if (widgetUnderMouse == 0) { QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver); qt_last_mouse_receiver = 0; + qt_last_native_mouse_receiver = 0; } } } diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e50bdd3..c8132e8 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1064,7 +1064,7 @@ QWidget *qt_mac_getTargetForMouseEvent( // Resolve the widget under the mouse: QWidget *widgetUnderMouse = 0; - if (popup || qt_button_down || !nativeWidget) { + if (popup || qt_button_down || !nativeWidget || !nativeWidget->isVisible()) { // Using QApplication::widgetAt for finding the widget under the mouse // is most safe, since it ignores cocoas own mouse down redirections (which // we need to be prepared for when using nativeWidget as starting point). @@ -1139,6 +1139,8 @@ QWidget *qt_mac_getTargetForMouseEvent( return target; } +QPointer qt_last_native_mouse_receiver = 0; + static inline void qt_mac_checkEnterLeaveForNativeWidgets(QWidget *maybeEnterWidget) { // Dispatch enter/leave for the cases where QApplicationPrivate::sendMouseEvent do @@ -1149,29 +1151,25 @@ static inline void qt_mac_checkEnterLeaveForNativeWidgets(QWidget *maybeEnterWid if (qt_button_down || QWidget::mouseGrabber()) return; - if ((maybeEnterWidget == qt_last_mouse_receiver) && qt_last_mouse_receiver) - return; + if ((maybeEnterWidget == qt_last_native_mouse_receiver) && qt_last_native_mouse_receiver) + return; if (maybeEnterWidget) { - if (!qt_last_mouse_receiver) { + if (!qt_last_native_mouse_receiver) { // case 3 QApplicationPrivate::dispatchEnterLeave(maybeEnterWidget, 0); - qt_last_mouse_receiver = maybeEnterWidget; - } else if (qt_last_mouse_receiver->internalWinId() && maybeEnterWidget->internalWinId()) { + qt_last_native_mouse_receiver = maybeEnterWidget->internalWinId() ? maybeEnterWidget : maybeEnterWidget->nativeParentWidget(); + } else if (maybeEnterWidget->internalWinId()) { // case 1 - if (qt_last_mouse_receiver->isVisible()) { - QApplicationPrivate::dispatchEnterLeave(maybeEnterWidget, qt_last_mouse_receiver); - qt_last_mouse_receiver = maybeEnterWidget; - } + QApplicationPrivate::dispatchEnterLeave(maybeEnterWidget, qt_last_native_mouse_receiver); + qt_last_native_mouse_receiver = maybeEnterWidget->internalWinId() ? maybeEnterWidget : maybeEnterWidget->nativeParentWidget(); } // else at lest one of the widgets are alien, so enter/leave will be handled in QApplicationPrivate } else { - if (qt_last_mouse_receiver && qt_last_mouse_receiver->internalWinId()) { + if (qt_last_native_mouse_receiver) { // case 2 - QApplicationPrivate::dispatchEnterLeave(0, qt_last_mouse_receiver); - // This seems to be the only case where we need to update qt_last_mouse_receiver - // from the mac specific code. Otherwise, QApplicationPrivate::sendMouseEvent - // will handle it: + QApplicationPrivate::dispatchEnterLeave(0, qt_last_native_mouse_receiver); qt_last_mouse_receiver = 0; + qt_last_native_mouse_receiver = 0; } } } @@ -1276,8 +1274,9 @@ bool qt_mac_handleMouseEvent(NSEvent *event, QEvent::Type eventType, Qt::MouseBu if (eventType == QEvent::MouseButtonRelease) { // A mouse button was released, which means that the implicit grab was // released. We therefore need to re-check if should send (delayed) enter leave events: - // qt_button_down has now become NULL since the call at the top of the function. - widgetToGetMouse = qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, nativeWidget, &widgetUnderMouse); + // qt_button_down has now become NULL since the call at the top of the function. Also, since + // the relase might have closed a window, we dont give the nativeWidget hint + qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, nativeWidget, &widgetUnderMouse); qt_mac_checkEnterLeaveForNativeWidgets(widgetUnderMouse); } diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 3ba12cd..9a5a5f1 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -186,6 +186,7 @@ extern void qt_mac_event_release(QWidget *w); //qapplication_mac.mm extern void qt_event_request_showsheet(QWidget *); //qapplication_mac.mm extern void qt_event_request_window_change(QWidget *); //qapplication_mac.mm extern QPointer qt_last_mouse_receiver; //qapplication_mac.mm +extern QPointer qt_last_native_mouse_receiver; //qt_cocoa_helpers_mac.mm extern IconRef qt_mac_create_iconref(const QPixmap &); //qpixmap_mac.cpp extern void qt_mac_set_cursor(const QCursor *, const QPoint &); //qcursor_mac.mm extern void qt_mac_update_cursor(); //qcursor_mac.mm @@ -3524,6 +3525,8 @@ void QWidgetPrivate::show_sys() qt_mac_getTargetForMouseEvent(0, QEvent::Enter, qlocal, qglobal, 0, &widgetUnderMouse); QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, qt_last_mouse_receiver); qt_last_mouse_receiver = widgetUnderMouse; + qt_last_native_mouse_receiver = widgetUnderMouse ? + (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0; } #endif @@ -3676,8 +3679,10 @@ void QWidgetPrivate::hide_sys() QPoint qlocal, qglobal; QWidget *widgetUnderMouse = 0; qt_mac_getTargetForMouseEvent(0, QEvent::Leave, qlocal, qglobal, 0, &widgetUnderMouse); - QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, qt_last_mouse_receiver); + QApplicationPrivate::dispatchEnterLeave(widgetUnderMouse, qt_last_native_mouse_receiver); qt_last_mouse_receiver = widgetUnderMouse; + qt_last_native_mouse_receiver = widgetUnderMouse ? + (widgetUnderMouse->internalWinId() ? widgetUnderMouse : widgetUnderMouse->nativeParentWidget()) : 0; } #endif -- cgit v0.12 From 53e589563f4adc51983703e6119c762bd81f584b Mon Sep 17 00:00:00 2001 From: Eckhart Koppen Date: Tue, 15 Feb 2011 08:00:50 +0200 Subject: Removed timestamp setting and checking for Symbian header export For Symbian, headers get always exported, and timestamps are not needed. Reviewed-by: TrustMe --- config.profiles/symbian/headerexport | 62 ++++++++++-------------------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/config.profiles/symbian/headerexport b/config.profiles/symbian/headerexport index e9e6f3b..d9f99e5 100644 --- a/config.profiles/symbian/headerexport +++ b/config.profiles/symbian/headerexport @@ -3,7 +3,7 @@ # # Synchronizes Qt header files - internal development tool. # -# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +# Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). # Contact: Nokia Corporation (qt-info@nokia.com) # ###################################################################### @@ -315,17 +315,16 @@ sub classNames { } ###################################################################### -# Syntax: syncHeader(header, iheader, copy, timestamp) +# Syntax: syncHeader(header, iheader, copy) # Params: header, string, filename to create "symlink" for # iheader, string, destination name of symlink # copy, forces header to be a copy of iheader -# timestamp, the requested modification time if copying # # Purpose: Syncronizes header to iheader # Returns: 1 if successful, else 0. ###################################################################### sub syncHeader { - my ($header, $iheader, $copy, $ts) = @_; + my ($header, $iheader, $copy) = @_; $iheader =~ s=\\=/=g; $header =~ s=\\=/=g; return copyFile($iheader, $header) if($copy); @@ -339,7 +338,6 @@ sub syncHeader { open HEADER, ">$header" || die "Could not open $header for writing!\n"; print HEADER "#include \"$iheader_out\"\n"; close HEADER; - utime(time, $ts, $header) or die "$iheader, $header"; return 1; } return 0; @@ -453,48 +451,21 @@ sub fileCompare { sub copyFile { my ($file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_; - # Bi-directional synchronization + open( I, "< " . $file ) || die "Could not open $file for reading"; local $/; binmode I; $filecontents = ; close I; - if ( open(I, "< " . $ifile) ) { - local $/; - binmode I; - $ifilecontents = ; - close I; - $copy = fileCompare($file, $ifile); - $knowdiff = 0, - } else { - $copy = -1; - $knowdiff = 1; - } - if ( $knowdiff || ($filecontents ne $ifilecontents) ) { - if ( $copy > 0 && !$oneway) { - my $file_dir = dirname($file); - mkpath $file_dir, !$quiet unless(-e $file_dir); - open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; - local $/; - binmode O; - print O $ifilecontents; - close O; - utime time, (stat($ifile))[9], $file; - return 1; - } elsif ( $copy < 0 ) { - my $ifile_dir = dirname($ifile); - mkpath $ifile_dir, !$quiet unless(-e $ifile_dir); - open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)"; - local $/; - binmode O; - print O $filecontents; - close O; - utime time, (stat($file))[9], $ifile; - return 1; - } - } - return 0; + my $ifile_dir = dirname($ifile); + mkpath $ifile_dir, !$quiet unless(-e $ifile_dir); + open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)"; + local $/; + binmode O; + print O $filecontents; + close O; + return 1; } ###################################################################### @@ -848,7 +819,6 @@ foreach my $lib (@modules_to_sync) { print "SYMBOL: $_\n"; } } else { - my $ts = (stat($iheader))[9]; #find out all the places it goes.. my @headers; if ($public_header) { @@ -887,18 +857,18 @@ foreach my $lib (@modules_to_sync) { # class =~ s,::,/,g; # } $class_lib_map_contents .= "QT_CLASS_LIB($full_class, $lib, $header_base)\n"; - $header_copies++ if(syncHeader("$out_basedir/$out_subdir/$lib/$class", "$out_basedir/$out_subdir/$lib/$header", 0, $ts)); + $header_copies++ if(syncHeader("$out_basedir/$out_subdir/$lib/$class", "$out_basedir/$out_subdir/$lib/$header", 0)); # KDE-Compat headers for Phonon if ($lib eq "phonon") { - $header_copies++ if (syncHeader("$out_basedir/$out_subdir/phonon_compat/Phonon/$class", "$out_basedir/$out_subdir/$lib/$header", 0, $ts)); + $header_copies++ if (syncHeader("$out_basedir/$out_subdir/phonon_compat/Phonon/$class", "$out_basedir/$out_subdir/$lib/$header", 0)); } } } elsif ($create_private_headers) { @headers = ( "$out_basedir/$out_subdir/$lib/private/$header" ); } foreach(@headers) { #sync them - $header_copies++ if(syncHeader($_, $iheader, $copy_headers, $ts)); + $header_copies++ if(syncHeader($_, $iheader, $copy_headers)); } if($public_header) { @@ -1132,7 +1102,7 @@ if($check_includes) { } } } - } } +} exit 0; -- cgit v0.12 From 3f3a0f31b74774051021d969e008d7bd1536b010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 15 Feb 2011 17:26:48 +0100 Subject: Workaround for QTBUG-17468 On Mac, processEvents doesn't always process posted events. Reviewed-by: Olivier Goffart --- tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp index 4f10d31..1177131 100644 --- a/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp +++ b/tests/auto/qfileopenevent/test/tst_qfileopenevent.cpp @@ -284,6 +284,9 @@ void tst_qfileopenevent::sendAndReceive() QCoreApplication::instance()->postEvent(this, event.take()); QCoreApplication::instance()->processEvents(); + // QTBUG-17468: On Mac, processEvents doesn't always process posted events + QCoreApplication::instance()->sendPostedEvents(); + // check the content QFile check("testSendAndReceive"); QCOMPARE(check.open(QFile::ReadOnly), true); -- cgit v0.12