From 9df295a355b18f662819f091a7eebb22fb0b409e Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 11 Mar 2010 14:11:32 +0100 Subject: Added -qt-style-s60 to Symbian configure options on Linux. RevBy: Miikka Heikkinen --- configure | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/configure b/configure index 1164221..20f3f84 100755 --- a/configure +++ b/configure @@ -725,6 +725,7 @@ CFG_DBUS=auto CFG_GLIB=auto CFG_GSTREAMER=auto CFG_QGTKSTYLE=auto +CFG_QS60STYLE=auto CFG_LARGEFILE=yes CFG_OPENSSL=auto CFG_PTMALLOC=no @@ -1799,6 +1800,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + style-s60) + if [ "$VAL" = "qt" ] || [ "$VAL" = "no" ]; then + CFG_QS60STYLE="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; qdbus|dbus) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ] || [ "$VAL" = "linked" ]; then CFG_DBUS="$VAL" @@ -3993,6 +4001,15 @@ if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_X11" = "yes" ]; then EOF fi +if echo "$XQMAKESPEC" | grep symbian > /dev/null ; then + cat << EOF + +Qt for Symbian only: + -no-style-s60....... Disable s60 style + + -qt-style-s60....... Enable s60 style in the Qt Library +EOF +fi + [ "x$ERROR" = "xyes" ] && exit 1 exit 0 fi # Help @@ -4638,6 +4655,14 @@ if [ "$CFG_S60" = "auto" ]; then fi fi +if [ "$CFG_QS60STYLE" = "auto" ]; then + if echo "$XQMAKESPEC" | grep symbian > /dev/null; then + CFG_QS60STYLE=qt + else + CFG_QS60STYLE=no + fi +fi + if [ "$CFG_SYMBIAN_DEFFILES" = "auto" ]; then if echo "$XQMAKESPEC" | grep symbian > /dev/null && [ "$CFG_DEV" = "no" ]; then CFG_SYMBIAN_DEFFILES=yes @@ -6194,6 +6219,12 @@ else fi fi +if [ "$CFG_QS60STYLE" = "no" ]; then + QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_STYLE_S60" +else + QCONFIG_FLAGS="$QCONFIG_FLAGS QT_STYLE_S60" +fi + # Disable OpenGL on Symbian. case "$XPLATFORM" in symbian*) -- cgit v0.12 From a3516a36e6d352481133ecb4ed064018a39266fc Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 11 Mar 2010 14:12:14 +0100 Subject: Fixed incorrect platform string when building for Symbian. RevBy: Miikka Heikkinen --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 20f3f84..9eec299 100755 --- a/configure +++ b/configure @@ -4023,6 +4023,8 @@ if [ "$PLATFORM_QWS" = "yes" ]; then Platform="Qt for Embedded Linux" elif [ "$PLATFORM_MAC" = "yes" ]; then Platform="Qt for Mac OS X" +elif echo "$XPLATFORM" | grep "symbian" > /dev/null ; then + Platform="Qt for Symbian" elif [ '!' -z "`getQMakeConf \"$XQMAKESPEC\" | grep QMAKE_LIBS_X11 | awk '{print $3;}'`" ]; then PLATFORM_X11=yes Platform="Qt for Linux/X11" -- cgit v0.12 From d88cd3152b5404c2a4a890b66dcc2e38ef08abde Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 11 Mar 2010 14:14:12 +0100 Subject: Forced little endianness when using symbian-sbsv2 mkspec. RevBy: Miikka Heikkinen --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 9eec299..1c81b66 100755 --- a/configure +++ b/configure @@ -5699,6 +5699,8 @@ fi if [ "$CFG_ENDIAN" = "auto" ]; then if [ "$PLATFORM_MAC" = "yes" ]; then true #leave as auto + elif [ "$XPLATFORM" = "symbian-sbsv2" ]; then + CFG_ENDIAN="Q_LITTLE_ENDIAN" else "$unixtests/endian.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" F="$?" -- cgit v0.12 From d3b035c4fc583a4533aa29ffd8a8bfe9220ecdc2 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 11 Mar 2010 14:41:06 +0100 Subject: Added rpp and rsg files to ignore filter. --- config.tests/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 config.tests/.gitignore diff --git a/config.tests/.gitignore b/config.tests/.gitignore new file mode 100644 index 0000000..bd76520 --- /dev/null +++ b/config.tests/.gitignore @@ -0,0 +1,2 @@ +*.rpp +*.rsg -- cgit v0.12 From 9f300858a82f41d06f2ad9545bb71cd2d15b03e8 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 11 Mar 2010 14:43:48 +0100 Subject: Moved -s60 and -usedeffiles options docs to Symbian section. --- configure | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 1c81b66..3ae9ba4 100755 --- a/configure +++ b/configure @@ -3362,7 +3362,6 @@ Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir [-no-openssl] [-openssl] [-openssl-linked] [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] [-no-javascript-jit] [-javascript-jit] [-no-script] [-script] [-no-scripttools] [-scripttools] [-no-declarative] [-declarative] - [-no-s60] [-s60] [-no-usedeffiles] [-usedeffiles] [additional platform specific options (see below)] @@ -3546,11 +3545,6 @@ EOF fi cat << EOF - -no-s60 ............ Do not compile in S60 support. - + -s60 ............... Compile with support for the S60 UI Framework. - -no-usedeffiles .... Disable the usage of DEF files. - * -usedeffiles ....... Enable the usage of DEF files. - -no-mmx ............ Do not compile with use of MMX instructions. -no-3dnow .......... Do not compile with use of 3DNOW instructions. -no-sse ............ Do not compile with use of SSE instructions. @@ -4005,8 +3999,13 @@ if echo "$XQMAKESPEC" | grep symbian > /dev/null ; then cat << EOF Qt for Symbian only: + -no-s60 ............ Do not compile in S60 support. + + -s60 ............... Compile with support for the S60 UI Framework. -no-style-s60....... Disable s60 style + -qt-style-s60....... Enable s60 style in the Qt Library + + -no-usedeffiles .... Disable the usage of DEF files. + * -usedeffiles ....... Enable the usage of DEF files. EOF fi -- cgit v0.12 From 9379242932d63d0a328484157e1efb19e461436e Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 11 Mar 2010 14:49:16 +0100 Subject: Corrected wrong header casing. --- src/gui/styles/qs60style_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index cb49fbc..5f762d8 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -63,7 +63,7 @@ #include #include #include -#include +#include #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) -- cgit v0.12 From 3a1656ebc4869755980d49f1b42ed271c2c1190c Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 11 Mar 2010 14:49:21 +0100 Subject: Disable OpenVG for symbian-sbsv2 on Linux. RevBy: Miikka Heikkinen --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 3ae9ba4..c4705e3 100755 --- a/configure +++ b/configure @@ -5939,7 +5939,7 @@ if [ "$CFG_OPENSSL" != "no" ]; then fi # detect OpenVG support -if [ "$CFG_OPENVG" != "no" ]; then +if [ "$CFG_OPENVG" != "no" ] && [ "$XPLATFORM" != "symbian-sbsv2" ]; then if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" "config.tests/unix/openvg" "OpenVG" $L_FLAGS $I_FLAGS $l_FLAGS $CONFIG_ARG; then if [ "$CFG_OPENVG" = "auto" ]; then CFG_OPENVG=yes -- cgit v0.12 From 24020b3997ad263e457426e831a7ef50b4bf730c Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 22 Mar 2010 14:09:34 +0100 Subject: Make ICON generation (to symbian mif) work for relative paths/shadow builds --- mkspecs/features/symbian/application_icon.prf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index 1109060..ecf987d 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -31,6 +31,7 @@ contains( CONFIG, no_icon ) { # Note: symbian-sbsv2 builds can't utilize extra compiler for mifconv, so ICON handling is done in code !symbian-sbsv2 { + !contains(ICON, "^(/|\\|.:).*"):ICON = $$_PRO_FILE_PWD_/$$ICON #absolute path #Makefile: requires paths with backslash ICON_backslashed = $$ICON contains(QMAKE_HOST.os, "Windows"):ICON_backslashed = $$replace( ICON_backslashed, /, \\) @@ -50,6 +51,7 @@ contains( CONFIG, no_icon ) { # Based on: http://www.forum.nokia.com/document/Cpp_Developers_Library # svg-t icons should always use /c32 depth mifconv.commands = mifconv $$mifconv.target /c32 $$ICON_backslashed + mifconv.depends = $$ICON PRE_TARGETDEPS += $$mifconv.target QMAKE_EXTRA_TARGETS += mifconv -- cgit v0.12 From caef7e056b8b20d44fa8839b88d62fe0d5802348 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 22 Mar 2010 15:48:16 +0100 Subject: Fix compile on symbian better. --- src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h | 4 ++-- src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h index 5fb7fe3..5b655e8 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h @@ -75,7 +75,7 @@ #include #elif OS(ANDROID) #include -#elif COMPILER(GCC) && !PLATFORM(SYMBIAN) +#elif COMPILER(GCC) && !defined(__SYMBIAN32__) #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) #include #else @@ -239,7 +239,7 @@ inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Bar inline int atomicIncrement(int volatile* addend) { return android_atomic_inc(addend); } inline int atomicDecrement(int volatile* addend) { return android_atomic_dec(addend); } -#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !PLATFORM(SYMBIAN) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc +#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !defined(__SYMBIAN32__) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc #define WTF_USE_LOCKFREE_THREADSAFESHARED 1 inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; } diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h index 52a24f6..3e25c95 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.h @@ -73,7 +73,7 @@ #include #elif PLATFORM(DARWIN) #include -#elif COMPILER(GCC) && !PLATFORM(SYMBIAN) +#elif COMPILER(GCC) && !defined(__SYMBIAN32__) #if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) #include #else @@ -232,7 +232,7 @@ inline int atomicDecrement(int volatile* addend) { return InterlockedDecrement(r inline int atomicIncrement(int volatile* addend) { return OSAtomicIncrement32Barrier(const_cast(addend)); } inline int atomicDecrement(int volatile* addend) { return OSAtomicDecrement32Barrier(const_cast(addend)); } -#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !PLATFORM(SYMBIAN) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc +#elif COMPILER(GCC) && !PLATFORM(SPARC64) && !defined(__SYMBIAN32__) // sizeof(_Atomic_word) != sizeof(int) on sparc64 gcc #define WTF_USE_LOCKFREE_THREADSAFESHARED 1 inline int atomicIncrement(int volatile* addend) { return __gnu_cxx::__exchange_and_add(addend, 1) + 1; } -- cgit v0.12 From fc5d053c330e2f242610e9c2f6e615b14dad9fe4 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 22 Mar 2010 14:33:20 +0100 Subject: Fix configure false positives when checking for symbian Just check the spec instead of the full path to the spec. This avoids false positives for testing for 'symbian' in the spec name when the path to the spec contains it instead. --- configure | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index f95760f..9830c60 100755 --- a/configure +++ b/configure @@ -4630,7 +4630,7 @@ if [ "$CFG_ZLIB" = "auto" ]; then fi if [ "$CFG_S60" = "auto" ]; then - if echo "$XQMAKESPEC" | grep symbian > /dev/null; then + if echo "$XPLATFORM" | grep symbian > /dev/null; then CFG_S60=yes else CFG_S60=no @@ -4638,7 +4638,7 @@ if [ "$CFG_S60" = "auto" ]; then fi if [ "$CFG_SYMBIAN_DEFFILES" = "auto" ]; then - if echo "$XQMAKESPEC" | grep symbian > /dev/null && [ "$CFG_DEV" = "no" ]; then + if echo "$XPLATFORM" | grep symbian > /dev/null && [ "$CFG_DEV" = "no" ]; then CFG_SYMBIAN_DEFFILES=yes else CFG_SYMBIAN_DEFFILES=no @@ -5756,7 +5756,7 @@ if [ "$CFG_DOUBLEFORMAT" = "auto" ]; then fi HAVE_STL=no -if echo "$XQMAKESPEC" | grep symbian > /dev/null || "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS; then +if echo "$XPLATFORM" | grep symbian > /dev/null || "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS; then HAVE_STL=yes fi @@ -5994,7 +5994,7 @@ elif [ "$CFG_JAVASCRIPTCORE_JIT" = "no" ]; then fi if [ "$CFG_AUDIO_BACKEND" = "auto" ]; then - if echo "$XQMAKESPEC" | grep symbian > /dev/null 2>&1; then + if echo "$XPLATFORM" | grep symbian > /dev/null 2>&1; then "$symbiantests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/symbian/audio "audio" $L_FLAGS $I_FLAGS $l_FLAGS else CFG_AUDIO_BACKEND=yes -- cgit v0.12 From 259f5b62e76127318dccff592f9eb95ea726f306 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 22 Mar 2010 15:23:28 +0100 Subject: This file does not exist --- src/declarative/util/util.pri | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index ddf00ea..f455870 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -62,8 +62,7 @@ HEADERS += \ $$PWD/qdeclarativebehavior_p.h \ $$PWD/qdeclarativefontloader_p.h \ $$PWD/qdeclarativestyledtext_p.h \ - $$PWD/qdeclarativelistmodelworkeragent_p.h \ - $$PWD/qdeclarativelistmodelworkeragent_p_p.h + $$PWD/qdeclarativelistmodelworkeragent_p.h contains(QT_CONFIG, xmlpatterns) { QT+=xmlpatterns -- cgit v0.12 From 079b57230c5ccdf0fa4769e913a935047e789ff0 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 22 Mar 2010 16:24:05 +0000 Subject: Replace download % display with a progress bar This change is to avoid flooding the console when copying a large sis file (e.g. qt.sis) to the phone. Reviewed-by: axis --- tools/runonphone/trksignalhandler.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/runonphone/trksignalhandler.cpp b/tools/runonphone/trksignalhandler.cpp index 18a2c0c..2abf91f 100644 --- a/tools/runonphone/trksignalhandler.cpp +++ b/tools/runonphone/trksignalhandler.cpp @@ -54,6 +54,7 @@ private: QTextStream out; QTextStream err; int loglevel; + int lastpercent; }; void TrkSignalHandler::copyingStarted() @@ -131,7 +132,12 @@ void TrkSignalHandler::applicationOutputReceived(const QString &output) void TrkSignalHandler::copyProgress(int percent) { if (d->loglevel > 0) { - d->out << percent << "% "; + if (d->lastpercent == 0) + d->out << "[ ]\r[" << flush; + while (percent > d->lastpercent) { + d->out << QLatin1Char('#'); + d->lastpercent+=2; //because typical console is 80 chars wide + } d->out.flush(); if (percent==100) d->out << endl; @@ -167,7 +173,8 @@ void TrkSignalHandler::timeout() TrkSignalHandlerPrivate::TrkSignalHandlerPrivate() : out(stdout), err(stderr), - loglevel(0) + loglevel(0), + lastpercent(0) { } -- cgit v0.12 From b826d3842727a3e4fc5d44b785f577f6e699389f Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 22 Mar 2010 16:27:08 +0000 Subject: Enable installation of a sis file without running any application "runonphone --sis qt.sis" Would install qt to the phone without attempting to execute any test afterwards. This feature is added because people were using runonphone as a fast way to install sis files from the command shell. Reviewed-by: axis --- tools/runonphone/main.cpp | 49 ++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index af08777..80e5e34 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include "symbianutils/trkutils.h" #include "symbianutils/trkdevice.h" #include "symbianutils/launcher.h" @@ -51,9 +52,9 @@ #include "trksignalhandler.h" #include "serenum.h" -void printUsage(QTextStream& outstream) +void printUsage(QTextStream& outstream, QString exeName) { - outstream << "runtest [options] [program arguments]" << endl + outstream << exeName << " [options] [program] [program arguments]" << 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 @@ -61,7 +62,9 @@ void printUsage(QTextStream& outstream) << "-v, --verbose show debugging output" << endl << "-q, --quiet hide progress messages" << endl << endl - << "USB COM ports can usually be autodetected" << endl; + << "USB COM ports can usually be autodetected, use -p or -f to force a specific port." << endl + << "If using System TRK, it is possible to copy the program directly to sys/bin on the phone." << endl + << "-s can be used with both System and Application TRK to install the program" << endl; } int main(int argc, char *argv[]) @@ -86,22 +89,22 @@ int main(int argc, char *argv[]) return 1; } QString param = args.at(i+1); - if(arg.compare("--portname", Qt::CaseSensitive) == 0 + if (arg.compare("--portname", Qt::CaseSensitive) == 0 || arg.compare("-p", Qt::CaseSensitive) == 0) { serialPortName = param; i++; } - else if(arg.compare("--portfriendlyname", Qt::CaseSensitive) == 0 + else if (arg.compare("--portfriendlyname", Qt::CaseSensitive) == 0 || arg.compare("-f", Qt::CaseSensitive) == 0) { serialPortFriendlyName = param; i++; } - else if(arg.compare("--sis", Qt::CaseSensitive) == 0 + else if (arg.compare("--sis", Qt::CaseSensitive) == 0 || arg.compare("-s", Qt::CaseSensitive) == 0) { sisFile = param; i++; } - else if(arg.compare("--timeout", Qt::CaseSensitive) == 0 + else if (arg.compare("--timeout", Qt::CaseSensitive) == 0 || arg.compare("-t", Qt::CaseSensitive) == 0) { bool ok; timeout = param.toInt(&ok); @@ -111,10 +114,10 @@ int main(int argc, char *argv[]) } i++; } - else if(arg.compare("--verbose", Qt::CaseSensitive) == 0 + else if (arg.compare("--verbose", Qt::CaseSensitive) == 0 || arg.compare("-v", Qt::CaseSensitive) == 0) loglevel=2; - else if(arg.compare("--quiet", Qt::CaseSensitive) == 0 + else if (arg.compare("--quiet", Qt::CaseSensitive) == 0 || arg.compare("-q", Qt::CaseSensitive) == 0) loglevel=0; else @@ -128,8 +131,8 @@ int main(int argc, char *argv[]) } } - if(exeFile.isEmpty()) { - printUsage(outstream); + if (exeFile.isEmpty() && sisFile.isEmpty()) { + printUsage(outstream, args[0]); return 1; } @@ -161,24 +164,26 @@ int main(int argc, char *argv[]) } QScopedPointer launcher; - - if (sisFile.isEmpty()) { - launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyRun)); - launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + exeFile); - errstream << "System TRK required to copy EXE, use --sis if using Application TRK" << endl; - } else { - launcher.reset(new trk::Launcher(trk::Launcher::ActionCopyInstallRun)); - launcher->addStartupActions(trk::Launcher::ActionInstall); + launcher.reset(new trk::Launcher(trk::Launcher::ActionPingOnly)); + QFileInfo info(exeFile); + 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()) { + launcher->addStartupActions(trk::Launcher::ActionCopy); + launcher->setCopyFileName(exeFile, QString("c:\\sys\\bin\\") + info.fileName()); + } + if (!exeFile.isEmpty()) { + launcher->addStartupActions(trk::Launcher::ActionRun); + launcher->setFileName(QString("c:\\sys\\bin\\") + info.fileName()); + launcher->setCommandLineArgs(cmdLine); + } if (loglevel > 0) outstream << "Connecting to target via " << serialPortName << endl; launcher->setTrkServerName(serialPortName); - launcher->setFileName(QString("c:\\sys\\bin\\") + exeFile); - launcher->setCommandLineArgs(cmdLine); - if (loglevel > 1) launcher->setVerbose(1); -- cgit v0.12 From 288c4290d25e0c8b14d4e1527ee7082cf249ee19 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 22 Mar 2010 16:32:29 +0000 Subject: Merge symbianutils from qtcreator e82219b344ee471dbb5d8e7f1351404ff9616d6c --- tools/runonphone/symbianutils/launcher.cpp | 83 ++++++--- tools/runonphone/symbianutils/launcher.h | 15 +- .../symbianutils/symbiandevicemanager.cpp | 194 +++++++++++++++++++-- .../runonphone/symbianutils/symbiandevicemanager.h | 47 ++++- tools/runonphone/symbianutils/trkdevice.cpp | 111 +++++++++--- tools/runonphone/symbianutils/trkdevice.h | 11 +- 6 files changed, 384 insertions(+), 77 deletions(-) diff --git a/tools/runonphone/symbianutils/launcher.cpp b/tools/runonphone/symbianutils/launcher.cpp index 408829b..92b494a 100644 --- a/tools/runonphone/symbianutils/launcher.cpp +++ b/tools/runonphone/symbianutils/launcher.cpp @@ -44,6 +44,7 @@ #include "trkutils_p.h" #include "trkdevice.h" #include "bluetoothlistener.h" +#include "symbiandevicemanager.h" #include #include @@ -100,12 +101,15 @@ Launcher::Launcher(Actions startupActions, d(new LauncherPrivate(dev)) { d->m_startupActions = startupActions; - connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); - connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close())); + connect(d->m_device.data(), SIGNAL(messageReceived(trk::TrkResult)), this, SLOT(handleResult(trk::TrkResult))); } Launcher::~Launcher() { + // Destroyed before protocol was through: Close + if (d->m_closeDevice && d->m_device->isOpen()) + d->m_device->close(); + emit destroyed(d->m_device->port()); logMessage("Shutting down.\n"); delete d; } @@ -214,11 +218,6 @@ bool Launcher::startServer(QString *errorMessage) } if (!d->m_device->isOpen() && !d->m_device->open(errorMessage)) return false; - if (d->m_closeDevice) { - connect(this, SIGNAL(finished()), d->m_device.data(), SLOT(close())); - } else { - disconnect(this, SIGNAL(finished()), d->m_device.data(), 0); - } setState(Connecting); // Set up the temporary 'waiting' state if we do not get immediate connection QTimer::singleShot(1000, this, SLOT(slotWaitingForTrk())); @@ -266,6 +265,13 @@ void Launcher::logMessage(const QString &msg) qDebug() << "LAUNCHER: " << qPrintable(msg); } +void Launcher::handleFinished() +{ + if (d->m_closeDevice) + d->m_device->close(); + emit finished(); +} + void Launcher::terminate() { switch (state()) { @@ -287,7 +293,7 @@ void Launcher::terminate() case Connecting: case WaitingForTrk: setState(Disconnected); - emit finished(); + handleFinished(); break; } } @@ -446,7 +452,7 @@ void Launcher::handleTrkVersion(const TrkResult &result) if (result.errorCode() || result.data.size() < 5) { if (d->m_startupActions == ActionPingOnly) { setState(Disconnected); - emit finished(); + handleFinished(); } return; } @@ -455,11 +461,13 @@ void Launcher::handleTrkVersion(const TrkResult &result) d->m_session.trkAppVersion.protocolMajor = result.data.at(3); d->m_session.trkAppVersion.protocolMinor = result.data.at(4); setState(DeviceDescriptionReceived); + const QString msg = deviceDescription(); + emit deviceDescriptionReceived(trkServerName(), msg); // Ping mode: Log & Terminate if (d->m_startupActions == ActionPingOnly) { - qWarning("%s", qPrintable(deviceDescription())); + qWarning("%s", qPrintable(msg)); setState(Disconnected); - emit finished(); + handleFinished(); } } @@ -586,7 +594,7 @@ void Launcher::handleWaitForFinished(const TrkResult &result) { logMessage(" FINISHED: " + stringFromArray(result.data)); setState(Disconnected); - emit finished(); + handleFinished(); } void Launcher::handleSupportMask(const TrkResult &result) @@ -704,18 +712,14 @@ QByteArray Launcher::startProcessMessage(const QString &executable, { // It's not started yet QByteArray ba; - appendShort(&ba, 0, TargetByteOrder); // create new process + appendShort(&ba, 0, TargetByteOrder); // create new process (kDSOSProcessItem) ba.append(char(0)); // options - currently unused - if(arguments.isEmpty()) { - appendString(&ba, executable.toLocal8Bit(), TargetByteOrder); - return ba; - } - // Append full command line as one string (leading length information). - QByteArray commandLineBa; - commandLineBa.append(executable.toLocal8Bit()); - commandLineBa.append('\0'); - commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit()); - appendString(&ba, commandLineBa, TargetByteOrder); + // One string consisting of binary terminated by '\0' and arguments terminated by '\0' + QByteArray commandLineBa = executable.toLocal8Bit(); + commandLineBa.append(char(0)); + if (!arguments.isEmpty()) + commandLineBa.append(arguments.join(QString(QLatin1Char(' '))).toLocal8Bit()); + appendString(&ba, commandLineBa, TargetByteOrder, true); return ba; } @@ -737,4 +741,37 @@ void Launcher::resumeProcess(uint pid, uint tid) appendInt(&ba, tid, BigEndian); d->m_device->sendTrkMessage(TrkContinue, TrkCallback(), ba, "CONTINUE"); } + +// Acquire a device from SymbianDeviceManager, return 0 if not available. +Launcher *Launcher::acquireFromDeviceManager(const QString &serverName, + QObject *parent, + QString *errorMessage) +{ + SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance(); + const QSharedPointer device = sdm->acquireDevice(serverName); + if (device.isNull()) { + *errorMessage = tr("Unable to acquire a device for port '%1'. It appears to be in use.").arg(serverName); + return 0; + } + // Wire release signal. + Launcher *rc = new Launcher(trk::Launcher::ActionPingOnly, device, parent); + connect(rc, SIGNAL(deviceDescriptionReceived(QString,QString)), + sdm, SLOT(setAdditionalInformation(QString,QString))); + connect(rc, SIGNAL(destroyed(QString)), sdm, SLOT(releaseDevice(QString))); + return rc; +} + +// Preliminary release of device, disconnecting the signal. +void Launcher::releaseToDeviceManager(Launcher *launcher) +{ + SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance(); + // Disentangle launcher and its device, remove connection from destroyed + launcher->setCloseDevice(false); + TrkDevice *device = launcher->trkDevice().data(); + launcher->disconnect(device); + device->disconnect(launcher); + launcher->disconnect(sdm); + sdm->releaseDevice(launcher->trkServerName()); +} + } // namespace trk diff --git a/tools/runonphone/symbianutils/launcher.h b/tools/runonphone/symbianutils/launcher.h index 2b23fd8..c47285c 100644 --- a/tools/runonphone/symbianutils/launcher.h +++ b/tools/runonphone/symbianutils/launcher.h @@ -97,7 +97,7 @@ public: void setInstallFileName(const QString &name); void setCommandLineArgs(const QStringList &args); bool startServer(QString *errorMessage); - void setVerbose(int v); + void setVerbose(int v); void setSerialFrame(bool b); bool serialFrame() const; // Close device or leave it open @@ -109,6 +109,15 @@ public: // becomes valid after successful execution of ActionPingOnly QString deviceDescription(unsigned verbose = 0u) const; + // Acquire a device from SymbianDeviceManager, return 0 if not available. + // The device will be released on destruction. + static Launcher *acquireFromDeviceManager(const QString &serverName, + QObject *parent, + QString *errorMessage); + // Preliminary release of device, disconnecting the signal. + static void releaseToDeviceManager(Launcher *l); + + // Create Trk message to start a process. static QByteArray startProcessMessage(const QString &executable, const QStringList &arguments); // Parse a TrkNotifyStopped message @@ -119,6 +128,7 @@ public: static QString msgStopped(uint pid, uint tid, uint address, const QString &why); signals: + void deviceDescriptionReceived(const QString &port, const QString &description); void copyingStarted(); void canNotConnect(const QString &errorMessage); void canNotCreateFile(const QString &filename, const QString &errorMessage); @@ -135,6 +145,8 @@ signals: void copyProgress(int percent); void stateChanged(int); void processStopped(uint pc, uint pid, uint tid, const QString& reason); + // Emitted by the destructor, for releasing devices of SymbianDeviceManager by name + void destroyed(const QString &serverName); public slots: void terminate(); @@ -167,6 +179,7 @@ private: void copyFileToRemote(); void installRemotePackageSilently(); void startInferiorIfNeeded(); + void handleFinished(); void logMessage(const QString &msg); void setState(State s); diff --git a/tools/runonphone/symbianutils/symbiandevicemanager.cpp b/tools/runonphone/symbianutils/symbiandevicemanager.cpp index f663816..8877ea1 100644 --- a/tools/runonphone/symbianutils/symbiandevicemanager.cpp +++ b/tools/runonphone/symbianutils/symbiandevicemanager.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "symbiandevicemanager.h" +#include "trkdevice.h" #include #include @@ -48,6 +49,7 @@ #include #include #include +#include namespace SymbianUtils { @@ -61,19 +63,51 @@ const char *SymbianDeviceManager::linuxBlueToothDeviceRootC = "/dev/rfcomm"; // ------------- SymbianDevice class SymbianDeviceData : public QSharedData { public: - SymbianDeviceData() : type(SerialPortCommunication) {} + SymbianDeviceData(); + ~SymbianDeviceData(); + + inline bool isOpen() const { return !device.isNull() && device->isOpen(); } + void forcedClose(); QString portName; QString friendlyName; QString deviceDesc; QString manufacturer; + QString additionalInformation; + DeviceCommunicationType type; + QSharedPointer device; + bool deviceAcquired; }; +SymbianDeviceData::SymbianDeviceData() : + type(SerialPortCommunication), + deviceAcquired(false) +{ +} + +SymbianDeviceData::~SymbianDeviceData() +{ + forcedClose(); +} + +void SymbianDeviceData::forcedClose() +{ + // Close the device when unplugging. Should devices be in 'acquired' state, + // their owners should hit on write failures. + // Apart from the destructor, also called by the devicemanager + // to ensure it also happens if other shared instances are still around. + if (isOpen()) { + if (deviceAcquired) + qWarning("Device on '%s' unplugged while an operation is in progress.", + qPrintable(portName)); + device->close(); + } +} + SymbianDevice::SymbianDevice(SymbianDeviceData *data) : m_data(data) { - } SymbianDevice::SymbianDevice() : @@ -96,6 +130,11 @@ SymbianDevice::~SymbianDevice() { } +void SymbianDevice::forcedClose() +{ + m_data->forcedClose(); +} + QString SymbianDevice::portName() const { return m_data->portName; @@ -106,6 +145,51 @@ QString SymbianDevice::friendlyName() const return m_data->friendlyName; } +QString SymbianDevice::additionalInformation() const +{ + return m_data->additionalInformation; +} + +void SymbianDevice::setAdditionalInformation(const QString &a) +{ + m_data->additionalInformation = a; +} + +SymbianDevice::TrkDevicePtr SymbianDevice::acquireDevice() +{ + if (debug) + qDebug() << "SymbianDevice::acquireDevice" << m_data->portName + << "acquired: " << m_data->deviceAcquired << " open: " << isOpen(); + if (isNull() || m_data->deviceAcquired) + return TrkDevicePtr(); + if (m_data->device.isNull()) { + m_data->device = TrkDevicePtr(new trk::TrkDevice); + m_data->device->setPort(m_data->portName); + m_data->device->setSerialFrame(m_data->type == SerialPortCommunication); + } + m_data->deviceAcquired = true; + return m_data->device; +} + +void SymbianDevice::releaseDevice(TrkDevicePtr *ptr /* = 0 */) +{ + if (debug) + qDebug() << "SymbianDevice::releaseDevice" << m_data->portName + << " open: " << isOpen(); + if (m_data->deviceAcquired) { + if (m_data->device->isOpen()) + m_data->device->clearWriteQueue(); + // Release if a valid pointer was passed in. + if (ptr && !ptr->isNull()) { + ptr->data()->disconnect(); + *ptr = TrkDevicePtr(); + } + m_data->deviceAcquired = false; + } else { + qWarning("Internal error: Attempt to release device that is not acquired."); + } +} + QString SymbianDevice::deviceDesc() const { return m_data->deviceDesc; @@ -123,7 +207,12 @@ DeviceCommunicationType SymbianDevice::type() const bool SymbianDevice::isNull() const { - return !m_data->portName.isEmpty(); + return m_data->portName.isEmpty(); +} + +bool SymbianDevice::isOpen() const +{ + return m_data->isOpen(); } QString SymbianDevice::toString() const @@ -158,7 +247,7 @@ int SymbianDevice::compare(const SymbianDevice &rhs) const return 0; } -QDebug operator<<(QDebug d, const SymbianDevice &cd) +SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDevice &cd) { d.nospace() << cd.toString(); return d; @@ -166,10 +255,11 @@ QDebug operator<<(QDebug d, const SymbianDevice &cd) // ------------- SymbianDeviceManagerPrivate struct SymbianDeviceManagerPrivate { - SymbianDeviceManagerPrivate() : m_initialized(false) {} + SymbianDeviceManagerPrivate() : m_initialized(false), m_destroyReleaseMapper(0) {} bool m_initialized; SymbianDeviceManager::SymbianDeviceList m_devices; + QSignalMapper *m_destroyReleaseMapper; }; SymbianDeviceManager::SymbianDeviceManager(QObject *parent) : @@ -185,8 +275,7 @@ SymbianDeviceManager::~SymbianDeviceManager() SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::devices() const { - if (!d->m_initialized) - const_cast(this)->update(false); + ensureInitialized(); return d->m_devices; } @@ -194,6 +283,7 @@ QString SymbianDeviceManager::toString() const { QString rc; QTextStream str(&rc); + str << d->m_devices.size() << " devices:\n"; const int count = d->m_devices.size(); for (int i = 0; i < count; i++) { str << '#' << i << ' '; @@ -203,13 +293,37 @@ QString SymbianDeviceManager::toString() const return rc; } +int SymbianDeviceManager::findByPortName(const QString &p) const +{ + ensureInitialized(); + const int count = d->m_devices.size(); + for (int i = 0; i < count; i++) + if (d->m_devices.at(i).portName() == p) + return i; + return -1; +} + QString SymbianDeviceManager::friendlyNameForPort(const QString &port) const { - foreach (const SymbianDevice &device, d->m_devices) { - if (device.portName() == port) - return device.friendlyName(); - } - return QString(); + const int idx = findByPortName(port); + return idx == -1 ? QString() : d->m_devices.at(idx).friendlyName(); +} + +SymbianDeviceManager::TrkDevicePtr + SymbianDeviceManager::acquireDevice(const QString &port) +{ + ensureInitialized(); + const int idx = findByPortName(port); + if (idx == -1) { + qWarning("Attempt to acquire device '%s' that does not exist.", qPrintable(port)); + if (debug) + qDebug() << *this; + return TrkDevicePtr(); + } + const TrkDevicePtr rc = d->m_devices[idx].acquireDevice(); + if (debug) + qDebug() << "SymbianDeviceManager::acquireDevice" << port << " returns " << !rc.isNull(); + return rc; } void SymbianDeviceManager::update() @@ -217,12 +331,38 @@ void SymbianDeviceManager::update() update(true); } +void SymbianDeviceManager::releaseDevice(const QString &port) +{ + const int idx = findByPortName(port); + if (debug) + qDebug() << "SymbianDeviceManager::releaseDevice" << port << idx << sender(); + if (idx != -1) { + d->m_devices[idx].releaseDevice(); + } else { + qWarning("Attempt to release non-existing device %s.", qPrintable(port)); + } +} + +void SymbianDeviceManager::setAdditionalInformation(const QString &port, const QString &ai) +{ + const int idx = findByPortName(port); + if (idx != -1) + d->m_devices[idx].setAdditionalInformation(ai); +} + +void SymbianDeviceManager::ensureInitialized() const +{ + if (!d->m_initialized) // Flag is set in update() + const_cast(this)->update(false); +} + void SymbianDeviceManager::update(bool emitSignals) { + static int n = 0; typedef SymbianDeviceList::iterator SymbianDeviceListIterator; if (debug) - qDebug(">SerialDeviceLister::update(%d)\n%s", int(emitSignals), + qDebug(">SerialDeviceLister::update(#%d, signals=%d)\n%s", n++, int(emitSignals), qPrintable(toString())); d->m_initialized = true; @@ -230,8 +370,11 @@ void SymbianDeviceManager::update(bool emitSignals) SymbianDeviceList newDevices = serialPorts() + blueToothDevices(); if (newDevices.size() > 1) qStableSort(newDevices.begin(), newDevices.end()); - if (d->m_devices == newDevices) // Happy, nothing changed. + if (d->m_devices == newDevices) { // Happy, nothing changed. + if (debug) + qDebug("m_devices.isEmpty()) { @@ -240,7 +383,8 @@ void SymbianDeviceManager::update(bool emitSignals) if (newDevices.contains(*oldIt)) { ++oldIt; } else { - const SymbianDevice toBeDeleted = *oldIt; + SymbianDevice toBeDeleted = *oldIt; + toBeDeleted.forcedClose(); oldIt = d->m_devices.erase(oldIt); if (emitSignals) emit deviceRemoved(toBeDeleted); @@ -301,16 +445,30 @@ SymbianDeviceManager::SymbianDeviceList SymbianDeviceManager::blueToothDevices() // Bluetooth devices are created on connection. List the existing ones // or at least the first one. const QString prefix = QLatin1String(linuxBlueToothDeviceRootC); - const QString friendlyFormat = QLatin1String("Bluetooth device (%1)"); + const QString blueToothfriendlyFormat = QLatin1String("Bluetooth device (%1)"); for (int d = 0; d < 4; d++) { QScopedPointer device(new SymbianDeviceData); device->type = BlueToothCommunication; device->portName = prefix + QString::number(d); if (d == 0 || QFileInfo(device->portName).exists()) { - device->friendlyName = friendlyFormat.arg(device->portName); + device->friendlyName = blueToothfriendlyFormat.arg(device->portName); rc.push_back(SymbianDevice(device.take())); } } + // New kernel versions support /dev/ttyUSB0, /dev/ttyUSB1. Trk responds + // on the latter (usually), try first. + static const char *usbTtyDevices[] = { "/dev/ttyUSB1", "/dev/ttyUSB0" }; + const int usbTtyCount = sizeof(usbTtyDevices)/sizeof(const char *); + for (int d = 0; d < usbTtyCount; d++) { + const QString ttyUSBDevice = QLatin1String(usbTtyDevices[d]); + if (QFileInfo(ttyUSBDevice).exists()) { + SymbianDeviceData *device = new SymbianDeviceData; + device->type = SerialPortCommunication; + device->portName = ttyUSBDevice; + device->friendlyName = QString::fromLatin1("USB/Serial device (%1)").arg(device->portName); + rc.push_back(SymbianDevice(device)); + } + } #endif return rc; } @@ -322,7 +480,7 @@ SymbianDeviceManager *SymbianDeviceManager::instance() return symbianDeviceManager(); } -QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm) +SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDeviceManager &sdm) { d.nospace() << sdm.toString(); return d; diff --git a/tools/runonphone/symbianutils/symbiandevicemanager.h b/tools/runonphone/symbianutils/symbiandevicemanager.h index dcf131a..180173d 100644 --- a/tools/runonphone/symbianutils/symbiandevicemanager.h +++ b/tools/runonphone/symbianutils/symbiandevicemanager.h @@ -46,12 +46,17 @@ #include #include +#include QT_BEGIN_NAMESPACE class QDebug; class QTextStream; QT_END_NAMESPACE +namespace trk { + class TrkDevice; +} + namespace SymbianUtils { struct SymbianDeviceManagerPrivate; @@ -62,11 +67,16 @@ enum DeviceCommunicationType { BlueToothCommunication = 1 }; -// SymbianDevice, explicitly shared. +// SymbianDevice: Explicitly shared device data and a TrkDevice +// instance that can be acquired (exclusively) for use. +// A device removal from the manager will result in the +// device being closed. class SYMBIANUTILS_EXPORT SymbianDevice { explicit SymbianDevice(SymbianDeviceData *data); friend class SymbianDeviceManager; public: + typedef QSharedPointer TrkDevicePtr; + SymbianDevice(); SymbianDevice(const SymbianDevice &rhs); SymbianDevice &operator=(const SymbianDevice &rhs); @@ -77,6 +87,17 @@ public: bool isNull() const; QString portName() const; QString friendlyName() const; + QString additionalInformation() const; + void setAdditionalInformation(const QString &); + + // Acquire: Mark the device as 'out' and return a shared pointer + // unless it is already in use by another owner. The result should not + // be passed on further. + TrkDevicePtr acquireDevice(); + // Give back a device and mark it as 'free'. + void releaseDevice(TrkDevicePtr *ptr = 0); + + bool isOpen() const; // Windows only. QString deviceDesc() const; @@ -86,10 +107,12 @@ public: QString toString() const; private: + void forcedClose(); + QExplicitlySharedDataPointer m_data; }; -QDebug operator<<(QDebug d, const SymbianDevice &); +SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDevice &); inline bool operator==(const SymbianDevice &d1, const SymbianDevice &d2) { return d1.compare(d2) == 0; } @@ -100,13 +123,15 @@ inline bool operator<(const SymbianDevice &d1, const SymbianDevice &d2) /* SymbianDeviceManager: Singleton that maintains a list of Symbian devices. * and emits change signals. - * On Windows, the update slot must be connected to a signal - * emitted from an event handler listening for WM_DEVICECHANGE. */ + * On Windows, the update slot must be connected to a [delayed] signal + * emitted from an event handler listening for WM_DEVICECHANGE. + * Device removal will result in the device being closed. */ class SYMBIANUTILS_EXPORT SymbianDeviceManager : public QObject { Q_OBJECT public: typedef QList SymbianDeviceList; + typedef QSharedPointer TrkDevicePtr; static const char *linuxBlueToothDeviceRootC; @@ -120,17 +145,25 @@ public: SymbianDeviceList devices() const; QString toString() const; + // Acquire a device for use. See releaseDevice(). + TrkDevicePtr acquireDevice(const QString &port); + + int findByPortName(const QString &p) const; QString friendlyNameForPort(const QString &port) const; public slots: void update(); + // Relase a device, make it available for further use. + void releaseDevice(const QString &port); + void setAdditionalInformation(const QString &port, const QString &ai); signals: - void deviceRemoved(const SymbianDevice &d); - void deviceAdded(const SymbianDevice &d); + void deviceRemoved(const SymbianUtils::SymbianDevice &d); + void deviceAdded(const SymbianUtils::SymbianDevice &d); void updated(); private: + void ensureInitialized() const; void update(bool emitSignals); SymbianDeviceList serialPorts() const; SymbianDeviceList blueToothDevices() const; @@ -138,7 +171,7 @@ private: SymbianDeviceManagerPrivate *d; }; -QDebug operator<<(QDebug d, const SymbianDeviceManager &); +SYMBIANUTILS_EXPORT QDebug operator<<(QDebug d, const SymbianDeviceManager &); } // namespace SymbianUtils diff --git a/tools/runonphone/symbianutils/trkdevice.cpp b/tools/runonphone/symbianutils/trkdevice.cpp index b327ab3..bd24300 100644 --- a/tools/runonphone/symbianutils/trkdevice.cpp +++ b/tools/runonphone/symbianutils/trkdevice.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #ifdef Q_OS_WIN @@ -102,6 +103,11 @@ QString winErrorMessage(unsigned long error) enum { verboseTrk = 0 }; +static inline QString msgAccessingClosedDevice(const QString &msg) +{ + return QString::fromLatin1("Error: Attempt to access device '%1', which is closed.").arg(msg); +} + namespace trk { /////////////////////////////////////////////////////////////////////// @@ -155,10 +161,11 @@ namespace trk { /////////////////////////////////////////////////////////////////////// class TrkWriteQueue -{ +{ Q_DISABLE_COPY(TrkWriteQueue) public: explicit TrkWriteQueue(); + void clear(); // Enqueue messages. void queueTrkMessage(byte code, TrkCallback callback, @@ -208,13 +215,24 @@ TrkWriteQueue::TrkWriteQueue() : { } +void TrkWriteQueue::clear() +{ + m_trkWriteToken = 0; + m_trkWriteBusy = false; + m_trkWriteQueue.clear(); + const int discarded = m_writtenTrkMessages.size(); + m_writtenTrkMessages.clear(); + if (verboseTrk) + qDebug() << "TrkWriteQueue::clear: discarded " << discarded; +} + byte TrkWriteQueue::nextTrkWriteToken() { ++m_trkWriteToken; if (m_trkWriteToken == 0) ++m_trkWriteToken; if (verboseTrk) - qDebug() << "Write token: " << m_trkWriteToken; + qDebug() << "nextTrkWriteToken:" << m_trkWriteToken; return m_trkWriteToken; } @@ -349,7 +367,7 @@ class WriterThread : public QThread { Q_OBJECT Q_DISABLE_COPY(WriterThread) -public: +public: explicit WriterThread(const QSharedPointer &context); // Enqueue messages. @@ -357,6 +375,8 @@ public: const QByteArray &data, const QVariant &cookie); void queueTrkInitialPing(); + void clearWriteQueue(); + // Call this from the device read notification with the results. void slotHandleResult(const TrkResult &result); @@ -374,7 +394,7 @@ public slots: private slots: void invokeNoopMessage(const trk::TrkMessage &); -private: +private: bool write(const QByteArray &data, QString *errorMessage); inline int writePendingMessage(); @@ -462,6 +482,7 @@ void WriterThread::terminate() m_waitCondition.wakeAll(); wait(); m_terminate = false; + m_queue.clear(); } #ifdef Q_OS_WIN @@ -561,6 +582,13 @@ void WriterThread::queueTrkMessage(byte code, TrkCallback callback, tryWrite(); } +void WriterThread::clearWriteQueue() +{ + m_dataMutex.lock(); + m_queue.clear(); + m_dataMutex.unlock(); +} + void WriterThread::queueTrkInitialPing() { m_dataMutex.lock(); @@ -592,6 +620,8 @@ class ReaderThreadBase : public QThread Q_DISABLE_COPY(ReaderThreadBase) public: + int bytesPending() const { return m_trkReadBuffer.size(); } + signals: void messageReceived(const trk::TrkResult &result, const QByteArray &rawData); @@ -692,7 +722,7 @@ int WinReaderThread::tryRead() if (!ClearCommError(m_context->device, NULL, &comStat)){ emit error(QString::fromLatin1("ClearCommError failed: %1").arg(winErrorMessage(GetLastError()))); return -7; - } + } const DWORD bytesToRead = qMax(DWORD(1), qMin(comStat.cbInQue, DWORD(BufSize))); // Trigger read DWORD bytesRead = 0; @@ -708,7 +738,7 @@ int WinReaderThread::tryRead() if (readError != ERROR_IO_PENDING) { emit error(QString::fromLatin1("Read error: %1").arg(winErrorMessage(readError))); return -1; - } + } // Wait for either termination or data const DWORD wr = WaitForMultipleObjects(HandleCount, m_handles, false, INFINITE); if (wr == WAIT_FAILED) { @@ -783,7 +813,7 @@ private: int m_terminatePipeFileDescriptors[2]; }; -UnixReaderThread::UnixReaderThread(const QSharedPointer &context) : +UnixReaderThread::UnixReaderThread(const QSharedPointer &context) : ReaderThreadBase(context) { m_terminatePipeFileDescriptors[0] = m_terminatePipeFileDescriptors[1] = -1; @@ -877,8 +907,8 @@ struct TrkDevicePrivate TrkDevicePrivate(); QSharedPointer deviceContext; - QSharedPointer writerThread; - QSharedPointer readerThread; + QScopedPointer writerThread; + QScopedPointer readerThread; QByteArray trkReadBuffer; int verbose; @@ -917,14 +947,14 @@ TrkDevice::~TrkDevice() bool TrkDevice::open(QString *errorMessage) { - if (d->verbose) + if (d->verbose || verboseTrk) qDebug() << "Opening" << port() << "is open: " << isOpen() << " serialFrame=" << serialFrame(); + if (isOpen()) + return true; if (d->port.isEmpty()) { *errorMessage = QLatin1String("Internal error: No port set on TrkDevice"); return false; } - - close(); #ifdef Q_OS_WIN const QString fullPort = QLatin1String("\\\\.\\") + d->port; d->deviceContext->device = CreateFile(reinterpret_cast(fullPort.utf16()), @@ -975,7 +1005,7 @@ bool TrkDevice::open(QString *errorMessage) return false; } #endif - d->readerThread = QSharedPointer(new ReaderThread(d->deviceContext)); + d->readerThread.reset(new ReaderThread(d->deviceContext)); connect(d->readerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)), Qt::QueuedConnection); connect(d->readerThread.data(), SIGNAL(messageReceived(trk::TrkResult,QByteArray)), @@ -983,18 +1013,22 @@ bool TrkDevice::open(QString *errorMessage) Qt::QueuedConnection); d->readerThread->start(); - d->writerThread = QSharedPointer(new WriterThread(d->deviceContext)); + d->writerThread.reset(new WriterThread(d->deviceContext)); connect(d->writerThread.data(), SIGNAL(error(QString)), this, SLOT(emitError(QString)), - Qt::QueuedConnection); - d->writerThread->start(); + Qt::QueuedConnection); + d->writerThread->start(); - if (d->verbose) - qDebug() << "Opened" << d->port; + if (d->verbose || verboseTrk) + qDebug() << "Opened" << d->port << d->readerThread.data() << d->writerThread.data(); return true; } void TrkDevice::close() { + if (verboseTrk) + qDebug() << "close" << d->port << " is open: " << isOpen() + << " read pending " << (d->readerThread.isNull() ? 0 : d->readerThread->bytesPending()) + << sender(); if (!isOpen()) return; if (d->readerThread) @@ -1010,6 +1044,7 @@ void TrkDevice::close() #else d->deviceContext->file.close(); #endif + if (d->verbose) emitLogMessage("Close"); } @@ -1030,6 +1065,8 @@ QString TrkDevice::port() const void TrkDevice::setPort(const QString &p) { + if (verboseTrk) + qDebug() << "setPort" << p; d->port = p; } @@ -1045,6 +1082,8 @@ bool TrkDevice::serialFrame() const void TrkDevice::setSerialFrame(bool f) { + if (verboseTrk) + qDebug() << "setSerialFrame" << f; d->deviceContext->serialFrame = f; } @@ -1060,12 +1099,14 @@ void TrkDevice::setVerbose(int b) void TrkDevice::slotMessageReceived(const trk::TrkResult &result, const QByteArray &rawData) { - d->writerThread->slotHandleResult(result); - if (d->verbose > 1) - qDebug() << "Received: " << result.toString(); - emit messageReceived(result); - if (!rawData.isEmpty()) - emit rawDataReceived(rawData); + if (isOpen()) { // Might receive bytes after closing due to queued connections. + d->writerThread->slotHandleResult(result); + if (d->verbose > 1) + qDebug() << "Received: " << result.toString(); + emit messageReceived(result); + if (!rawData.isEmpty()) + emit rawDataReceived(rawData); + } } void TrkDevice::emitError(const QString &s) @@ -1075,15 +1116,27 @@ void TrkDevice::emitError(const QString &s) emit error(s); } +void TrkDevice::clearWriteQueue() +{ + if (isOpen()) + d->writerThread->clearWriteQueue(); +} + void TrkDevice::sendTrkMessage(byte code, TrkCallback callback, const QByteArray &data, const QVariant &cookie) { + if (!isOpen()) { + emitError(msgAccessingClosedDevice(d->port)); + return; + } if (!d->writerThread.isNull()) { if (d->verbose > 1) { - QByteArray msg = "Sending: "; + QByteArray msg = "Sending: 0x"; msg += QByteArray::number(code, 16); msg += ": "; msg += stringFromArray(data).toLatin1(); + if (cookie.isValid()) + msg += " Cookie: " + cookie.toString().toLatin1(); qDebug("%s", msg.data()); } d->writerThread->queueTrkMessage(code, callback, data, cookie); @@ -1092,12 +1145,20 @@ void TrkDevice::sendTrkMessage(byte code, TrkCallback callback, void TrkDevice::sendTrkInitialPing() { + if (!isOpen()) { + emitError(msgAccessingClosedDevice(d->port)); + return; + } if (!d->writerThread.isNull()) d->writerThread->queueTrkInitialPing(); } bool TrkDevice::sendTrkAck(byte token) { + if (!isOpen()) { + emitError(msgAccessingClosedDevice(d->port)); + return false; + } if (d->writerThread.isNull()) return false; // The acknowledgement must not be queued! diff --git a/tools/runonphone/symbianutils/trkdevice.h b/tools/runonphone/symbianutils/trkdevice.h index 78012fd..1021a7d 100644 --- a/tools/runonphone/symbianutils/trkdevice.h +++ b/tools/runonphone/symbianutils/trkdevice.h @@ -64,12 +64,14 @@ struct TrkDevicePrivate; * Trk communications. Provides synchronous write and asynchronous * read operation. * The serialFrames property specifies whether packets are encapsulated in - * "0x90 " frames, which is currently the case for serial ports. + * "0x90 " frames, which is currently the case for serial ports. * Contains a write message queue allowing * for queueing messages with a notification callback. If the message receives * an ACK, the callback is invoked. - * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronisation. - * The respective message will not be sent, the callback is just invoked. */ + * The special message TRK_WRITE_QUEUE_NOOP_CODE code can be used for synchronization. + * The respective message will not be sent, the callback is just invoked. + * Note that calling open/close in quick succession can cause crashes + * due to the use of queused signals. */ enum { TRK_WRITE_QUEUE_NOOP_CODE = 0x7f }; @@ -111,6 +113,9 @@ public: // Send an Ack synchronously, bypassing the queue bool sendTrkAck(unsigned char token); +public slots: + void clearWriteQueue(); + signals: void messageReceived(const trk::TrkResult &result); // Emitted with the contents of messages enclosed in 07e, not for log output -- cgit v0.12 From d9c5d0698109c39547ee23a883b88a48a4f9f8e1 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 18 Mar 2010 06:08:29 +0100 Subject: Calling setX and setY should send itemSendGeometry/ScenePositionChanged events SetX and setY were calling setPosHelper directly therefore events for itemSendGeometryChange and itemSendScenePositionChange were not sent properly. Task-number:QTBUG-9093 Reviewed-by:janarve --- src/gui/graphicsview/qgraphicsitem.cpp | 6 +++--- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 3c255ef..3a6647c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3482,7 +3482,7 @@ void QGraphicsItem::setX(qreal x) if (qIsNaN(x)) return; - d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y())); + setPos(QPointF(x, d_ptr->pos.y())); } /*! @@ -3509,7 +3509,7 @@ void QGraphicsItem::setY(qreal y) if (qIsNaN(y)) return; - d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y)); + setPos(QPointF(d_ptr->pos.x(), y)); } /*! @@ -3577,7 +3577,7 @@ void QGraphicsItem::setPos(const QPointF &pos) return; // Update and repositition. - if (!(d_ptr->flags & ItemSendsGeometryChanges)) { + if (!(d_ptr->flags & ItemSendsGeometryChanges) && !(d_ptr->flags & ItemSendsScenePositionChanges)) { d_ptr->setPosHelper(pos); return; } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index c0ad8bf..2a44af7 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -9819,6 +9819,16 @@ void tst_QGraphicsItem::scenePosChange() QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 4); QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + + root->setX(1); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 5); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); + + root->setY(1); + QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 6); + QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1); + QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0); } void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() -- cgit v0.12 From fcb738161efc965e91c3d528c31ac77d3a05ac64 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Mon, 22 Mar 2010 00:40:21 +0100 Subject: Fix QGraphicsEffect cache when the item is not visible by the view. We can't rely on the exposed rect since the item can be outside the view so we need to regenerate the complete pixmap. Task-number:QTBUG-8750 Reviewed-by:sroedal --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- src/gui/graphicsview/qgraphicsscene.cpp | 2 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 3a6647c..948ff28 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10936,7 +10936,7 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP // Item coordinates with info. QTransform newEffectTransform = info->transformPtr->inverted(); newEffectTransform *= effectTransform; - scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, info->exposedRegion, + scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform, info->drawItem); } diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index bcdc7d3..29a4be8 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4721,7 +4721,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * if (item->d_ptr->graphicsEffect && item->d_ptr->graphicsEffect->isEnabled()) { ENSURE_TRANSFORM_PTR; QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp, - painter, opacity, wasDirtyParentSceneTransform, drawItem); + painter, opacity, wasDirtyParentSceneTransform, itemHasContents && !itemIsFullyTransparent); QGraphicsEffectSource *source = item->d_ptr->graphicsEffect->d_func()->source; QGraphicsItemEffectSourcePrivate *sourced = static_cast (source->d_func()); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 2a44af7..92a7f2e 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -7719,7 +7719,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QTest::qWait(50); // Make sure all visible items are repainted. - QCOMPARE(item1->repaints, 0); + QCOMPARE(item1->repaints, 1); QCOMPARE(item2->repaints, 1); QCOMPARE(item3->repaints, 1); -- cgit v0.12 From 27380de043105379002075543fffdd67718138ca Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 23 Mar 2010 10:35:57 +0100 Subject: Adding the autotest for the task Task-number: QTBUG-2804 --- .../tst_qitemselectionmodel.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 6ef4305..3b2a716 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -93,6 +93,7 @@ private slots: void task232634_childrenDeselectionSignal(); void task260134_layoutChangedWithAllSelected(); void QTBUG5671_layoutChangedWithAllSelected(); + void QTBUG2804_layoutChangedTreeSelection(); private: QAbstractItemModel *model; @@ -2327,5 +2328,31 @@ void tst_QItemSelectionModel::QTBUG5671_layoutChangedWithAllSelected() QVERIFY(selection.isSelected(index)); } +void tst_QItemSelectionModel::QTBUG2804_layoutChangedTreeSelection() +{ + QStandardItemModel model; + QStandardItem top1("Child1"), top2("Child2"), top3("Child3"); + QStandardItem sub11("Alpha"), sub12("Beta"), sub13("Gamma"), sub14("Delta"), + sub21("Alpha"), sub22("Beta"), sub23("Gamma"), sub24("Delta"); + top1.appendColumn(QList() << &sub11 << &sub12 << &sub13 << &sub14); + top2.appendColumn(QList() << &sub21 << &sub22 << &sub23 << &sub24); + model.appendColumn(QList() << &top1 << &top2 << &top3); + + QItemSelectionModel selModel(&model); + + selModel.select(sub11.index(), QItemSelectionModel::Select); + selModel.select(sub12.index(), QItemSelectionModel::Select); + selModel.select(sub21.index(), QItemSelectionModel::Select); + selModel.select(sub23.index(), QItemSelectionModel::Select); + + QModelIndexList list = selModel.selectedIndexes(); + QCOMPARE(list.count(), 4); + + model.sort(0); //this will provoke a relayout + + QCOMPARE(selModel.selectedIndexes().count(), 4); +} + + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" -- cgit v0.12 From 069853c579f57177f83e5d98aca3cfd5ac809961 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 23 Mar 2010 10:38:14 +0100 Subject: More fool proof way for finding these headers --- mkspecs/features/symbian/qt.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf index 2dc614f..0d2e6eb 100644 --- a/mkspecs/features/symbian/qt.prf +++ b/mkspecs/features/symbian/qt.prf @@ -43,5 +43,5 @@ isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000 # Workaround for the fact that Gnupoc and Symbian chose different approaches to # the letter casing of headers. contains(CONFIG, is_using_gnupoc) { - INCLUDEPATH += $$[QT_INSTALL_PREFIX]/mkspecs/common/symbian/header-wrappers + INCLUDEPATH += $$QMAKESPEC/../../common/symbian/header-wrappers } -- cgit v0.12 From 5d65e3c264332262fb09b8fe6f08d284c088a61d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 23 Mar 2010 10:45:33 +0100 Subject: build fix for mingw we need to define WIN32_LEAN_AND_MEAN to include both windows.h and winsock2.h (http://msdn.microsoft.com/en-us/library/ms737629(VS.85).aspx) --- src/qt3support/network/q3socketdevice_win.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt3support/network/q3socketdevice_win.cpp b/src/qt3support/network/q3socketdevice_win.cpp index 528b50a..1354cfa 100644 --- a/src/qt3support/network/q3socketdevice_win.cpp +++ b/src/qt3support/network/q3socketdevice_win.cpp @@ -47,7 +47,6 @@ #include -# include #if defined (QT_NO_IPV6) # include #else -- cgit v0.12 From 21ca1f5e48a978c76ef7d39628226b5afba2d1a8 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 23 Mar 2010 11:00:40 +0100 Subject: Fixed regular expression matching. We need extra backslashes, otherwise it tries to match the '|' verbatim. --- mkspecs/features/symbian/application_icon.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index ecf987d..b583313 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -31,7 +31,7 @@ contains( CONFIG, no_icon ) { # Note: symbian-sbsv2 builds can't utilize extra compiler for mifconv, so ICON handling is done in code !symbian-sbsv2 { - !contains(ICON, "^(/|\\|.:).*"):ICON = $$_PRO_FILE_PWD_/$$ICON #absolute path + !contains(ICON, "^(/|\\\\|.:).*"):ICON = $$_PRO_FILE_PWD_/$$ICON #absolute path #Makefile: requires paths with backslash ICON_backslashed = $$ICON contains(QMAKE_HOST.os, "Windows"):ICON_backslashed = $$replace( ICON_backslashed, /, \\) -- cgit v0.12 From 8f65acdd3b74788b949d84e59acc881b767e9f15 Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 23 Mar 2010 11:02:34 +0100 Subject: Fixed mif generation on symbian-abld. We have to do backslash fixing because we are using QMAKE_EXTRA_TARGETS instead of QMAKE_EXTRA_COMPILERS, which in turn is needed to get clean targets correct on the symbian/* mkspecs. --- mkspecs/features/symbian/application_icon.prf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index b583313..9979f40 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -34,7 +34,6 @@ contains( CONFIG, no_icon ) { !contains(ICON, "^(/|\\\\|.:).*"):ICON = $$_PRO_FILE_PWD_/$$ICON #absolute path #Makefile: requires paths with backslash ICON_backslashed = $$ICON - contains(QMAKE_HOST.os, "Windows"):ICON_backslashed = $$replace( ICON_backslashed, /, \\) symbian-abld { mifIconZDir = ${ZDIR}$$APP_RESOURCE_DIR @@ -48,6 +47,10 @@ contains( CONFIG, no_icon ) { # Extra compiler rules for mifconv mifconv.target = $$mifIconZDir/$${baseTarget}.mif + contains(QMAKE_HOST.os, "Windows") { + ICON_backslashed = $$replace(ICON_backslashed, /, \\) + mifconv.target = $$replace(mifconv.target, /, \\) + } # Based on: http://www.forum.nokia.com/document/Cpp_Developers_Library # svg-t icons should always use /c32 depth mifconv.commands = mifconv $$mifconv.target /c32 $$ICON_backslashed -- cgit v0.12 From 49b200a700c140510720e1ed5f1b791b406ad0d6 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 23 Mar 2010 11:33:06 +0100 Subject: Fix warning on Sequential Animation Group --- src/corelib/animation/qsequentialanimationgroup.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index 7617c1f..5ca30e6 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -464,12 +464,7 @@ void QSequentialAnimationGroupPrivate::setCurrentAnimation(int index, bool inter void QSequentialAnimationGroupPrivate::activateCurrentAnimation(bool intermediate) { - Q_Q(QSequentialAnimationGroup); - - if (!currentAnimation) - return; - - if (state == QSequentialAnimationGroup::Stopped) + if (!currentAnimation || state == QSequentialAnimationGroup::Stopped) return; currentAnimation->stop(); -- cgit v0.12 From c023432503ca3569ea06a4f71d2d192a6f4e069e Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 23 Mar 2010 12:41:26 +0100 Subject: Fixed usage of xplatform in configure. XQMAKESPEC contains the full path, so don't use that, since the full path could contain "symbian" by accident. --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 9113988..f41f6e1 100755 --- a/configure +++ b/configure @@ -3994,7 +3994,7 @@ if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_X11" = "yes" ]; then EOF fi -if echo "$XQMAKESPEC" | grep symbian > /dev/null ; then +if echo "$XPLATFORM" | grep symbian > /dev/null ; then cat << EOF Qt for Symbian only: @@ -4656,7 +4656,7 @@ if [ "$CFG_S60" = "auto" ]; then fi if [ "$CFG_QS60STYLE" = "auto" ]; then - if echo "$XQMAKESPEC" | grep symbian > /dev/null; then + if echo "$XPLATFORM" | grep symbian > /dev/null; then CFG_QS60STYLE=qt else CFG_QS60STYLE=no -- cgit v0.12 From 2c18a5665f70cd7ff62bfffac2c3f2b5364d7392 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 23 Mar 2010 13:13:06 +0100 Subject: Add new function QTextLine::horizontalAdvance() Add a function to QTextLine which returns the accumulated advance of the glyphs in the text. Previously QTextLine::naturalTextWidth() was used for both this purpose and for calculating the pixel width of the text. Since these two metrics are not the same, either of the two usages would be wrong. QTextLine::naturalTextWidth() has been changed to do what its documentation claims it does, and horizontalAdvance() should now be used for laying out text horizontally. Reviewed-by: Simon Hausmann --- src/gui/painting/qpainter.cpp | 2 +- src/gui/text/qtextlayout.cpp | 14 ++++++++++++++ src/gui/text/qtextlayout.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index db4ace4..1c528fe 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7999,7 +7999,7 @@ start_lengthVariant: for (int i = 0; i < textLayout.lineCount(); i++) { QTextLine line = textLayout.lineAt(i); - qreal advance = textLayout.engine()->lines[i].textAdvance.toReal(); + qreal advance = line.horizontalAdvance(); if (tf & Qt::AlignRight) xoff = r.width() - advance; else if (tf & Qt::AlignHCenter) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 766053c..2fc5d1a 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1570,6 +1570,20 @@ qreal QTextLine::naturalTextWidth() const return eng->lines[i].textWidth.toReal(); } +/*! \since 4.7 + Returns the horizontal advance of the text. The advance of the text + is the distance from its position to the next position at which + text would naturally be drawn. + + By adding the advance to the position of the text line and using this + as the position of a second text line, you will be able to position + the two lines side-by-side without gaps in-between. +*/ +qreal QTextLine::horizontalAdvance() const +{ + return eng->lines[i].textAdvance.toReal(); +} + /*! Lays out the line with the given \a width. The line is filled from its starting position with as many characters as will fit into diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index edae7de..8c93ed6 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -202,6 +202,7 @@ public: bool leadingIncluded() const; qreal naturalTextWidth() const; + qreal horizontalAdvance() const; QRectF naturalTextRect() const; enum Edge { -- cgit v0.12 From afb4eee57f22461c329aac534c8d0468c234acfd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 23 Mar 2010 12:41:35 +0100 Subject: Optimize QMetaObject::indexOf* functions Comparing the first character before calling strcmp gives big speedup, as it avoid the overhead of calling the strcmp function in many cases. In indexOfMethodRelative, fix the normalize case. The computation of the normalized string was put outside of the for loop, but it should have been inside. This was not detected by the test because the wrong string is at the end. In IndexOfMethodRelative, we do not need to check if the method is a signal or a slot, because we only iterate over the right interval. This is only true for code generated by moc since Qt 4.6. Which means that in application compiled with Qt 4.5 and older, indexOfSignal could now return a slot with the same name (and vice-versa), but I this it is safe to ignore that "problem". Reviewed-by: Roberto Raggi Reviewed-by: Kent Hansen --- src/corelib/kernel/qmetaobject.cpp | 63 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 312c4b2..4ad78fd 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -483,38 +483,37 @@ int QMetaObject::classInfoCount() const } /** \internal -* helper class for indexOf{Method,Slot,Signal}, returns the relative index of the method within +* helper function for indexOf{Method,Slot,Signal}, returns the relative index of the method within * the baseObject * \a MethodType might be MethodSignal or MethodSlot, or 0 to match everything. +* \a normalizeStringData set to true if we should do a second pass for old moc generated files normalizing all the symbols. */ template static inline int indexOfMethodRelative(const QMetaObject **baseObject, const char *method, bool normalizeStringData) { - const QMetaObject *m; - for (m = *baseObject; m; m = *baseObject = m->d.superdata) { - const QMetaObject *const m = *baseObject; + for (const QMetaObject *m = *baseObject; m; m = m->d.superdata) { int i = (MethodType == MethodSignal && priv(m->d.data)->revision >= 4) ? (priv(m->d.data)->signalCount - 1) : (priv(m->d.data)->methodCount - 1); - if (i < 0) - continue; - const int end = (MethodType == MethodSlot && priv(m->d.data)->revision >= 4) ? (priv(m->d.data)->signalCount) : 0; if (!normalizeStringData) { for (; i >= end; --i) { - if ((MethodType == 0 || (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType) - && strcmp(method, m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) + const char *stringdata = m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5*i]; + if (method[0] == stringdata[0] && strcmp(method + 1, stringdata + 1) == 0) { + *baseObject = m; return i; + } } } else if (priv(m->d.data)->revision < 5) { - const char *stringdata = (m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5 * i]); - const QByteArray normalizedSignature = QMetaObject::normalizedSignature(stringdata); for (; i >= end; --i) { - if ((MethodType == 0|| (m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodType) - && normalizedSignature == method) + const char *stringdata = (m->d.stringdata + m->d.data[priv(m->d.data)->methodData + 5 * i]); + const QByteArray normalizedSignature = QMetaObject::normalizedSignature(stringdata); + if (normalizedSignature == method) { + *baseObject = m; return i; + } } } } @@ -537,8 +536,8 @@ int QMetaObject::indexOfConstructor(const char *constructor) const if (priv(d.data)->revision < 2) return -1; for (int i = priv(d.data)->constructorCount-1; i >= 0; --i) { - if (strcmp(constructor, d.stringdata - + d.data[priv(d.data)->constructorData + 5*i]) == 0) { + const char *data = d.stringdata + d.data[priv(d.data)->constructorData + 5*i]; + if (data[0] == constructor[0] && strcmp(constructor + 1, data + 1) == 0) { return i; } } @@ -682,18 +681,19 @@ static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, co */ int QMetaObject::indexOfEnumerator(const char *name) const { - int i = -1; const QMetaObject *m = this; - while (m && i < 0) { - for (i = priv(m->d.data)->enumeratorCount-1; i >= 0; --i) - if (strcmp(name, m->d.stringdata - + m->d.data[priv(m->d.data)->enumeratorData + 4*i]) == 0) { + while (m) { + const QMetaObjectPrivate *d = priv(m->d.data); + for (int i = d->enumeratorCount - 1; i >= 0; --i) { + const char *prop = m->d.stringdata + m->d.data[d->enumeratorData + 4*i]; + if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) { i += m->enumeratorOffset(); - break; + return i; } + } m = m->d.superdata; } - return i; + return -1; } /*! @@ -704,26 +704,27 @@ int QMetaObject::indexOfEnumerator(const char *name) const */ int QMetaObject::indexOfProperty(const char *name) const { - int i = -1; const QMetaObject *m = this; - while (m && i < 0) { - for (i = priv(m->d.data)->propertyCount-1; i >= 0; --i) - if (strcmp(name, m->d.stringdata - + m->d.data[priv(m->d.data)->propertyData + 3*i]) == 0) { + while (m) { + const QMetaObjectPrivate *d = priv(m->d.data); + for (int i = d->propertyCount-1; i >= 0; --i) { + const char *prop = m->d.stringdata + m->d.data[d->propertyData + 3*i]; + if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) { i += m->propertyOffset(); - break; + return i; } + } m = m->d.superdata; } - if (i == -1 && priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)){ + if (priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)) { QAbstractDynamicMetaObject *me = const_cast(static_cast(this)); - i = me->createProperty(name, 0); + return me->createProperty(name, 0); } - return i; + return -1; } /*! -- cgit v0.12 From 5d27c5485023998c3771bded0b86f1ae836a44af Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 18 Mar 2010 12:31:52 +0100 Subject: Fix warnings in tst_qobject.cpp --- tests/auto/qobject/tst_qobject.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 0161a68..7b35ef5 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -429,12 +429,14 @@ public: public slots: void on_Sender_signalNoParams() { ++called_slot1; } - void on_Sender_signalWithParams(int i = 0) { ++called_slot2; } - void on_Sender_signalWithParams(int i, QString string) { ++called_slot3; } + void on_Sender_signalWithParams(int i = 0) { ++called_slot2; Q_UNUSED(i); } + void on_Sender_signalWithParams(int i, QString string) { ++called_slot3; Q_UNUSED(i);Q_UNUSED(string); } void on_Sender_signalManyParams() { ++called_slot4; } - void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot5; } - void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff, bool dummy) { ++called_slot6; } - void on_Sender_signalManyParams2(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot7; } + void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot5; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); } + void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff, bool dummy) + { ++called_slot6; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); Q_UNUSED(dummy);} + void on_Sender_signalManyParams2(int i1, int i2, int i3, QString string, bool onoff) + { ++called_slot7; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); } void slotLoopBack() { ++called_slot8; } protected slots: @@ -2090,21 +2092,21 @@ public slots: void constUintPointerSlot(const uint *) { } void constUlongPointerSlot(const ulong *) { } - void structSlot(Struct s) { } - void classSlot(Class c) { } - void enumSlot(Enum e) { } + void structSlot(Struct s) { Q_UNUSED(s); } + void classSlot(Class c) { Q_UNUSED(c); } + void enumSlot(Enum e) { Q_UNUSED(e); } - void structPointerSlot(Struct *s) { } - void classPointerSlot(Class *c) { } - void enumPointerSlot(Enum *e) { } + void structPointerSlot(Struct *s) { Q_UNUSED(s); } + void classPointerSlot(Class *c) { Q_UNUSED(c); } + void enumPointerSlot(Enum *e) { Q_UNUSED(e); } - void constStructPointerSlot(const Struct *s) { } - void constClassPointerSlot(const Class *c) { } - void constEnumPointerSlot(const Enum *e) { } + void constStructPointerSlot(const Struct *s) { Q_UNUSED(s); } + void constClassPointerSlot(const Class *c) { Q_UNUSED(c); } + void constEnumPointerSlot(const Enum *e) { Q_UNUSED(e); } - void constStructPointerConstPointerSlot(const Struct * const *s) { } - void constClassPointerConstPointerSlot(const Class * const *c) { } - void constEnumPointerConstPointerSlot(const Enum * const *e) { } + void constStructPointerConstPointerSlot(const Struct * const *s) { Q_UNUSED(s); } + void constClassPointerConstPointerSlot(const Class * const *c) { Q_UNUSED(c); } + void constEnumPointerConstPointerSlot(const Enum * const *e) { Q_UNUSED(e); } void uintSlot(uint) {}; void unsignedintSlot(unsigned int) {}; -- cgit v0.12 From b17b2443bf8bd1880af593f379c93081ac6d7a80 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 23 Mar 2010 14:16:52 +0100 Subject: tst_QObject: test signals and slots with the same name --- tests/auto/qobject/tst_qobject.cpp | 42 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 7b35ef5..8da3484 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -128,6 +128,7 @@ private slots: void isSignalConnected(); void qMetaObjectConnect(); void qMetaObjectDisconnectOne(); + void sameName(); protected: }; @@ -162,7 +163,7 @@ class SenderObject : public QObject Q_OBJECT public: - SenderObject() : recursionCount(0) {} + SenderObject() : aPublicSlotCalled(0), recursionCount(0) {} void emitSignal1AfterRecursion() { @@ -185,11 +186,12 @@ signals: QT_MOC_COMPAT void signal5(); public slots: - void aPublicSlot(){} + void aPublicSlot() { aPublicSlotCalled++; } public: Q_INVOKABLE void invoke1(){} Q_SCRIPTABLE void sinvoke1(){} + int aPublicSlotCalled; protected: Q_INVOKABLE QT_MOC_COMPAT void invoke2(){} Q_INVOKABLE QT_MOC_COMPAT void invoke2(int){} @@ -3552,5 +3554,41 @@ void tst_QObject::qMetaObjectDisconnectOne() delete r1; } +class ConfusingObject : public SenderObject +{ Q_OBJECT +public slots: + void signal1() { s++; } +signals: + void aPublicSlot(); +public: + int s; + ConfusingObject() : s(0) {} + friend class tst_QObject; +}; + +void tst_QObject::sameName() +{ + ConfusingObject c1, c2; + QVERIFY(connect(&c1, SIGNAL(signal1()), &c1, SLOT(signal1()))); + c1.emitSignal1(); + QCOMPARE(c1.s, 1); + + QVERIFY(connect(&c2, SIGNAL(signal1()), &c1, SIGNAL(signal1()))); + c2.emitSignal1(); + QCOMPARE(c1.s, 2); + + QVERIFY(connect(&c2, SIGNAL(aPublicSlot()), &c1, SLOT(signal1()))); + c2.aPublicSlot(); + QCOMPARE(c2.aPublicSlotCalled, 0); + QCOMPARE(c1.aPublicSlotCalled, 0); + QCOMPARE(c1.s, 3); + + QVERIFY(connect(&c2, SIGNAL(aPublicSlot()), &c1, SLOT(aPublicSlot()))); + c2.aPublicSlot(); + QCOMPARE(c2.aPublicSlotCalled, 0); + QCOMPARE(c1.aPublicSlotCalled, 1); + QCOMPARE(c1.s, 4); +} + QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" -- cgit v0.12 From 4a4458d1cf5ec7885c6f63f739b7ee80c70ad211 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 23 Mar 2010 15:34:38 +0100 Subject: Wrong repaint when changing the default row height in QTreeView When in QTreeView::dataChanged(), we didn't check for the actual change in the value before setting QTreeViewPrivate::defaultItemHeight. Hence, if uniformRowHeights is true, we completely miss any resizing of the items. Reviewed-by: Thierry Task-number: QTBUG-9216 --- src/gui/itemviews/qtreeview.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 61ad79d..4636c50 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -674,15 +674,19 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto // refresh the height cache here; we don't really lose anything by getting the size hint, // since QAbstractItemView::dataChanged() will get the visualRect for the items anyway - int topViewIndex = d->viewIndex(topLeft); - if (topViewIndex == 0) - d->defaultItemHeight = indexRowSizeHint(topLeft); bool sizeChanged = false; + int topViewIndex = d->viewIndex(topLeft); + if (topViewIndex == 0) { + int newDefaultItemHeight = indexRowSizeHint(topLeft); + sizeChanged = d->defaultItemHeight != newDefaultItemHeight; + d->defaultItemHeight = newDefaultItemHeight; + } + if (topViewIndex != -1) { if (topLeft.row() == bottomRight.row()) { int oldHeight = d->itemHeight(topViewIndex); d->invalidateHeightCache(topViewIndex); - sizeChanged = (oldHeight != d->itemHeight(topViewIndex)); + sizeChanged |= (oldHeight != d->itemHeight(topViewIndex)); if (topLeft.column() == 0) d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft); } else { -- cgit v0.12