From 445efa40a290da0f72a4b7c213ea991193d51917 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 24 Sep 2013 15:31:23 +0200 Subject: Fixed QJNIEnvironment reference counting. Change-Id: I02369e0c6472375efeffed577d39b764c591e025 Reviewed-by: Christian Stromme --- src/corelib/kernel/qjni.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 17678fcbba..f26d4379d3 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -160,10 +160,12 @@ QJNIEnvironmentPrivate::QJNIEnvironmentPrivate() : jniEnv(0) { JavaVM *vm = QtAndroidPrivate::javaVM(); - if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) != JNI_EDETACHED) - return; + if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) == JNI_EDETACHED) { + if (vm->AttachCurrentThread(&jniEnv, 0) < 0) + return; + } - if (vm->AttachCurrentThread(&jniEnv, 0) < 0) + if (!jniEnv) return; if (!refCount->hasLocalData()) -- cgit v1.2.3 From f83fa3c95e9ac6badc393c198c8bc08bc45bea96 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 25 Sep 2013 08:56:15 +0200 Subject: Fix a crash in QProcess signal handling on Mac. On Mac, SA_SIGINFO can be set while the handler is SIG_DFL. Change-Id: Ibaeaa1612e27217826841d7400309c45b5a101ea Initial-patch-by: Thiago Macieira Reviewed-by: Thiago Macieira --- src/corelib/io/qprocess_unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index eab3890beb..3c6d294916 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -141,7 +141,8 @@ static void qt_sa_sigchld_sigaction(int signum, siginfo_t *info, void *context) if (qt_sa_old_sigchld_handler.sa_flags & SA_SIGINFO) { void (*oldAction)(int, siginfo_t *, void *) = vsa->sa_sigaction; - oldAction(signum, info, context); + if (oldAction) + oldAction(signum, info, context); } else { void (*oldAction)(int) = vsa->sa_handler; -- cgit v1.2.3 From e358c0095e405d5be5cf9c59a59dd7bb12fba7a4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 24 Sep 2013 16:07:13 +0200 Subject: Fix warning about uninitialized variable Change-Id: I9c1a04556d4c77183d7025ca33314e7dfbf953ab Reviewed-by: John Layt Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezoneprivate_tz.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index d8b8ee81da..62b8f5f7b6 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -618,7 +618,7 @@ void QTzTimeZonePrivate::init(const QByteArray &olsenId) // Offsets are stored as total offset, want to know separate UTC and DST offsets // so find the first non-dst transition to use as base UTC Offset - int utcOffset; + int utcOffset = 0; foreach (const QTzTransition &tran, tranList) { if (!typeList.at(tran.tz_typeind).tz_isdst) { utcOffset = typeList.at(tran.tz_typeind).tz_gmtoff; -- cgit v1.2.3 From 283ba0ef014b0af64318c238819e54f1fa9d876f Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Tue, 24 Sep 2013 15:45:11 +0200 Subject: Android: remove environment variable warnings at app startup. Change-Id: I8542809fd16465a29b4fb7e8276b63d71e1b9c0e Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/android/src/androidjnimain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp index 5941737fde..b51c15c5d9 100644 --- a/src/plugins/platforms/android/src/androidjnimain.cpp +++ b/src/plugins/platforms/android/src/androidjnimain.cpp @@ -455,7 +455,7 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para env->ReleaseStringUTFChars(environmentString, nativeString); m_applicationParams=string.split('\t'); foreach (string, m_applicationParams) { - if (putenv(string.constData())) + if (!string.isEmpty() && putenv(string.constData())) qWarning() << "Can't set environment" << string; } -- cgit v1.2.3 From 7247cb9e4a8c91fd9b233a47fd2620aed3c7be43 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 25 Sep 2013 12:08:23 +0200 Subject: Fix: warning/compilation issue on android Compiler would complain "error: format not a string literal and no format arguments [-Werror=format-security]", since the third argument of __android_log_print() is actually the format string. __android_log_write() is anyway more suited since we're not using any format here. Change-Id: Ic19102a9f15038a7cfcb06b605d7b9a73c3e1175 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/testlib/qplaintestlogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 57ce5b031d..77be0e423e 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -211,7 +211,7 @@ void QPlainTestLogger::outputMessage(const char *str) #elif defined(Q_OS_WIN) OutputDebugStringA(str); #elif defined(Q_OS_ANDROID) - __android_log_print(ANDROID_LOG_INFO, "QTestLib", str); + __android_log_write(ANDROID_LOG_INFO, "QTestLib", str); #endif outputString(str); } -- cgit v1.2.3 From a1a00fc8622379a2f1759d57995e8853a8dd7195 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 19 Sep 2013 15:03:05 +0200 Subject: Fix configure warnings on Windows 7 with MSVC2010. Change-Id: I5c4e27d6437cdf7b0dfd17df812d4506d1be4fb9 Reviewed-by: Friedemann Kleint --- src/corelib/tools/qarraydata.cpp | 2 +- tools/configure/configureapp.cpp | 2 +- tools/configure/environment.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index a61147ad9c..825b3289c7 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -91,7 +91,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, // Allocate additional space if array is growing if (options & Grow) - capacity = qAllocMore(objectSize * capacity, headerSize) / int(objectSize); + capacity = qAllocMore(int(objectSize * capacity), int(headerSize)) / int(objectSize); size_t allocSize = headerSize + objectSize * capacity; diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 576eca5bb9..914e7c9bfd 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1543,7 +1543,7 @@ void Configure::desc(const char *option, const char *description, bool skipInden if (!skipIndent) printf("%*s", optionIndent, ""); - int remaining = descIndent - optionIndent - strlen(option); + int remaining = descIndent - optionIndent - int(strlen(option)); int wrapIndent = descIndent + qMax(0, 1 - remaining); printf("%s", option); diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index d733165271..81769aa043 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -347,7 +347,7 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv if (envStrings) { int strLen = 0; for (LPWSTR envString = envStrings; *(envString); envString += strLen + 1) { - strLen = wcslen(envString); + strLen = int(wcslen(envString)); QString str = QString((const QChar*)envString, strLen); if (!str.startsWith("=")) { // These are added by the system int sepIndex = str.indexOf('='); -- cgit v1.2.3 From d730e07d017ff81268989df9b4e19bb5a65029c2 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 20 Sep 2013 12:47:01 +0200 Subject: Fix truncation and conversion warnings on MSVC2010. Change-Id: I44845e13b97753333a7c80a80ead0b352b8906b0 Reviewed-by: Friedemann Kleint --- src/corelib/tools/qstring.cpp | 2 +- src/gui/image/qimage_ssse3.cpp | 4 ++-- src/gui/painting/qdrawhelper_ssse3.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 9625737d7f..239cf0446a 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -3895,7 +3895,7 @@ static inline __m128i mergeQuestionMarks(__m128i chunk) # else // SSE has no compare instruction for unsigned comparison. // The variables must be shiffted + 0x8000 to be compared - const __m128i signedBitOffset = _mm_set1_epi16(0x8000); + const __m128i signedBitOffset = _mm_set1_epi16(short(0x8000)); const __m128i thresholdMask = _mm_set1_epi16(short(0xff + 0x8000)); const __m128i signedChunk = _mm_add_epi16(chunk, signedBitOffset); diff --git a/src/gui/image/qimage_ssse3.cpp b/src/gui/image/qimage_ssse3.cpp index 9e570a0c96..f50457c32a 100644 --- a/src/gui/image/qimage_ssse3.cpp +++ b/src/gui/image/qimage_ssse3.cpp @@ -65,10 +65,10 @@ Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, con } // Mask the 4 first colors of the RGB888 vector - const __m128i shuffleMask = _mm_set_epi8(0xff, 9, 10, 11, 0xff, 6, 7, 8, 0xff, 3, 4, 5, 0xff, 0, 1, 2); + const __m128i shuffleMask = _mm_set_epi8(char(0xff), 9, 10, 11, char(0xff), 6, 7, 8, char(0xff), 3, 4, 5, char(0xff), 0, 1, 2); // Mask the 4 last colors of a RGB888 vector with an offset of 1 (so the last 3 bytes are RGB) - const __m128i shuffleMaskEnd = _mm_set_epi8(0xff, 13, 14, 15, 0xff, 10, 11, 12, 0xff, 7, 8, 9, 0xff, 4, 5, 6); + const __m128i shuffleMaskEnd = _mm_set_epi8(char(0xff), 13, 14, 15, char(0xff), 10, 11, 12, char(0xff), 7, 8, 9, char(0xff), 4, 5, 6); // Mask to have alpha = 0xff const __m128i alphaMask = _mm_set1_epi32(0xff000000); diff --git a/src/gui/painting/qdrawhelper_ssse3.cpp b/src/gui/painting/qdrawhelper_ssse3.cpp index c6f532ca77..59882f3ae3 100644 --- a/src/gui/painting/qdrawhelper_ssse3.cpp +++ b/src/gui/painting/qdrawhelper_ssse3.cpp @@ -103,7 +103,7 @@ inline static void blend_pixel(quint32 &dst, const quint32 src) if (!minusOffsetToAlignSrcOn16Bytes) {\ /* src is aligned, usual algorithm but with aligned operations.\ See the SSE2 version for more documentation on the algorithm itself. */\ - const __m128i alphaShuffleMask = _mm_set_epi8(0xff,15,0xff,15,0xff,11,0xff,11,0xff,7,0xff,7,0xff,3,0xff,3);\ + const __m128i alphaShuffleMask = _mm_set_epi8(char(0xff),15,char(0xff),15,char(0xff),11,char(0xff),11,char(0xff),7,char(0xff),7,char(0xff),3,char(0xff),3);\ for (; x < length-3; x += 4) { \ const __m128i srcVector = _mm_load_si128((__m128i *)&src[x]); \ const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); \ @@ -124,7 +124,7 @@ inline static void blend_pixel(quint32 &dst, const quint32 src) __m128i srcVectorPrevLoaded = _mm_load_si128((__m128i *)&src[x - minusOffsetToAlignSrcOn16Bytes]);\ const int palignrOffset = minusOffsetToAlignSrcOn16Bytes << 2;\ \ - const __m128i alphaShuffleMask = _mm_set_epi8(0xff,15,0xff,15,0xff,11,0xff,11,0xff,7,0xff,7,0xff,3,0xff,3);\ + const __m128i alphaShuffleMask = _mm_set_epi8(char(0xff),15,char(0xff),15,char(0xff),11,char(0xff),11,char(0xff),7,char(0xff),7,char(0xff),3,char(0xff),3);\ switch (palignrOffset) {\ case 4:\ BLENDING_LOOP(4, length)\ -- cgit v1.2.3 From 25f7cddcab00b8906311950630a1fcee773b46a5 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 18 Sep 2013 11:50:20 +0200 Subject: Doc: Fix module names of multimedia examples in manifest-meta These examples are not in Qt Multimedia, but in Qt Multimedia Widgets module. Change-Id: I44fe0f10aa3229068646ff226551398a0cb3e27e Reviewed-by: Jerome Pasion --- doc/global/manifest-meta.qdocconf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/global/manifest-meta.qdocconf b/doc/global/manifest-meta.qdocconf index 20419f1b29..826266c385 100644 --- a/doc/global/manifest-meta.qdocconf +++ b/doc/global/manifest-meta.qdocconf @@ -125,8 +125,8 @@ manifestmeta.android.names = "QtQuick/Qt Quick Demo - Maroon*" \ "QtLinguist/Arrow Pad Example" \ "QtGui/Raster Window Example" \ "QtGui/Analog Clock Window Example" \ - "QtMultimedia/Video Widget Example" \ - "QtMultimedia/Media Player Example" \ + "QtMultimediaWidgets/Video Widget Example" \ + "QtMultimediaWidgets/Media Player Example" \ "QtSVG/Text Object Example" \ "QtQML/Qt Quick Examples - XMLHttpRequest" \ "QtQuick/Qt Quick Particles Examples - *" \ @@ -188,7 +188,7 @@ manifestmeta.thumbnail.names = "QtConcurrent/Map Example" \ "QtHelp/*" \ "QtMultimedia/AudioEngine Example" \ "QtMultimedia/Declarative Radio Example" \ - "QtMultimedia/Media Player Example" \ + "QtMultimediaWidgets/Media Player Example" \ "QtQml/Extending QML*" \ "QtQuick/Qt Quick Examples - Accessibility" \ "QtSensors/Qt Sensors - SensorGesture QML Type example" \ -- cgit v1.2.3 From 774d74df91869d1178cbcdc7648994576a47f850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Wed, 25 Sep 2013 15:29:37 +0100 Subject: Fix WinCE/MSVC2008 build errors related to std::lower_bound patches. See QTBUG-33473 for more information about this compiler bug. Change-Id: I13b945350fdc38165c1515f0cdd75a53cf37cd6c Reviewed-by: Giuseppe D'Angelo --- src/corelib/io/qurlidna.cpp | 5 +++++ src/gui/image/qxpmhandler.cpp | 5 +++++ src/gui/painting/qcolor_p.cpp | 5 +++++ src/gui/text/qcssparser.cpp | 7 +++++++ src/gui/text/qfontsubset_agl.cpp | 5 +++++ src/gui/text/qtexthtmlparser.cpp | 13 +++++++++++++ 6 files changed, 40 insertions(+) diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index ee95e590f9..988d076025 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -61,6 +61,11 @@ struct NameprepCaseFoldingEntry { ushort mapping[4]; }; +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +inline bool operator<(const NameprepCaseFoldingEntry &one, const NameprepCaseFoldingEntry &other) +{ return one.uc < other.uc; } +#endif + inline bool operator<(uint one, const NameprepCaseFoldingEntry &other) { return one < other.uc; } diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 528bd4ebb1..5edb866b62 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -742,6 +742,11 @@ static const struct XPMRGBData { { QRGB(139,139, 0), "yellow4" }, { QRGB(154,205, 50), "yellowgreen" } }; +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +inline bool operator<(const XPMRGBData &data1, const XPMRGBData &data2) +{ return qstrcmp(data1.name, data2.name) < 0; } +#endif + inline bool operator<(const char *name, const XPMRGBData &data) { return qstrcmp(name, data.name) < 0; } inline bool operator<(const XPMRGBData &data, const char *name) diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index 3f6326fcbe..72b6279b2f 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -289,6 +289,11 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData); #undef rgb +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +inline bool operator<(const RGBData &data1, const RGBData &data2) +{ return qstrcmp(data1.name, data2.name) < 0; } +#endif + inline bool operator<(const char *name, const RGBData &data) { return qstrcmp(name, data.name) < 0; } inline bool operator<(const RGBData &data, const char *name) diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 7a96fbe88b..9c7a57df3d 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -347,6 +347,13 @@ static const QCssKnownValue styleFeatures[NumKnownStyleFeatures - 1] = { { "none", StyleFeature_None } }; +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +Q_STATIC_GLOBAL_OPERATOR bool operator<(const QCssKnownValue &prop1, const QCssKnownValue &prop2) +{ + return QString::compare(QString::fromLatin1(prop1.name), QLatin1String(prop2.name), Qt::CaseInsensitive) < 0; +} +#endif + Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &name, const QCssKnownValue &prop) { return QString::compare(name, QLatin1String(prop.name), Qt::CaseInsensitive) < 0; diff --git a/src/gui/text/qfontsubset_agl.cpp b/src/gui/text/qfontsubset_agl.cpp index 194ecb7ab5..a2c8f7b0a0 100644 --- a/src/gui/text/qfontsubset_agl.cpp +++ b/src/gui/text/qfontsubset_agl.cpp @@ -125,6 +125,11 @@ struct AGLEntry { unsigned short index; }; +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +inline bool operator<(AGLEntry entry1, AGLEntry entry2) +{ return entry1.uc < entry2.uc; } +#endif + inline bool operator<(unsigned short uc, AGLEntry entry) { return uc < entry.uc; } inline bool operator<(AGLEntry entry, unsigned short uc) diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index c177fa0810..952cebcc1b 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -324,6 +324,13 @@ static const struct QTextHtmlEntity { const char *name; quint16 code; } entities { "zwnj", 0x200c } }; +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2) +{ + return QLatin1String(entity1.name) < QLatin1String(entity2.name); +} +#endif + Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &entityStr, const QTextHtmlEntity &entity) { return entityStr < QLatin1String(entity.name); @@ -443,6 +450,12 @@ static const QTextHtmlElement elements[Html_NumElements]= { { "var", Html_var, QTextHtmlElement::DisplayInline }, }; +#if defined(Q_CC_MSVC) && _MSC_VER < 1600 +Q_STATIC_GLOBAL_OPERATOR bool operator<(const QTextHtmlElement &e1, const QTextHtmlElement &e2) +{ + return QLatin1String(e1.name) < QLatin1String(e2.name); +} +#endif Q_STATIC_GLOBAL_OPERATOR bool operator<(const QString &str, const QTextHtmlElement &e) { -- cgit v1.2.3 From 466e0dff4bb686e51d0ab3f905631fcb7dd8bfef Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 19 Sep 2013 17:15:43 +0200 Subject: Add tracing to logging framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4d5b9a24a214785019ff1238c1790ead79205b15 Reviewed-by: Leena Miettinen Reviewed-by: Topi Reiniö Reviewed-by: Robin Burchell Reviewed-by: Thiago Macieira Reviewed-by: Shawn Rutledge --- src/corelib/doc/snippets/qtracer/ftracer.cpp | 180 ++++++++++++++++ src/corelib/doc/snippets/qtracer/main.cpp | 59 ++++++ src/corelib/doc/snippets/qtracer/qtracer.pro | 2 + src/corelib/global/qglobal.cpp | 4 + src/corelib/global/qlogging.cpp | 1 + src/corelib/global/qlogging.h | 2 +- src/corelib/io/qloggingcategory.cpp | 293 ++++++++++++++++++++++++++- src/corelib/io/qloggingcategory.h | 74 ++++++- src/corelib/io/qloggingregistry.cpp | 8 + src/testlib/qtestlog.cpp | 1 + 10 files changed, 618 insertions(+), 6 deletions(-) create mode 100644 src/corelib/doc/snippets/qtracer/ftracer.cpp create mode 100644 src/corelib/doc/snippets/qtracer/main.cpp create mode 100644 src/corelib/doc/snippets/qtracer/qtracer.pro diff --git a/src/corelib/doc/snippets/qtracer/ftracer.cpp b/src/corelib/doc/snippets/qtracer/ftracer.cpp new file mode 100644 index 0000000000..b12e3ed9c3 --- /dev/null +++ b/src/corelib/doc/snippets/qtracer/ftracer.cpp @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include +#include + + +//![1] +QLoggingCategory theFooArea("foo"); +QLoggingCategory theBarArea("bar"); +QLoggingCategory theBazArea("baz"); +//![1] + +// Note: These locations are Ubuntu specific. + +// Note: To make the example work with user permissions, make sure +// the files are user-writable and the path leading there accessible. + +const char traceSwitch[] = "/sys/kernel/debug/tracing/tracing_on"; +const char traceSink[] = "/sys/kernel/debug/tracing/trace_marker"; + +// The base class only serves as a facility to share code +// between the "single line" data logging aspect and the +// scoped "measuring" aspect. + +// Both aspects and the base class could be combined into +// a single tracer serving both purposes, but are split +// here for clarity. + +// Error handling is left as an exercise. + +//![2] +class MyTracerBase : public QTracer +{ +public: + MyTracerBase() { + enable = ::open(traceSwitch, O_WRONLY); + marker = ::open(traceSink, O_WRONLY); + } + + ~MyTracerBase() { + ::close(enable); + ::close(marker); + } + +protected: + int enable; + int marker; +}; +//![2] + + +//![2] +class MyTracer : public MyTracerBase +{ +public: + void start() { ::write(marker, "B", 1); } + void end() { ::write(marker, "E", 1); } +}; +//![2] + + +//![3] +class MyDataLogger : public MyTracerBase +{ +public: + MyDataLogger() { + buf[0] = 0; + pos = 0; + } + + void record(int i) { pos += sprintf(buf + pos, "%d", i); } + void record(const char *msg) { pos += sprintf(buf + pos, "%s", msg); } + void end() { ::write(marker, buf, pos); pos = 0; } + +private: + char buf[100]; + int pos; +}; +//![3] + +// Simplest possible example for "measuring". +//![4] +int foo(int i) +{ + qCTraceGuard(theFooArea); + // Here could be some lengthy code. + return i * i; +} +//![4] + +// We can switch on/off tracing dynamically. +// The tracer will be temporarily switched off at the third call +// and re-enabled at the eighth. +//![5] +int bar(int i) +{ + static int n = 0; + ++n; + if (n == 3) + theBarArea.setEnabled(QtTraceMsg, false); + if (n == 8) + theBarArea.setEnabled(QtTraceMsg, true); + + qCTraceGuard(theBarArea); + return i * i; +} +//![5] + +// An example to create "complex" log messages. +//![6] +int baz(int i) +{ + qCTrace(theBazArea) << 32 << "some stuff"; + + return i * i; +} +//![6] + + + +//![7] +namespace { +static struct Init +{ + Init() { + tracer.addToCategory(theFooArea); + tracer.addToCategory(theBarArea); + logger.addToCategory(theBazArea); + } + + MyTracer tracer; + MyDataLogger logger; + +} initializer; +} +//![7] diff --git a/src/corelib/doc/snippets/qtracer/main.cpp b/src/corelib/doc/snippets/qtracer/main.cpp new file mode 100644 index 0000000000..758a2bbdb8 --- /dev/null +++ b/src/corelib/doc/snippets/qtracer/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +int foo(int i); +int bar(int i); +int baz(int i); + +int main() +{ + int s = 0; + for (int i = 0; i != 10; ++i) + s += foo(i); + + for (int i = 0; i != 10; ++i) + s += bar(i); + + for (int i = 0; i != 10; ++i) + s += baz(i); + + return s; +} + diff --git a/src/corelib/doc/snippets/qtracer/qtracer.pro b/src/corelib/doc/snippets/qtracer/qtracer.pro new file mode 100644 index 0000000000..254e22be76 --- /dev/null +++ b/src/corelib/doc/snippets/qtracer/qtracer.pro @@ -0,0 +1,2 @@ + +SOURCES += ftracer.cpp main.cpp diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 59bdecc868..e2b1502a8e 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -717,6 +717,10 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); A message generated by the qCritical() function. \value QtFatalMsg A message generated by the qFatal() function. + \value QtTraceMsg + Used by the qCTrace() macro. Trace events are usually passed only + to dedicated \a QTracer objects, and do not appear in the installed + message handler. \value QtSystemMsg diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 4d564b09c3..c0709ce258 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -814,6 +814,7 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont case QtWarningMsg: message.append(QLatin1String("warning")); break; case QtCriticalMsg:message.append(QLatin1String("critical")); break; case QtFatalMsg: message.append(QLatin1String("fatal")); break; + case QtTraceMsg: message.append(QLatin1String("trace")); break; } } else if (token == fileTokenC) { if (context.file) diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index 2b798f9ea0..68a24d0397 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE class QDebug; class QNoDebug; -enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg }; +enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtTraceMsg, QtSystemMsg = QtCriticalMsg }; class QMessageLogContext { diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 562cf25964..80acee6ad1 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -107,7 +107,8 @@ QLoggingCategory::QLoggingCategory(const char *category) : name(0), enabledDebug(false), enabledWarning(true), - enabledCritical(true) + enabledCritical(true), + enabledTrace(false) { bool isDefaultCategory = (category == 0) || (strcmp(category, qtDefaultCategoryName) == 0); @@ -122,7 +123,8 @@ QLoggingCategory::QLoggingCategory(const char *category) } if (QLoggingRegistry *reg = QLoggingRegistry::instance()) - reg->registerCategory(this);} + reg->registerCategory(this); +} /*! Destructs a QLoggingCategory object @@ -164,6 +166,7 @@ bool QLoggingCategory::isEnabled(QtMsgType msgtype) const case QtDebugMsg: return enabledDebug; case QtWarningMsg: return enabledWarning; case QtCriticalMsg: return enabledCritical; + case QtTraceMsg: return enabledTrace; case QtFatalMsg: return true; default: break; } @@ -177,6 +180,10 @@ bool QLoggingCategory::isEnabled(QtMsgType msgtype) const change e.g. the settings of another objects for the same category name. \note QtFatalMsg cannot be changed. It will always return true. + + Example: + + \snippet qtracer/ftracer.cpp 5 */ void QLoggingCategory::setEnabled(QtMsgType type, bool enable) { @@ -184,6 +191,7 @@ void QLoggingCategory::setEnabled(QtMsgType type, bool enable) case QtDebugMsg: enabledDebug = enable; break; case QtWarningMsg: enabledWarning = enable; break; case QtCriticalMsg: enabledCritical = enable; break; + case QtTraceMsg: enabledTrace = enable; break; case QtFatalMsg: default: break; } @@ -319,11 +327,60 @@ void QLoggingCategory::setFilterRules(const QString &rules) \snippet qloggingcategory/main.cpp 12 \note Arguments are not processed if critical output for the category is not - enabled, so do not reply on any side effects. + enabled, so do not rely on any side effects. \sa qCritical() */ +/*! + \relates QLoggingCategory + \macro qCTrace(category) + \since 5.2 + + Returns an output stream for trace messages in the logging category + \a category. + + The macro expands to code that first checks whether + \l QLoggingCategory::isEnabled() evaluates for trace output to \c{true}. + If so, the stream arguments are processed and sent to the tracers + registered with the category. + + \note Arguments are not processed if trace output for the category is not + enabled, so do not rely on any side effects. + + Example: + + \snippet qtracer/ftracer.cpp 6 + + \sa qCTraceGuard() +*/ + +/*! + \relates QLoggingCategory + \macro qCTraceGuard(category) + \since 5.2 + + The macro expands to code that creates a guard object with automatic + storage. The guard constructor checks whether + \l QLoggingCategory::isEnabled() evaluates for trace output to \c{true}. + If so, the stream arguments are processed and the \c{start()} + functions of the tracers registered with the \a category are called. + + The guard destructor also checks whether the category is enabled for + tracing and if so, the \c{end()} + functions of the tracers registered with the \a category are called. + + \note Arguments are always processed, even if trace output for the + category is disabled. They will, however, in that case not be passed + to the \c{record()} functions of the registered tracers. + + Example: + + \snippet qtracer/ftracer.cpp 4 + + \sa qCTrace() +*/ + /*! \macro Q_DECLARE_LOGGING_CATEGORY(name) \relates QLoggingCategory @@ -349,4 +406,234 @@ void QLoggingCategory::setFilterRules(const QString &rules) This macro must be used outside of a class or method. */ + +/*! + \class QTracer + \inmodule QtCore + \since 5.2 + + \brief The QTracer class provides an interface for handling + trace events associated with a logging category. + + \c QTracer objects are registered with logging categories. + Multiple \c QTracer objects + can be registered with the same category, and the same + \c QTracer object can be registered with different categories. + + If code containing \c qCTrace is executed, and the associated + logging category is enabled for tracing, all \c QTracer objects + that are registered with the category are notified. + + \c QTracer objects +*/ + +/*! + \fn QTracer::QTracer() + + Constructs a tracer object. + + Example: + + \snippet qtracer/ftracer.cpp 2 +*/ + +/*! + \fn QTracer::~QTracer() + + Destroys the tracer object. +*/ + +/*! + Registers this tracer for the \a category. + + The tracer will later be notified of messages of type + \c QtTraceMsg, as long as that message type + is enabled in the category. + + Example: + + \snippet qtracer/ftracer.cpp 1 + \codeline + \snippet qtracer/ftracer.cpp 7 +*/ + +void QTracer::addToCategory(QLoggingCategory &category) +{ + category.tracers.append(this); +} + +/*! + \fn void QTracer::start() + + This function is invoked when a tracing activity starts, + typically from the constructor of a \c QTraceGuard object + defined by \c qCTrace() or \c qCTraceGuard(). + + The base implementation does nothing. \c QTracer subclasses + are advised to override it if needed. + + \sa qCTrace(), qCTraceGuard() +*/ + +/*! + \fn void QTracer::end() + + This function is invoked when a tracing activity ends, + typically from the destructor of a \c QTraceGuard object + defined by \c qCTrace() or \c qCTraceGuard(). + + The base implementation does nothing. It is common for + \c QTracer subclasses to override it to perform flushing + of collected data. + + \sa qCTrace(), qCTraceGuard() +*/ + +/*! + \fn void QTracer::record(int data) + + This function is invoked during a tracing activity to + pass integer \a data to the \c QTracer object. + + Example: + + \snippet qtracer/ftracer.cpp 3 +*/ + +/*! + \fn void QTracer::record(const char *data) + + This function is invoked during a tracing activity to + pass string \a data to the \c QTracer object. +*/ + +/*! + \fn void QTracer::record(const QVariant &data) + + This function is invoked during a tracing activity to + pass abitrary (non-integer, non-string) \a data to + the \c QTracer object. +*/ + +/*! + \class QTraceGuard + \since 5.2 + \inmodule QtCore + + \brief The QTraceGuard class facilitates notifications to + \c QTracer objects. + + \c QTraceGuard objects are typically implicitly created on the + stack when using the \c qCTrace or \c qCTraceGuard macros and + are associated to a \c QLoggingCategory. + + The constructor of a \c QTraceGuard objects checks whether + its associated category is enabled, and if so, informs all + \c QTracer objects registered with the category that a + tracing activity starts. + + The destructor of a \c QTraceGuard objects checks whether + its associated category is enabled, and if so, informs all + \c QTracer objects registered with the category that a + tracing activity ended. + + A \c QTraceGuard object created by \c qCTrace will be destroyed + at the end of the full expression, a guard created by + \c qCTraceGuard at the end of the block containing the macro. + + During the lifetime of a QTraceGuard object, its \c operator<<() + can be used to pass additional data to the active tracers. + The fast path handles only \c int and \c{const char *} data, + but it is possible to use arbitrary values wrapped in \c QVariants. + + \sa QTracer +*/ + +/*! + \fn QTraceGuard::QTraceGuard(QLoggingCategory &category) + \internal + + Constructs a trace guard object relaying to \a category. +*/ + +/*! + \fn QTraceGuard::~QTraceGuard() + \internal + + Destroys the trace guard object. +*/ + +/*! + \internal + + Calls \c start() on all registered tracers. +*/ + +void QTraceGuard::start() +{ + QLoggingCategory::Tracers &tracers = target->tracers; + for (int i = tracers.size(); --i >= 0; ) + tracers.at(i)->start(); +} + +/*! + \internal + + Calls \c end() on all registered tracers. +*/ + +void QTraceGuard::end() +{ + QLoggingCategory::Tracers &tracers = target->tracers; + for (int i = tracers.size(); --i >= 0; ) + tracers.at(i)->end(); +} + + +/*! + \internal + + This function is called for int parameters passed to the + qCTrace stream. +*/ + +QTraceGuard &QTraceGuard::operator<<(int msg) +{ + QLoggingCategory::Tracers &tracers = target->tracers; + for (int i = tracers.size(); --i >= 0; ) + tracers.at(i)->record(msg); + return *this; +} + +/*! + \internal + + This function is called for string parameters passed to the + qCTrace stream. +*/ + +QTraceGuard &QTraceGuard::operator<<(const char *msg) +{ + QLoggingCategory::Tracers &tracers = target->tracers; + for (int i = tracers.size(); --i >= 0; ) + tracers.at(i)->record(msg); + return *this; +} + + +/*! + \internal + + This function is called for QVariant parameters passed to the + qCTrace stream. +*/ + +QTraceGuard &QTraceGuard::operator<<(const QVariant &msg) +{ + QLoggingCategory::Tracers &tracers = target->tracers; + for (int i = tracers.size(); --i >= 0; ) + tracers.at(i)->record(msg); + return *this; +} + QT_END_NAMESPACE diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h index 90111c96fa..23b25b5e3f 100644 --- a/src/corelib/io/qloggingcategory.h +++ b/src/corelib/io/qloggingcategory.h @@ -44,9 +44,13 @@ #include #include +#include QT_BEGIN_NAMESPACE +class QTracer; +class QTraceGuard; + class Q_CORE_EXPORT QLoggingCategory { Q_DISABLE_COPY(QLoggingCategory) @@ -76,13 +80,18 @@ public: static void setFilterRules(const QString &rules); private: + friend class QLoggingRegistry; + friend class QTraceGuard; + friend class QTracer; + const char *name; bool enabledDebug; bool enabledWarning; bool enabledCritical; - - friend class QLoggingRegistry; + bool enabledTrace; + typedef QVector Tracers; + Tracers tracers; }; template <> @@ -103,6 +112,56 @@ inline bool QLoggingCategory::isEnabled() const return enabledCritical; } +template <> +inline bool QLoggingCategory::isEnabled() const +{ + return enabledTrace; +} + +class Q_CORE_EXPORT QTracer +{ + Q_DISABLE_COPY(QTracer) +public: + QTracer() {} + virtual ~QTracer() {} + + void addToCategory(QLoggingCategory &category); + + virtual void start() {} + virtual void end() {} + virtual void record(int) {} + virtual void record(const char *) {} + virtual void record(const QVariant &) {} +}; + +class Q_CORE_EXPORT QTraceGuard +{ + Q_DISABLE_COPY(QTraceGuard) +public: + QTraceGuard(QLoggingCategory &category) + { + target = category.isEnabled() ? &category : 0; + if (target) + start(); + } + + ~QTraceGuard() + { + if (target) + end(); + } + + QTraceGuard &operator<<(int msg); + QTraceGuard &operator<<(const char *msg); + QTraceGuard &operator<<(const QVariant &msg); + +private: + void start(); + void end(); + + QLoggingCategory *target; +}; + #define Q_DECLARE_LOGGING_CATEGORY(name) \ extern QLoggingCategory &name(); @@ -123,6 +182,17 @@ inline bool QLoggingCategory::isEnabled() const #define qCCritical(category) \ for (bool enabled = category().isEnabled(); enabled; enabled = false) \ QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).critical() +#define qCTrace(category) \ + for (bool enabled = category.isEnabled(); enabled; enabled = false) \ + QTraceGuard(category) + + +#define Q_TRACE_GUARD_NAME_HELPER(line) qTraceGuard ## line +#define Q_TRACE_GUARD_NAME(line) Q_TRACE_GUARD_NAME_HELPER(line) + +#define qCTraceGuard(category) \ + QTraceGuard Q_TRACE_GUARD_NAME(__LINE__)(category); + #if defined(QT_NO_DEBUG_OUTPUT) # undef qCDebug diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index a82e6f65f4..885b51709d 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -86,6 +86,9 @@ int QLoggingRule::pass(const QString &categoryName, QtMsgType msgType) const case QtCriticalMsg: fullCategory += QLatin1String(".critical"); break; + case QtTraceMsg: + fullCategory += QLatin1String(".trace"); + break; default: break; } @@ -288,6 +291,7 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat) bool debug = (cat->categoryName() == qtDefaultCategoryName); bool warning = true; bool critical = true; + bool trace = true; QString categoryName = QLatin1String(cat->categoryName()); QLoggingRegistry *reg = QLoggingRegistry::instance(); @@ -301,11 +305,15 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat) filterpass = item.pass(categoryName, QtCriticalMsg); if (filterpass != 0) critical = (filterpass > 0); + filterpass = item.pass(categoryName, QtTraceMsg); + if (filterpass != 0) + trace = (filterpass > 0); } cat->setEnabled(QtDebugMsg, debug); cat->setEnabled(QtWarningMsg, warning); cat->setEnabled(QtCriticalMsg, critical); + cat->setEnabled(QtTraceMsg, trace); } diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index d094372d0b..10936f5c03 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -257,6 +257,7 @@ namespace QTest { } switch (type) { + case QtTraceMsg: case QtDebugMsg: QTest::TestLoggers::addMessage(QAbstractTestLogger::QDebug, msg); break; -- cgit v1.2.3 From 9a683bfb84464bbf051236c4e3c2710219cbf0d5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Sep 2013 19:37:39 +0200 Subject: QCocoaApplicationDelegate: Play nice with the user's application delegate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We tended to ignore the original application delegate a bit too often. Change-Id: I0844c8658d128e4fbb9a6fc5000025f55e5293c2 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 423d552627..f9767ce716 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -210,9 +210,10 @@ static void cleanupCocoaApplicationDelegate() - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { // The reflection delegate gets precedence - if (reflectionDelegate - && [reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) { - return [reflectionDelegate applicationShouldTerminate:sender]; + if (reflectionDelegate) { + if ([reflectionDelegate respondsToSelector:@selector(applicationShouldTerminate:)]) + return [reflectionDelegate applicationShouldTerminate:sender]; + return NSTerminateNow; } if ([self canQuit]) { @@ -327,12 +328,11 @@ static void cleanupCocoaApplicationDelegate() - (void)applicationDidBecomeActive:(NSNotification *)notification { - Q_UNUSED(notification); -/* if (reflectionDelegate && [reflectionDelegate respondsToSelector:@selector(applicationDidBecomeActive:)]) [reflectionDelegate applicationDidBecomeActive:notification]; +/* onApplicationChangedActivation(true); if (!QWidget::mouseGrabber()){ @@ -351,12 +351,11 @@ static void cleanupCocoaApplicationDelegate() - (void)applicationDidResignActive:(NSNotification *)notification { - Q_UNUSED(notification); -/* if (reflectionDelegate && [reflectionDelegate respondsToSelector:@selector(applicationDidResignActive:)]) [reflectionDelegate applicationDidResignActive:notification]; +/* onApplicationChangedActivation(false); if (!QWidget::mouseGrabber()) -- cgit v1.2.3 From 1db90754826730dc810b92f9a741243b90ae8da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 24 Sep 2013 18:04:14 +0200 Subject: Android: Use the application's class loader when loading Java classes. Previously the system class loader was used, which meant only system Java classes where available. With this change it's no longer necessary to add a JNI_OnLoad() to get a handle to application specific classes. Change-Id: Ic8fe35b4e525bfeb1d317d5ba6b496e39bf9bb30 Reviewed-by: Yoann Lopes --- src/corelib/kernel/qjni.cpp | 16 ++++++++++++---- src/corelib/kernel/qjnihelpers.cpp | 20 ++++++++++++++++++++ src/corelib/kernel/qjnihelpers_p.h | 1 + 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index f26d4379d3..d1113e4eae 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -70,16 +70,24 @@ static jclass getCachedClass(JNIEnv *env, const char *className) QString key = QLatin1String(className); QHash::iterator it = cachedClasses->find(key); if (it == cachedClasses->end()) { - jclass c = env->FindClass(className); + QJNIObjectPrivate classLoader = QtAndroidPrivate::classLoader(); + if (!classLoader.isValid()) + return 0; + + QJNIObjectPrivate stringName = QJNIObjectPrivate::fromString(QLatin1String(className)); + QJNIObjectPrivate classObject = classLoader.callObjectMethod("loadClass", + "(Ljava/lang/String;)Ljava/lang/Class;", + stringName.object()); if (env->ExceptionCheck()) { - c = 0; #ifdef QT_DEBUG env->ExceptionDescribe(); #endif // QT_DEBUG env->ExceptionClear(); } - if (c) - clazz = static_cast(env->NewGlobalRef(c)); + + if (classObject.isValid()) + clazz = static_cast(env->NewGlobalRef(classObject.object())); + cachedClasses->insert(key, clazz); } else { clazz = it.value(); diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp index a95194b66a..fbcd0606e6 100644 --- a/src/corelib/kernel/qjnihelpers.cpp +++ b/src/corelib/kernel/qjnihelpers.cpp @@ -45,6 +45,7 @@ QT_BEGIN_NAMESPACE static JavaVM *g_javaVM = Q_NULLPTR; static jobject g_jActivity = Q_NULLPTR; +static jobject g_jClassLoader = Q_NULLPTR; static inline bool exceptionCheck(JNIEnv *env) { @@ -79,6 +80,20 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env) if (exceptionCheck(env)) return JNI_ERR; + + + jmethodID classLoaderMethodID = env->GetStaticMethodID(jQtNative, + "classLoader", + "()Ljava/lang/ClassLoader;"); + + if (exceptionCheck(env)) + return JNI_ERR; + + jobject classLoader = env->CallStaticObjectMethod(jQtNative, classLoaderMethodID); + if (exceptionCheck(env)) + return JNI_ERR; + + g_jClassLoader = env->NewGlobalRef(classLoader); g_jActivity = env->NewGlobalRef(activity); g_javaVM = vm; @@ -96,4 +111,9 @@ JavaVM *QtAndroidPrivate::javaVM() return g_javaVM; } +jobject QtAndroidPrivate::classLoader() +{ + return g_jClassLoader; +} + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h index 8719ae044b..39059db215 100644 --- a/src/corelib/kernel/qjnihelpers_p.h +++ b/src/corelib/kernel/qjnihelpers_p.h @@ -63,6 +63,7 @@ namespace QtAndroidPrivate Q_CORE_EXPORT jobject activity(); Q_CORE_EXPORT JavaVM *javaVM(); Q_CORE_EXPORT jint initJNI(JavaVM *vm, JNIEnv *env); + jobject classLoader(); } QT_END_NAMESPACE -- cgit v1.2.3 From 1749bab56538316a579c8f02da0bdaadfe75c11d Mon Sep 17 00:00:00 2001 From: Matt Hoosier Date: Wed, 25 Sep 2013 08:22:45 -0500 Subject: Allow QDir::mkpath() to work on QNX QNet paths Due to a quirk in the way that QNX's mkdir() implementation reports return values when the requested pathname is the mountpoint of a QNet filesystem, the usual recursive directory creation algorithm used by QDir fails if the destination directory happens to exist inside QNet. This is an artificial failure; the desired directory can still be created with the normal mkdir() algorithm. There just needs to error handling in place to allow the recursive creation of parents to recognize this situation. Change-Id: I350fd9cb39858570032f9146c1154a9287701569 Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_unix.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index a7517b4c7f..46d8101e20 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -511,7 +511,14 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea if (slash) { const QByteArray chunk = QFile::encodeName(dirName.left(slash)); if (QT_MKDIR(chunk.constData(), 0777) != 0) { - if (errno == EEXIST) { + if (errno == EEXIST +#if defined(Q_OS_QNX) + // On QNX the QNet (VFS paths of other hosts mounted under a directory + // such as /net) mountpoint returns ENOENT, despite existing. stat() + // on the QNet mountpoint returns successfully and reports S_IFDIR. + || errno == ENOENT +#endif + ) { QT_STATBUF st; if (QT_STAT(chunk.constData(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR) continue; -- cgit v1.2.3 From f04b46f34e9446417cd5681f511332344679ef30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 25 Sep 2013 17:18:38 +0200 Subject: Don't assume QCoreApplication::applicationName() will never change Tests will typically create multiple QCoreApplications, some of them with different argv[0] than others, so we can't use a static variable to keep the cached application name. Change-Id: Icd97527730558944473a71373326b4a82f1b7cf7 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 14 ++++++++------ src/corelib/kernel/qcoreapplication_p.h | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index f3caa1d918..553eaf0820 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -146,15 +146,17 @@ QString QCoreApplicationPrivate::macMenuBarName() #endif QString QCoreApplicationPrivate::appName() const { - static QString applName; + if (applicationName.isNull()) { #ifdef Q_OS_MAC - applName = macMenuBarName(); + applicationName = macMenuBarName(); #endif - if (applName.isEmpty() && argv[0]) { - char *p = strrchr(argv[0], '/'); - applName = QString::fromLocal8Bit(p ? p + 1 : argv[0]); + if (applicationName.isEmpty() && argv[0]) { + char *p = strrchr(argv[0], '/'); + applicationName = QString::fromLocal8Bit(p ? p + 1 : argv[0]); + } } - return applName; + + return applicationName; } #endif diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 6a3bea9c9e..477b8cfcfe 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -83,6 +83,7 @@ public: ~QCoreApplicationPrivate(); QString appName() const; + mutable QString applicationName; #ifdef Q_OS_MAC static QString macMenuBarName(); -- cgit v1.2.3 From c66d42f97299c19fab40a7f59be961e6928f43ed Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 25 Sep 2013 11:24:01 +0200 Subject: QKeySequenceEdit: cleanup unused member variable Change-Id: Ib1197aee7589be0afd0c639b362bf1c3fceffeb4 Reviewed-by: Marc Mutz --- src/widgets/widgets/qkeysequenceedit.cpp | 2 +- src/widgets/widgets/qkeysequenceedit_p.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index a71c0ada70..a1915e41ef 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -59,7 +59,7 @@ void QKeySequenceEditPrivate::init() prevKey = -1; releaseTimer = 0; - layout = new QVBoxLayout(q); + QVBoxLayout *layout = new QVBoxLayout(q); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(lineEdit); diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h index 2de86b3a05..58c9699059 100644 --- a/src/widgets/widgets/qkeysequenceedit_p.h +++ b/src/widgets/widgets/qkeysequenceedit_p.h @@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_KEYSEQUENCEEDIT class QLineEdit; -class QVBoxLayout; class QKeySequenceEditPrivate : public QWidgetPrivate { @@ -66,7 +65,6 @@ public: void finishEditing(); QLineEdit *lineEdit; - QVBoxLayout *layout; QKeySequence keySequence; int keyNum; int key[MaxKeyCount]; -- cgit v1.2.3 From 935e52108d54f76fbcdc09479125ec5f7a3bb5b2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 20 Sep 2013 03:07:14 +0200 Subject: QtConcurrent::IterateKernel: fix a race on a cache variable getticks() can be called concurrently, so accessing a non-atomic static long, even when the assignment will produce the same value in evey case, constitutes a data race. Fixed by making 'useThreadCpuTime' atomic. Since atomic long's might not be supported on all platforms, use an atomic int instead. To avoid a narrowing conversion, and since we're not interested in the return value of sysconf(), only whether it succeeded, convert any non-error return value to 0 prior to storing in the atomic. Change-Id: Ic285f7801327b30ddcd9c24bf1ccee3112a447b1 Reviewed-by: Olivier Goffart --- src/concurrent/qtconcurrentiteratekernel.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/concurrent/qtconcurrentiteratekernel.cpp b/src/concurrent/qtconcurrentiteratekernel.cpp index c3b35afe3f..268d85cb01 100644 --- a/src/concurrent/qtconcurrentiteratekernel.cpp +++ b/src/concurrent/qtconcurrentiteratekernel.cpp @@ -90,10 +90,13 @@ static qint64 getticks() # if (_POSIX_THREAD_CPUTIME-0 == 0) // detect availablility of CLOCK_THREAD_CPUTIME_ID - static long useThreadCpuTime = -2; + static QBasicAtomicInt sUseThreadCpuTime = Q_BASIC_ATOMIC_INITIALIZER(-2); + int useThreadCpuTime = sUseThreadCpuTime.load(); if (useThreadCpuTime == -2) { - // sysconf() will return either -1 or _POSIX_VERSION (don't care about thread races here) - useThreadCpuTime = sysconf(_SC_THREAD_CPUTIME); + // sysconf() will return either -1L or _POSIX_VERSION + // (don't care about sysconf's exact return value) + useThreadCpuTime = sysconf(_SC_THREAD_CPUTIME) == -1L ? -1 : 0 ; + sUseThreadCpuTime.store(useThreadCpuTime); // might happen multiple times, but doesn't matter } if (useThreadCpuTime != -1) clockId = CLOCK_THREAD_CPUTIME_ID; -- cgit v1.2.3 From 0a3a05f418a7c79cf11f0851f9793c558e3656e8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 23 Sep 2013 17:09:45 +0200 Subject: Fix setting android minimum/target version We need to output integers here, since these are interpreted as integers when reading the json. Change-Id: I4206b3ac347b61a357bd2658f146979e06690141 Reviewed-by: Paul Olav Tvete --- mkspecs/features/android_deployment_settings.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/android_deployment_settings.prf b/mkspecs/features/android_deployment_settings.prf index 2f64d47f04..1e54b67789 100644 --- a/mkspecs/features/android_deployment_settings.prf +++ b/mkspecs/features/android_deployment_settings.prf @@ -45,10 +45,10 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-no-sdk { FILE_CONTENT += " \"android-package\": \"$$ANDROID_PACKAGE\"," !isEmpty(ANDROID_MINIMUM_VERSION): \ - FILE_CONTENT += " \"android-minimum-version\": \"$$ANDROID_MINIMUM_VERSION\"," + FILE_CONTENT += " \"android-minimum-version\": $$ANDROID_MINIMUM_VERSION," !isEmpty(ANDROID_TARGET_VERSION): \ - FILE_CONTENT += " \"android-target-version\": \"$$ANDROID_TARGET_VERSION\"," + FILE_CONTENT += " \"android-target-version\": $$ANDROID_TARGET_VERSION," !isEmpty(ANDROID_APP_NAME): \ FILE_CONTENT += " \"android-app-name\": \"$$ANDROID_APP_NAME\"," -- cgit v1.2.3 From 39e04b022227c52c9e6aac1942919f68247e1394 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 23 Sep 2013 17:10:33 +0200 Subject: Remove logic which changes install rules inside Qt dir A common problem is that examples and other apps are unusable on Android when they are inside the Qt directory. There doesn't really seem to be any good reason for having a special case in place, since this will only affect applications which are not built with the host toolchain, and we aren't building any command line apps for the target devices. So the only thing this will affect are the examples and we want those to be installed into the correct path. Change-Id: Ibae365e06eb77944f11e596c16c3c5baf798848c Reviewed-by: BogDan Vatra --- mkspecs/features/android.prf | 13 +++++-------- src/android/java/java.pro | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/mkspecs/features/android.prf b/mkspecs/features/android.prf index 2a3086d4ad..5e21f0b845 100644 --- a/mkspecs/features/android.prf +++ b/mkspecs/features/android.prf @@ -2,13 +2,10 @@ contains(TEMPLATE, ".*app") { !android_app { !contains(TARGET, ".so"): TARGET = lib$${TARGET}.so QMAKE_LFLAGS += -Wl,-soname,$$TARGET + + android_install: { + target.path=/libs/$$ANDROID_TARGET_ARCH/ + INSTALLS *= target + } } } -!QTDIR_build:android_install { - isEmpty(QT_BUILD_TREE) { - target.path=/libs/$$ANDROID_TARGET_ARCH/ - } else { - target.path = / - } - INSTALLS *= target -} diff --git a/src/android/java/java.pro b/src/android/java/java.pro index 22c8ecc034..9d682e4f23 100644 --- a/src/android/java/java.pro +++ b/src/android/java/java.pro @@ -1,4 +1,4 @@ -CONFIG -= qt +CONFIG -= qt android_install javaresources.files = \ $$PWD/AndroidManifest.xml \ -- cgit v1.2.3 From d4ec6331bbdfa9d1b9db70287c1917e9b353f39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 25 Sep 2013 10:25:18 +0200 Subject: tst_QNetworkReply: Don't remove file if never created If we end up QSKIP'ing the test 'wronlyFileName' is never created. Change-Id: I2ccbfdb630b58d7904e73b476a65a82a45ab90d7 Reviewed-by: Peter Hartmann --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 3d57345d2d..0e8d9fa2a3 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1416,7 +1416,8 @@ void tst_QNetworkReply::initTestCase() void tst_QNetworkReply::cleanupTestCase() { #if !defined Q_OS_WIN - QFile::remove(wronlyFileName); + if (!wronlyFileName.isNull()) + QFile::remove(wronlyFileName); #endif #ifndef QT_NO_BEARERMANAGEMENT if (networkSession && networkSession->isOpen()) { -- cgit v1.2.3 From 9bd350d03d3c702a4b767e9ebd8c487013e4c315 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Thu, 26 Sep 2013 14:08:00 +0200 Subject: Doc: Adding "qtdoc" to the depends qdocconf variable. -needed to link to Qt 5.2 docs (as seen on the navigation bar) Change-Id: Icc0bdb95231dbccd0393d4f401daafd8bcb30472 Reviewed-by: Martin Smith --- src/concurrent/doc/qtconcurrent.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/concurrent/doc/qtconcurrent.qdocconf b/src/concurrent/doc/qtconcurrent.qdocconf index 7fa437c17f..9d89192946 100644 --- a/src/concurrent/doc/qtconcurrent.qdocconf +++ b/src/concurrent/doc/qtconcurrent.qdocconf @@ -27,7 +27,7 @@ qhp.QtConcurrent.subprojects.classes.sortPages = true tagfile = ../../../doc/qtconcurrent/qtconcurrent.tags -depends += qtcore +depends += qtcore qtdoc headerdirs += .. -- cgit v1.2.3 From 696060134d10d44175970ffd38618544ecdd9387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 26 Sep 2013 13:20:27 +0200 Subject: Make QCoreApplicationPrivate::appName() thread-safe Change-Id: Iea0d208e3e4721fff8a6667e0df1203a887c29d3 Reviewed-by: Olivier Goffart --- src/corelib/kernel/qcoreapplication.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 553eaf0820..3ae4e523c8 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -146,6 +146,9 @@ QString QCoreApplicationPrivate::macMenuBarName() #endif QString QCoreApplicationPrivate::appName() const { + static QBasicMutex applicationNameMutex; + QMutexLocker locker(&applicationNameMutex); + if (applicationName.isNull()) { #ifdef Q_OS_MAC applicationName = macMenuBarName(); -- cgit v1.2.3 From 0bf30a7caba53aa85dcbdc877ace5e25bf45b526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 26 Sep 2013 15:01:32 +0200 Subject: iOS: Propagate xcodebuild exit-code from makefile wrapper Without bash's pipefail option we would end up with the exit code of grep. Since we don't know which shell the user is running, we have to explicitly call bash. Change-Id: Ic3f6db0af9bb90a58001ccfbf9d6d21b6c9c9634 Reviewed-by: Joerg Bornemann --- mkspecs/features/ios/default_post.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/ios/default_post.prf b/mkspecs/features/ios/default_post.prf index 654255eb1f..3322047788 100644 --- a/mkspecs/features/ios/default_post.prf +++ b/mkspecs/features/ios/default_post.prf @@ -19,7 +19,7 @@ equals(TEMPLATE, app) { # We use xcodebuild to do the actual build, but filter out the verbose # output that shows all environment variables for each build step. - xcodebuild_build.commands = "@xcodebuild build | grep -v setenv" + xcodebuild_build.commands = "@bash -o pipefail -c 'xcodebuild | grep -v setenv'" QMAKE_EXTRA_TARGETS += xcodebuild_build all.depends = xcodebuild_build QMAKE_EXTRA_TARGETS += all -- cgit v1.2.3 From a3530859e9a7423db0b6839f15538f248aaf4a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 25 Sep 2013 16:23:45 +0200 Subject: Expose QTest::currentAppName() and remove hard-coded argv[0] in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Except where we're actually testing QCoreApplication::applicationName() and friends. Change-Id: I25514884c11f43a4f82b1f818f822dc3d79f69a3 Reviewed-by: Tor Arne Vestbø --- src/testlib/qtestcase.cpp | 12 ++++++-- src/testlib/qtestcase.h | 2 ++ src/testlib/qtestlog.cpp | 2 +- src/testlib/qtestresult.cpp | 10 +++---- src/testlib/qtestresult_p.h | 4 +-- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 2 +- .../tst_qprocessnoapplication.cpp | 3 +- .../qcoreapplication/tst_qcoreapplication.cpp | 32 +++++++++++----------- .../qcommandlineparser/tst_qcommandlineparser.cpp | 11 +++++++- .../kernel/qguiapplication/tst_qguiapplication.cpp | 2 +- tests/auto/sql/kernel/qsql/tst_qsql.cpp | 20 +++++++------- 11 files changed, 59 insertions(+), 41 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index bae4a29457..ff90ed1c0e 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1612,7 +1612,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) } } - bool installedTestCoverage = installCoverageTool(QTestResult::currentAppname(), QTestResult::currentTestObjectName()); + bool installedTestCoverage = installCoverageTool(QTestResult::currentAppName(), QTestResult::currentTestObjectName()); QTestLog::setInstalledTestCoverage(installedTestCoverage); // If no loggers were created by the long version of the -o command-line @@ -2167,7 +2167,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) QTestResult::setCurrentTestObject(metaObject->className()); if (argc > 0) - QTestResult::setCurrentAppname(argv[0]); + QTestResult::setCurrentAppName(argv[0]); qtest_qParseArgs(argc, argv, false); @@ -2520,6 +2520,14 @@ QTestData &QTest::newRow(const char *dataTag) \sa QTest::newRow(), QFETCH(), QMetaType */ +/*! + Returns the name of the binary that is currently executed. +*/ +const char *QTest::currentAppName() +{ + return QTestResult::currentAppName(); +} + /*! Returns the name of the test function that is currently executed. diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 6b5e7a574b..ba727b5afe 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -200,6 +200,8 @@ namespace QTest Q_TESTLIB_EXPORT void *qElementData(const char *elementName, int metaTypeId); Q_TESTLIB_EXPORT QObject *testObject(); + Q_TESTLIB_EXPORT const char *currentAppName(); + Q_TESTLIB_EXPORT const char *currentTestFunction(); Q_TESTLIB_EXPORT const char *currentDataTag(); Q_TESTLIB_EXPORT bool currentTestFailed(); diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 10936f5c03..5b6cbe658c 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -394,7 +394,7 @@ void QTestLog::stopLogging() QTest::TestLoggers::stopLogging(); QTest::TestLoggers::destroyLoggers(); QTest::loggerUsingStdout = false; - saveCoverageTool(QTestResult::currentAppname(), failCount() != 0, QTestLog::installedTestCoverage()); + saveCoverageTool(QTestResult::currentAppName(), failCount() != 0, QTestLog::installedTestCoverage()); } void QTestLog::addLogger(LogMode mode, const char *filename) diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp index 7ab317f209..d94b2bf85c 100644 --- a/src/testlib/qtestresult.cpp +++ b/src/testlib/qtestresult.cpp @@ -63,7 +63,7 @@ namespace QTest static const char *expectFailComment = 0; static int expectFailMode = 0; - static const char *currentAppname = 0; + static const char *currentAppName = 0; } void QTestResult::reset() @@ -318,14 +318,14 @@ bool QTestResult::skipCurrentTest() return QTest::skipCurrentTest; } -void QTestResult::setCurrentAppname(const char *appname) +void QTestResult::setCurrentAppName(const char *appName) { - QTest::currentAppname = appname; + QTest::currentAppName = appName; } -const char *QTestResult::currentAppname() +const char *QTestResult::currentAppName() { - return QTest::currentAppname; + return QTest::currentAppName; } QT_END_NAMESPACE diff --git a/src/testlib/qtestresult_p.h b/src/testlib/qtestresult_p.h index 769800d90d..ea8173b169 100644 --- a/src/testlib/qtestresult_p.h +++ b/src/testlib/qtestresult_p.h @@ -93,8 +93,8 @@ public: static void setSkipCurrentTest(bool value); static bool skipCurrentTest(); - static void setCurrentAppname(const char *appname); - static const char *currentAppname(); + static void setCurrentAppName(const char *appName); + static const char *currentAppName(); private: Q_DISABLE_COPY(QTestResult) diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 290afec776..4a50a45ea6 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -324,7 +324,7 @@ void tst_QGlobal::qCoreAppStartupFunction() { QCOMPARE(qStartupFunctionValue, 0); int argc = 1; - char *argv[] = { const_cast("tst_qglobal") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); QCOMPARE(qStartupFunctionValue, 124); } diff --git a/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp b/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp index 33146cafd1..21d03cd04d 100644 --- a/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp +++ b/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp @@ -70,8 +70,7 @@ void tst_QProcessNoApplication::initializationDeadlock() } }; - static char argv0[] = "tst_QProcessNoApplication"; - char *argv[] = { argv0, 0 }; + char *argv[] = { const_cast(QTest::currentAppName()), 0 }; int argc = 1; QCoreApplication app(argc, argv); MyThread thread; diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index ccaa2bec4f..78f2cdae69 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -88,7 +88,7 @@ public: void tst_QCoreApplication::sendEventsOnProcessEvents() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); EventSpy spy; @@ -110,7 +110,7 @@ void tst_QCoreApplication::getSetCheck() // Test the property { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); QCOMPARE(app.property("applicationVersion").toString(), v); } @@ -135,7 +135,7 @@ void tst_QCoreApplication::argc() { { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); QCOMPARE(argc, 1); QCOMPARE(app.arguments().count(), 1); @@ -143,7 +143,7 @@ void tst_QCoreApplication::argc() { int argc = 4; - char *argv[] = { const_cast("tst_qcoreapplication"), + char *argv[] = { const_cast(QTest::currentAppName()), const_cast("arg1"), const_cast("arg2"), const_cast("arg3") }; @@ -162,7 +162,7 @@ void tst_QCoreApplication::argc() { int argc = 2; - char *argv[] = { const_cast("tst_qcoreapplication"), + char *argv[] = { const_cast(QTest::currentAppName()), const_cast("-qmljsdebugger=port:3768,block") }; QCoreApplication app(argc, argv); QCOMPARE(argc, 1); @@ -196,7 +196,7 @@ public: void tst_QCoreApplication::postEvent() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); EventSpy spy; @@ -281,7 +281,7 @@ void tst_QCoreApplication::postEvent() void tst_QCoreApplication::removePostedEvents() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); EventSpy spy; @@ -460,7 +460,7 @@ public: void tst_QCoreApplication::deliverInDefinedOrder() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); DeliverInDefinedOrderObject obj(&app); @@ -500,7 +500,7 @@ public: void tst_QCoreApplication::globalPostedEventsCount() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); QCoreApplication::sendPostedEvents(); @@ -546,7 +546,7 @@ public: void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); ProcessEventsAlwaysSendsPostedEventsObject object; @@ -564,7 +564,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() void tst_QCoreApplication::reexec() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); // exec once @@ -579,7 +579,7 @@ void tst_QCoreApplication::reexec() void tst_QCoreApplication::execAfterExit() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); app.exit(1); @@ -590,7 +590,7 @@ void tst_QCoreApplication::execAfterExit() void tst_QCoreApplication::eventLoopExecAfterExit() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); // exec once and exit @@ -648,7 +648,7 @@ void tst_QCoreApplication::customEventDispatcher() QVERIFY(!weak_ed.isNull()); { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); // instantiating app should not overwrite the ED QCOMPARE(QCoreApplication::eventDispatcher(), ed); @@ -763,7 +763,7 @@ private slots: void tst_QCoreApplication::testQuitLock() { int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); QuitTester tester; @@ -782,7 +782,7 @@ void tst_QCoreApplication::QTBUG31606_QEventDestructorDeadLock() }; int argc = 1; - char *argv[] = { const_cast("tst_qcoreapplication") }; + char *argv[] = { const_cast(QTest::currentAppName()) }; QCoreApplication app(argc, argv); EventSpy spy; diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index 9219ff72df..d8965dee5d 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -48,6 +48,9 @@ class tst_QCommandLineParser : public QObject { Q_OBJECT +public slots: + void initTestCase(); + private slots: void parsingModes_data(); @@ -81,9 +84,15 @@ private slots: void testQuoteEscaping(); }; -static char *empty_argv[] = { const_cast("tst_qcommandlineparser") }; +static char *empty_argv[] = { 0 }; static int empty_argc = 1; +void tst_QCommandLineParser::initTestCase() +{ + Q_ASSERT(!empty_argv[0]); + empty_argv[0] = const_cast(QTest::currentAppName()); +} + Q_DECLARE_METATYPE(QCommandLineParser::SingleDashWordOptionMode) void tst_QCommandLineParser::parsingModes_data() diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 0f224c4909..7884426d68 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -768,7 +768,7 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents() testPluginInfo.rawMetaData = qt_plugin_query_metadata; qRegisterStaticPluginFunction(testPluginInfo); int argc = 3; - char *argv[] = { const_cast("tst_qguiapplication"), const_cast("-plugin"), const_cast("testplugin") }; + char *argv[] = { const_cast(QTest::currentAppName()), const_cast("-plugin"), const_cast("testplugin") }; QGuiApplication app(argc, argv); QVERIFY(QGuiApplication::primaryScreen()); diff --git a/tests/auto/sql/kernel/qsql/tst_qsql.cpp b/tests/auto/sql/kernel/qsql/tst_qsql.cpp index bc6b36931a..5747683e4e 100644 --- a/tests/auto/sql/kernel/qsql/tst_qsql.cpp +++ b/tests/auto/sql/kernel/qsql/tst_qsql.cpp @@ -114,8 +114,8 @@ void tst_QSql::cleanup() void tst_QSql::basicDriverTest() { int argc = 1; - const char *argv[] = {"test"}; - QGuiApplication app(argc, const_cast(argv), false); + char *argv[] = { const_cast(QTest::currentAppName()) }; + QGuiApplication app(argc, argv, false); tst_Databases dbs; dbs.open(); @@ -155,10 +155,10 @@ void tst_QSql::open() { int i; int argc = 1; - const char *argv[] = {"test"}; + char *argv[] = { const_cast(QTest::currentAppName()) }; int count = -1; for (i = 0; i < 10; ++i) { - QGuiApplication app(argc, const_cast(argv), false); + QGuiApplication app(argc, argv, false); tst_Databases dbs; dbs.open(); @@ -184,8 +184,8 @@ void tst_QSql::openInvalid() void tst_QSql::concurrentAccess() { int argc = 1; - const char *argv[] = {"test"}; - QGuiApplication app(argc, const_cast(argv), false); + char *argv[] = { const_cast(QTest::currentAppName()) }; + QGuiApplication app(argc, argv, false); tst_Databases dbs; dbs.open(); @@ -213,8 +213,8 @@ void tst_QSql::concurrentAccess() void tst_QSql::openErrorRecovery() { int argc = 1; - const char *argv[] = {"test"}; - QGuiApplication app(argc, const_cast(argv), false); + char *argv[] = { const_cast(QTest::currentAppName()) }; + QGuiApplication app(argc, argv, false); tst_Databases dbs; dbs.addDbs(); @@ -261,8 +261,8 @@ void tst_QSql::openErrorRecovery() void tst_QSql::registerSqlDriver() { int argc = 1; - const char *argv[] = {"test"}; - QGuiApplication app(argc, const_cast(argv), false); + char *argv[] = { const_cast(QTest::currentAppName()) }; + QGuiApplication app(argc, argv, false); QSqlDatabase::registerSqlDriver("QSQLTESTDRIVER", new QSqlDriverCreator); QVERIFY(QSqlDatabase::drivers().contains("QSQLTESTDRIVER")); -- cgit v1.2.3 From 2864ba28e1611a9ad9d08f8e4b5faad744e97d6f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 26 Sep 2013 16:22:28 +0200 Subject: Remove code that doesn't do anything. Change-Id: Id2528167f21e1ab81b998ceb808a9fc4a24b239a Reviewed-by: Yoann Lopes --- src/gui/opengl/qopenglpaintengine.cpp | 19 ------------------- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 12 ------------ 2 files changed, 31 deletions(-) diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 78f5080caf..05135519f8 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -89,12 +89,6 @@ #include -// ####TODO Properly #ifdef this class to use #define symbols actually defined -// by OpenGL/ES includes -#ifndef GL_FRAMEBUFFER_SRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - QT_BEGIN_NAMESPACE @@ -1860,25 +1854,12 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type } } - bool srgbFrameBufferEnabled = false; - if (funcs.hasOpenGLExtension(QOpenGLExtensions::SRGBFrameBuffer)) { - if (false) - { - glEnable(GL_FRAMEBUFFER_SRGB); - srgbFrameBufferEnabled = true; - } - } - #if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #else glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data()); #endif - - if (srgbFrameBufferEnabled) - glDisable(GL_FRAMEBUFFER_SRGB); - } void QOpenGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 80660041b7..3b29923586 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -86,12 +86,6 @@ #include -// ####TODO Properly #ifdef this class to use #define symbols actually defined -// by OpenGL/ES includes -#ifndef GL_FRAMEBUFFER_SRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - QT_BEGIN_NAMESPACE @@ -1868,18 +1862,12 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp } } - bool srgbFrameBufferEnabled = false; - #if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #else glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data()); #endif - - if (srgbFrameBufferEnabled) - glDisable(GL_FRAMEBUFFER_SRGB); - } void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, -- cgit v1.2.3 From e120ad442d7ebff0b9862e8af9ebf9717b5ac92e Mon Sep 17 00:00:00 2001 From: Marko Pellikka Date: Thu, 22 Aug 2013 17:45:47 -0700 Subject: QString::reserve fix to avoid truncation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case of implicit memory sharing, QString::reserve caused data truncation if given size was smaller than size of data. Task-number: QTBUG-29664 Change-Id: If2da5ad051385635ebb829c18b5ebaa349f08e8a Reviewed-by: Olivier Goffart Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qstring.h | 4 ++-- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 701082c7e6..2eaed65148 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -934,8 +934,8 @@ inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); } inline void QString::reserve(int asize) { - if (d->ref.isShared() || uint(asize) + 1u > d->alloc) - reallocData(uint(asize) + 1u); + if (d->ref.isShared() || uint(asize) >= d->alloc) + reallocData(qMax(asize, d->size) + 1u); if (!d->capacityReserved) { // cannot set unconditionally, since d could be the shared_null/shared_empty (which is const) diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 0148ba6d03..48874781c0 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -5240,6 +5240,18 @@ void tst_QString::resizeAfterReserve() s += "hello world"; s.resize(0); QVERIFY(s.capacity() == 100); + + // reserve() can't be used to truncate data + s.fill('x', 100); + s.reserve(50); + QVERIFY(s.capacity() == 100); + QVERIFY(s.size() == 100); + + // even with increased ref count truncation isn't allowed + QString t = s; + s.reserve(50); + QVERIFY(s.capacity() == 100); + QVERIFY(s.size() == 100); } void tst_QString::resizeWithNegative() const -- cgit v1.2.3 From 4ec31ce56adf6cd36cc7e31306fb9d0d1bb1b4f9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 24 Sep 2013 15:57:29 +0200 Subject: evdevtouch: Avoid duplicating points in released state Points in released state should only be removed from m_contacts after the disappeared-since-last-sync is done. Otherwise the same point can appear twice (both times in released state) in the same event. Change-Id: Ia751054c3fe893006a090bdce96a64738d8388ac Reviewed-by: Gunnar Sletta --- src/platformsupport/input/evdevtouch/qevdevtouch.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp index 08f9860ccf..a7502fbcc0 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp @@ -271,6 +271,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, d->hw_pressure_max = absInfo.maximum; } } + char name[1024]; if (ioctl(m_fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) { d->hw_name = QString::fromLocal8Bit(name); @@ -452,9 +453,6 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) } addTouchPoint(contact, &combinedStates); - - if (contact.state == Qt::TouchPointReleased) - it.remove(); } // Now look for contacts that have disappeared since the last sync. @@ -469,6 +467,15 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) } } + // Remove contacts that have just been reported as released. + it = m_contacts; + while (it.hasNext()) { + it.next(); + Contact &contact(it.value()); + if (contact.state == Qt::TouchPointReleased) + it.remove(); + } + m_lastContacts = m_contacts; if (!m_typeB && !m_singleTouch) m_contacts.clear(); -- cgit v1.2.3 From 091ca0ede21b62a55893307018722b384052c642 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 24 Sep 2013 16:37:59 +0200 Subject: evdevtouch: Fix ABS limit queries Add the missing parentheses around the conditional expression. EVIOCGABS and similar macros do not have guarding parentheses in older kernel headers. Change-Id: I5f464351e9407d90643d4e73d4afdbb2ad88b02b Reviewed-by: Gunnar Sletta --- src/platformsupport/input/evdevtouch/qevdevtouch.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp index a7502fbcc0..176373e9f9 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp @@ -254,16 +254,25 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, input_absinfo absInfo; memset(&absInfo, 0, sizeof(input_absinfo)); - if (ioctl(m_fd, EVIOCGABS(d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X), &absInfo) >= 0) { + bool has_x_range = false, has_y_range = false; + + if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X)), &absInfo) >= 0) { qDebug("min X: %d max X: %d", absInfo.minimum, absInfo.maximum); d->hw_range_x_min = absInfo.minimum; d->hw_range_x_max = absInfo.maximum; + has_x_range = true; } - if (ioctl(m_fd, EVIOCGABS(d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y), &absInfo) >= 0) { + + if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y)), &absInfo) >= 0) { qDebug("min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum); d->hw_range_y_min = absInfo.minimum; d->hw_range_y_max = absInfo.maximum; + has_y_range = true; } + + if (!has_x_range || !has_y_range) + qWarning("evdevtouch: Invalid ABS limits, behavior unspecified"); + if (ioctl(m_fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) { qDebug("min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum); if (absInfo.maximum > absInfo.minimum) { -- cgit v1.2.3 From 9bf820ce4769a873a38bf97678d717bf82c4a285 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 24 Sep 2013 14:03:18 +0200 Subject: Fix device-specific eglfs hooks to provide createNativeWindow correctly Change-Id: I21aa17de7a79278d41b30a7590603c3382607673 Reviewed-by: Gunnar Sletta --- mkspecs/devices/linux-arm-amlogic-8726M-g++/qeglfshooks_8726m.cpp | 7 ++++--- mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp | 7 ++++--- mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp | 5 +++-- mkspecs/unsupported/android-g++/qeglfshooks_surfaceflinger.cpp | 5 +++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mkspecs/devices/linux-arm-amlogic-8726M-g++/qeglfshooks_8726m.cpp b/mkspecs/devices/linux-arm-amlogic-8726M-g++/qeglfshooks_8726m.cpp index cca9b98332..7c63625d39 100644 --- a/mkspecs/devices/linux-arm-amlogic-8726M-g++/qeglfshooks_8726m.cpp +++ b/mkspecs/devices/linux-arm-amlogic-8726M-g++/qeglfshooks_8726m.cpp @@ -54,7 +54,7 @@ class QEglFS8726MHooks : public QEglFSHooks { public: virtual QSize screenSize() const; - virtual EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format); + virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format); virtual void destroyNativeWindow(EGLNativeWindowType window); }; @@ -75,9 +75,10 @@ QSize QEglFS8726MHooks::screenSize() const return QSize(vinfo.xres, vinfo.yres); } -EGLNativeWindowType QEglFS8726MHooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format) +EGLNativeWindowType QEglFS8726MHooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) { - Q_UNUSED(format); + Q_UNUSED(window) + Q_UNUSED(format) fbdev_window *window = new fbdev_window; window->width = size.width(); diff --git a/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp b/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp index 6f59b73921..2a5ee74648 100644 --- a/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp +++ b/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp @@ -49,7 +49,7 @@ class QEglFSImx6Hooks : public QEglFSHooks public: QEglFSImx6Hooks(); virtual QSize screenSize() const; - virtual EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format); + virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format); virtual void destroyNativeWindow(EGLNativeWindowType window); virtual EGLNativeDisplayType platformDisplay() const; @@ -78,9 +78,10 @@ EGLNativeDisplayType QEglFSImx6Hooks::platformDisplay() const return mNativeDisplay; } -EGLNativeWindowType QEglFSImx6Hooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format) +EGLNativeWindowType QEglFSImx6Hooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) { - Q_UNUSED(format); + Q_UNUSED(window) + Q_UNUSED(format) EGLNativeWindowType eglWindow = fbCreateWindow(mNativeDisplay, 0, 0, size.width(), size.height()); return eglWindow; diff --git a/mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp b/mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp index add96bf14e..671f525250 100644 --- a/mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp +++ b/mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp @@ -226,7 +226,7 @@ public: virtual void platformDestroy(); virtual EGLNativeDisplayType platformDisplay() const; virtual QSize screenSize() const; - virtual EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format); + virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format); virtual void destroyNativeWindow(EGLNativeWindowType window); virtual bool hasCapability(QPlatformIntegration::Capability cap) const; @@ -258,8 +258,9 @@ QSize QEglFSPiHooks::screenSize() const return QSize(width, height); } -EGLNativeWindowType QEglFSPiHooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format) +EGLNativeWindowType QEglFSPiHooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) { + Q_UNUSED(window) return createDispmanxLayer(QPoint(0, 0), size, 1, format.hasAlpha() ? DISPMANX_FLAGS_ALPHA_FROM_SOURCE : DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS); } diff --git a/mkspecs/unsupported/android-g++/qeglfshooks_surfaceflinger.cpp b/mkspecs/unsupported/android-g++/qeglfshooks_surfaceflinger.cpp index 78a1eb183e..5f4b6a392c 100644 --- a/mkspecs/unsupported/android-g++/qeglfshooks_surfaceflinger.cpp +++ b/mkspecs/unsupported/android-g++/qeglfshooks_surfaceflinger.cpp @@ -62,7 +62,7 @@ class QEglFSPandaHooks : public QEglFSHooks { public: QEglFSPandaHooks(); - virtual EGLNativeWindowType createNativeWindow(const QSize &size, const QSurfaceFormat &format); + virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format); virtual bool filterConfig(EGLDisplay display, EGLConfig config) const; virtual const char *fbDeviceName() const { return "/dev/graphics/fb0"; } @@ -103,8 +103,9 @@ void QEglFSPandaHooks::ensureFramebufferNativeWindowCreated() window->query(window, NATIVE_WINDOW_FORMAT, &mFramebufferVisualId); } -EGLNativeWindowType QEglFSPandaHooks::createNativeWindow(const QSize &size, const QSurfaceFormat &format) +EGLNativeWindowType QEglFSPandaHooks::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) { + Q_UNUSED(window) return mUseFramebuffer ? createNativeWindowFramebuffer(size, format) : createNativeWindowSurfaceFlinger(size, format); } -- cgit v1.2.3 From 279db88c39ae51db2cde80559e30e52457536d12 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 26 Sep 2013 15:55:03 +0200 Subject: Correct the detection of Windows-generated mouse events Check only bit 8 to decide if the mouse event is generated from a touch or pen event. Task-number: QTBUG-33460 Change-Id: I83b23267b5de6df5e0e6b7113ecf377dd7e86c84 Reviewed-by: Friedemann Kleint Reviewed-by: Shawn Rutledge --- src/plugins/platforms/windows/qwindowsmousehandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 3782b7e020..3dd8c5a0cd 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -168,11 +168,13 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, return translateMouseWheelEvent(window, hwnd, msg, result); #ifndef Q_OS_WINCE - // Check for events synthesized from touch. Lower byte is touch index, 0 means pen. static const bool passSynthesizedMouseEvents = QWindowsIntegration::instance()->options() & QWindowsIntegration::PassOsMouseEventsSynthesizedFromTouch; if (!passSynthesizedMouseEvents) { + // Check for events synthesized from touch. Lower 7 bits are touch/pen index, bit 8 indicates touch. + // However, when tablet support is active, extraInfo is a packet serial number. This is not a problem + // since we do not want to ignore mouse events coming from a tablet. const quint64 extraInfo = GetMessageExtraInfo(); - const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0xff); + const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0x80); if (fromTouch) return false; } -- cgit v1.2.3 From 77dc33dcdbe0eec8ddc9059c4e0ff9dde264c5fa Mon Sep 17 00:00:00 2001 From: John Layt Date: Wed, 18 Sep 2013 15:53:18 +0100 Subject: QLocale - Fix Mac date format code translation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mac uses the CLDR format codes which need to be translated into their Qt equivalent. The existing code mistranslates the year code, is outdated for a number of new codes introduced in recent versions of CLDR, and by default accepted any codes it didn't recognize. This change updates support to the latest version of CLDR, fixes the treatment of years, and defaults to ignoring any new format codes added in the future. Note that this change cannot have auto tests written as the system locale formats change between versions of OSX. Testing must be done manually by changing system locale and formats. Task-number: QTBUG-25057 Change-Id: I69dda25b4a0b38d3971995644546306876922d57 Reviewed-by: Morten Johan Sørvig --- src/corelib/tools/qlocale_mac.mm | 105 ++++++++++++++++------- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 5 +- 2 files changed, 77 insertions(+), 33 deletions(-) diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm index 43a0d67e74..deb5d5eb1d 100644 --- a/src/corelib/tools/qlocale_mac.mm +++ b/src/corelib/tools/qlocale_mac.mm @@ -166,6 +166,11 @@ static QString macTimeToString(const QTime &time, bool short_format) return QCFString(CFDateFormatterCreateStringWithDate(0, myFormatter, myDate)); } +// Mac uses the Unicode CLDR format codes +// http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table +// See also qtbase/util/local_database/dateconverter.py +// Makes the assumption that input formats are always well formed and consecutive letters +// never exceed the maximum for the format code. static QString macToQtFormat(const QString &sys_fmt) { QString result; @@ -185,55 +190,97 @@ static QString macToQtFormat(const QString &sys_fmt) int repeat = qt_repeatCount(sys_fmt, i); switch (c.unicode()) { - case 'G': // Qt doesn't support these :( - case 'Y': - case 'D': - case 'F': - case 'w': - case 'W': - case 'g': + // Qt does not support the following options + case 'G': // Era (1..5): 4 = long, 1..3 = short, 5 = narrow + case 'Y': // Year of Week (1..n): 1..n = padded number + case 'U': // Cyclic Yar Name (1..5): 4 = long, 1..3 = short, 5 = narrow + case 'Q': // Quarter (1..4): 4 = long, 3 = short, 1..2 = padded number + case 'q': // Standalone Quarter (1..4): 4 = long, 3 = short, 1..2 = padded number + case 'w': // Week of Year (1..2): 1..2 = padded number + case 'W': // Week of Month (1): 1 = number + case 'D': // Day of Year (1..3): 1..3 = padded number + case 'F': // Day of Week in Month (1): 1 = number + case 'g': // Modified Julian Day (1..n): 1..n = padded number + case 'A': // Milliseconds in Day (1..n): 1..n = padded number break; - case 'u': // extended year - use 'y' - if (repeat < 4) + case 'y': // Year (1..n): 2 = short year, 1 & 3..n = padded number + case 'u': // Extended Year (1..n): 2 = short year, 1 & 3..n = padded number + // Qt only supports long (4) or short (2) year, use long for all others + if (repeat == 2) result += QLatin1String("yy"); else result += QLatin1String("yyyy"); break; - case 'S': // fractional second - if (repeat < 3) - result += QLatin1Char('z'); + case 'M': // Month (1..5): 4 = long, 3 = short, 1..2 = number, 5 = narrow + case 'L': // Standalone Month (1..5): 4 = long, 3 = short, 1..2 = number, 5 = narrow + // Qt only supports long, short and number, use short for narrow + if (repeat == 5) + result += QLatin1String("MMM"); else - result += QLatin1String("zzz"); + result += QString(repeat, QLatin1Char('M')); break; - case 'E': - if (repeat <= 3) - result += QLatin1String("ddd"); - else + case 'd': // Day of Month (1..2): 1..2 padded number + result += QString(repeat, c); + break; + case 'E': // Day of Week (1..6): 4 = long, 1..3 = short, 5..6 = narrow + // Qt only supports long, short and padded number, use short for narrow + if (repeat == 4) result += QLatin1String("dddd"); + else + result += QLatin1String("ddd"); break; - case 'e': - if (repeat >= 2) - result += QLatin1String("dd"); + case 'e': // Local Day of Week (1..6): 4 = long, 3 = short, 5..6 = narrow, 1..2 padded number + case 'c': // Standalone Local Day of Week (1..6): 4 = long, 3 = short, 5..6 = narrow, 1..2 padded number + // Qt only supports long, short and padded number, use short for narrow + if (repeat >= 5) + result += QLatin1String("ddd"); else - result += QLatin1Char('d'); + result += QString(repeat, QLatin1Char('d')); break; - case 'a': + case 'a': // AM/PM (1): 1 = short + // Translate to Qt uppercase AM/PM result += QLatin1String("AP"); break; - case 'k': + case 'h': // Hour [1..12] (1..2): 1..2 = padded number + case 'K': // Hour [0..11] (1..2): 1..2 = padded number + case 'j': // Local Hour [12 or 24] (1..2): 1..2 = padded number + // Qt h is local hour + result += QString(repeat, QLatin1Char('h')); + break; + case 'H': // Hour [0..23] (1..2): 1..2 = padded number + case 'k': // Hour [1..24] (1..2): 1..2 = padded number + // Qt H is 0..23 hour result += QString(repeat, QLatin1Char('H')); break; - case 'K': - result += QString(repeat, QLatin1Char('h')); + case 'm': // Minutes (1..2): 1..2 = padded number + case 's': // Seconds (1..2): 1..2 = padded number + result += QString(repeat, c); + break; + case 'S': // Fractional second (1..n): 1..n = tuncates to decimal places + // Qt uses msecs either unpadded or padded to 3 places + if (repeat < 3) + result += QLatin1Char('z'); + else + result += QLatin1String("zzz"); break; - case 'z': - case 'Z': - case 'v': + case 'z': // Time Zone (1..4) + case 'Z': // Time Zone (1..5) + case 'O': // Time Zone (1, 4) + case 'v': // Time Zone (1, 4) + case 'V': // Time Zone (1..4) + case 'X': // Time Zone (1..5) + case 'x': // Time Zone (1..5) result += QLatin1Char('t'); break; default: - result += QString(repeat, c); + // a..z and A..Z are reserved for format codes, so any occurrence of these not + // already processed are not known and so unsupported formats to be ignored. + // All other chars are allowed as literals. + if (c < QLatin1Char('A') || c > QLatin1Char('z') || + (c > QLatin1Char('Z') && c < QLatin1Char('a'))) { + result += QString(repeat, c); + } break; } diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 8411cfe29b..d6dea05755 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1407,10 +1407,7 @@ void tst_QLocale::macDefaultLocale() QCOMPARE(locale.decimalPoint(), QChar('.')); QCOMPARE(locale.groupSeparator(), QChar(',')); QCOMPARE(locale.dateFormat(QLocale::ShortFormat), QString("M/d/yy")); - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_6) - QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, y")); - else - QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy")); + QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy")); QCOMPARE(locale.timeFormat(QLocale::ShortFormat), QString("h:mm AP")); QCOMPARE(locale.timeFormat(QLocale::LongFormat), QString("h:mm:ss AP t")); -- cgit v1.2.3 From 5889b239b17b27f0c93fe4f8a56fc1cc32708e8b Mon Sep 17 00:00:00 2001 From: Vitalii Shastun Date: Fri, 20 Sep 2013 18:23:33 +0300 Subject: Fix QT_NO_PRINTER build on Mac On Mac the QT_NO_PRINTER build was not implemented. Task-number: QTBUG-33565 Change-Id: I118472f9400aa0a0d0e192ae39a11ea38a66f340 Reviewed-by: John Layt --- src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 4 ++-- src/plugins/platforms/cocoa/qcocoaprintersupport.h | 2 ++ src/plugins/platforms/cocoa/qcocoaprintersupport.mm | 4 ++++ src/plugins/platforms/cocoa/qpaintengine_mac.mm | 2 ++ src/printsupport/dialogs/qpagesetupdialog_mac.mm | 3 ++- src/printsupport/dialogs/qprintdialog_mac.mm | 4 ++-- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 873fa3eed9..a53a6bca46 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -133,7 +133,7 @@ void QCocoaNativeInterface::beep() QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport() { -#ifndef QT_NO_WIDGETS +#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) return new QCocoaPrinterSupport(); #else qFatal("Printing is not supported when Qt is configured with -no-widgets"); @@ -143,7 +143,7 @@ QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport() void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine) { -#ifndef QT_NO_WIDGETS +#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) QMacPrintEnginePrivate *macPrintEnginePriv = static_cast(printEngine)->d_func(); if (macPrintEnginePriv->state == QPrinter::Idle && !macPrintEnginePriv->isPrintSessionInitialized()) macPrintEnginePriv->initialize(); diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.h b/src/plugins/platforms/cocoa/qcocoaprintersupport.h index 83cf1ffada..a48790ef34 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.h +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.h @@ -43,6 +43,7 @@ #define QCOCOAPRINTERSUPPORT_H #include +#ifndef QT_NO_PRINTER #include "qt_mac_p.h" @@ -64,4 +65,5 @@ private: QPrinterInfo printerInfoFromPMPrinter(const PMPrinter &printer); }; +#endif // QT_NO_PRINTER #endif // QCOCOAPRINTERSUPPORT_H diff --git a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm index cfa23b7a30..cb2aa7132b 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintersupport.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintersupport.mm @@ -40,6 +40,8 @@ ****************************************************************************/ #include "qcocoaprintersupport.h" + +#ifndef QT_NO_PRINTER #include "qprintengine_mac_p.h" #include @@ -169,3 +171,5 @@ QList > QCocoaPrinterSupport::supportedSizesWithNames(con PMRelease(printer); return returnValue; } + +#endif //QT_NO_PRINTER diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm index dc3757ce3c..40d60a6a0a 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm @@ -117,8 +117,10 @@ static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransfor QMacCGContext::QMacCGContext(QPainter *p) { QPaintEngine *pe = p->paintEngine(); +#ifndef QT_NO_PRINTER if (pe->type() == QPaintEngine::MacPrinter) pe = static_cast(pe)->paintEngine(); +#endif pe->syncState(); context = 0; if (pe->type() == QPaintEngine::CoreGraphics) diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm index 967f127b86..7180c01df4 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm +++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm @@ -39,11 +39,12 @@ ** ****************************************************************************/ -#ifndef QT_NO_PRINTDIALOG #include #include "qpagesetupdialog.h" + +#ifndef QT_NO_PRINTDIALOG #include "qpagesetupdialog_p.h" #include diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm index 37333f2593..bf1617065b 100644 --- a/src/printsupport/dialogs/qprintdialog_mac.mm +++ b/src/printsupport/dialogs/qprintdialog_mac.mm @@ -39,8 +39,6 @@ ** ****************************************************************************/ -#ifndef QT_NO_PRINTDIALOG - #include #include "qprintdialog.h" @@ -52,6 +50,8 @@ #include #include +#ifndef QT_NO_PRINTDIALOG + QT_BEGIN_NAMESPACE class QPrintDialogPrivate : public QAbstractPrintDialogPrivate -- cgit v1.2.3 From 5b70efb1258fd7435e8cfbed1a54abb46db0adcc Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 26 Sep 2013 13:37:08 +0200 Subject: Mac: QWizard default background pixmap works again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-26722 Change-Id: I579111b5d34f8e3cdc6bb016d9c0e42ec3ffb8c9 Reviewed-by: Morten Johan Sørvig Reviewed-by: Gabriel de Dietrich Reviewed-by: Stephen Chu --- .../platforms/cocoa/qcocoanativeinterface.h | 6 +++ .../platforms/cocoa/qcocoanativeinterface.mm | 26 ++++++++++++ src/widgets/dialogs/qwizard.cpp | 49 +++++++++------------- tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp | 20 ++------- 4 files changed, 56 insertions(+), 45 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 2e5e65f577..d30b281eb8 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -45,6 +45,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -91,6 +92,11 @@ private: Needed by the native print dialog in the Qt Print Support module. */ Q_INVOKABLE void *NSPrintInfoForPrintEngine(QPrintEngine *printEngine); + /* + Function to return the default background pixmap. + Needed by QWizard in the Qt widget module. + */ + Q_INVOKABLE QPixmap defaultBackgroundPixmapForQWizard(); // QMacPastebardMime support. The mac pasteboard void pointers are // QMacPastebardMime instances from the cocoa plugin or qtmacextras diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index a53a6bca46..972c171f69 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -50,6 +50,7 @@ #include #include +#include #include #include "qsurfaceformat.h" #include @@ -154,6 +155,31 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine #endif } +QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard() +{ + QCFType url; + const int ExpectedImageWidth = 242; + const int ExpectedImageHeight = 414; + if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"), + 0, 0, &url) == noErr) { + QCFType bundle = CFBundleCreate(kCFAllocatorDefault, url); + if (bundle) { + url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0); + if (url) { + QCFType imageSource = CGImageSourceCreateWithURL(url, 0); + QCFType image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); + if (image) { + int width = CGImageGetWidth(image); + int height = CGImageGetHeight(image); + if (width == ExpectedImageWidth && height == ExpectedImageHeight) + return QPixmap::fromImage(qt_mac_toQImage(image)); + } + } + } + } + return QPixmap(); +} + void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window) { Q_UNUSED(window); diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index dba3e8a97d..02d4d1ca27 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -59,9 +59,10 @@ #include "qset.h" #include "qstyle.h" #include "qvarlengtharray.h" -#if defined(Q_WS_MAC) -#include "private/qt_mac_p.h" -#include "qlibrary.h" +#if defined(Q_OS_MACX) +#include +#include +#include #elif !defined(QT_NO_STYLE_WINDOWSVISTA) #include "qwizard_win_p.h" #include "qtimer.h" @@ -604,7 +605,7 @@ public: void _q_updateButtonStates(); void _q_handleFieldObjectDestroyed(QObject *); void setStyle(QStyle *style); -#ifdef Q_WS_MAC +#ifdef Q_OS_MACX static QPixmap findDefaultBackgroundPixmap(); #endif @@ -1368,7 +1369,7 @@ bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const } break; } -#ifdef Q_WS_MAC +#ifdef Q_OS_MACX pushButton->setAutoDefault(false); #endif pushButton->hide(); @@ -1706,32 +1707,22 @@ void QWizardPrivate::setStyle(QStyle *style) it.value()->setStyle(style); } -#ifdef Q_WS_MAC +#ifdef Q_OS_MACX QPixmap QWizardPrivate::findDefaultBackgroundPixmap() { - QCFType url; - const int ExpectedImageWidth = 242; - const int ExpectedImageHeight = 414; - if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"), - 0, 0, &url) == noErr) { - QCFType bundle = CFBundleCreate(kCFAllocatorDefault, url); - if (bundle) { - url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("tif"), 0); - if (url) { - QCFType imageSource = CGImageSourceCreateWithURL(url, 0); - QCFType image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); - if (image) { - int width = CGImageGetWidth(image); - int height = CGImageGetHeight(image); - if (width == ExpectedImageWidth && height == ExpectedImageHeight) - return QPixmap::fromMacCGImageRef(image); - } - } - } - } - return QPixmap(); - + QGuiApplication *app = qobject_cast(QCoreApplication::instance()); + if (!app) + return QPixmap(); + QPlatformNativeInterface *platformNativeInterface = app->platformNativeInterface(); + int at = platformNativeInterface->metaObject()->indexOfMethod("defaultBackgroundPixmapForQWizard()"); + if (at == -1) + return QPixmap(); + QMetaMethod defaultBackgroundPixmapForQWizard = platformNativeInterface->metaObject()->method(at); + QPixmap result; + if (!defaultBackgroundPixmapForQWizard.invoke(platformNativeInterface, Q_RETURN_ARG(QPixmap, result))) + return QPixmap(); + return result; } #endif @@ -2842,7 +2833,7 @@ QPixmap QWizard::pixmap(WizardPixmap which) const { Q_D(const QWizard); Q_ASSERT(uint(which) < NPixmaps); -#ifdef Q_WS_MAC +#ifdef Q_OS_MACX if (which == BackgroundPixmap && d->defaultPixmaps[BackgroundPixmap].isNull()) d->defaultPixmaps[BackgroundPixmap] = d->findDefaultBackgroundPixmap(); #endif diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index c3fc050275..c240b5eb35 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -439,14 +439,8 @@ void tst_QWizard::setPixmap() QVERIFY(wizard.pixmap(QWizard::BannerPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull()); -#ifdef Q_OS_MAC - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_3) { - QEXPECT_FAIL("", "QTBUG-23701", Continue); - QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false); - } else { - // fall through since the image doesn't exist on a 10.3 system. - QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull()); - } +#ifdef Q_OS_MACX + QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false); #else QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull()); #endif @@ -454,14 +448,8 @@ void tst_QWizard::setPixmap() QVERIFY(page->pixmap(QWizard::BannerPixmap).isNull()); QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull()); -#ifdef Q_OS_MAC - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_3) { - QEXPECT_FAIL("", "QTBUG-23701", Continue); - QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false); - } else { - // fall through since the image doesn't exist on a 10.3 system. - QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull()); - } +#ifdef Q_OS_MACX + QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull() == false); #else QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull()); #endif -- cgit v1.2.3 From f37990712b217b4f8136d70675cb259f61548556 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 26 Sep 2013 16:22:19 +0200 Subject: [QNSView viewWillMoveToWindow:] remove observer from previous window Even if there is not a new window, the notifications from the old one are not needed. Change-Id: I9c1858d25e49379ca4737e23beec06623e91b69c Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index b8a31329fe..ab098b08bf 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -204,9 +204,9 @@ static QTouchDevice *touchDevice = 0; selector:@selector(windowNotification:) name:nil // Get all notifications object:newWindow]; - } else { - [[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:[self window]]; } + if ([self window]) + [[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:[self window]]; } - (void)updateGeometry { -- cgit v1.2.3 From c533e80e3151dcd4b48548a1244f90ad035d7385 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 17 Sep 2013 15:04:43 +0200 Subject: Doc: remove duplicate \externalpage definitions Delete all duplicate \externalpage definitions from corelib, printsupport and testlib sources. Change-Id: I7dc5358861f4dad3e8ce080619b61ca3da64ec85 Reviewed-by: Jerome Pasion --- src/corelib/doc/src/external-resources.qdoc | 20 --------------- src/printsupport/doc/src/external-resources.qdoc | 31 ------------------------ src/testlib/doc/src/qt-webpages.qdoc | 4 --- 3 files changed, 55 deletions(-) delete mode 100644 src/printsupport/doc/src/external-resources.qdoc diff --git a/src/corelib/doc/src/external-resources.qdoc b/src/corelib/doc/src/external-resources.qdoc index d1c7eb5d1b..a4f1b8723a 100644 --- a/src/corelib/doc/src/external-resources.qdoc +++ b/src/corelib/doc/src/external-resources.qdoc @@ -46,26 +46,6 @@ \title ISO 8601 */ -/*! - \externalpage http://www.ietf.org/rfc/rfc3986.txt - \title RFC 3986 -*/ - -/*! - \externalpage http://www.ietf.org/rfc/rfc1738.txt - \title RFC 1738 -*/ - -/*! - \externalpage http://www.ietf.org/rfc/rfc3941.txt - \title RFC 3491 -*/ - -/*! - \externalpage http://www.ietf.org/rfc/rfc2045.txt - \title RFC 2045 -*/ - /*! \externalpage http://www.ietf.org/rfc/rfc4648.txt \title RFC 4648 diff --git a/src/printsupport/doc/src/external-resources.qdoc b/src/printsupport/doc/src/external-resources.qdoc deleted file mode 100644 index 0a829ac761..0000000000 --- a/src/printsupport/doc/src/external-resources.qdoc +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \externalpage http://www.cups.org/ - \title Common Unix Printing System (CUPS) -*/ \ No newline at end of file diff --git a/src/testlib/doc/src/qt-webpages.qdoc b/src/testlib/doc/src/qt-webpages.qdoc index a0af232c03..e90790b7c0 100644 --- a/src/testlib/doc/src/qt-webpages.qdoc +++ b/src/testlib/doc/src/qt-webpages.qdoc @@ -32,7 +32,3 @@ \externalpage http://blog.qt.digia.com/blog/2008/12/05/qtestlib-now-with-nice-graphs-pointing-upwards/ \title qtestlib-tools Announcement */ -/*! - \externalpage http://qt.gitorious.org/qt-labs/qtestlib-tools - \title qtestlib-tools -*/ -- cgit v1.2.3 From 79fc0ff67a4f0b606d3a321914c156fc66d8fb58 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 25 Sep 2013 18:18:47 +0200 Subject: QCocoaBackingStore: Initialize non-opaque images with transparent color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In particular, this is needed when a QWidget has WA_TranslucentBackground set and nobody is painting anything behind it (except maybe some native view). Change-Id: Ib1f0714f85fa7eeced527617ecd09bb2ed6ddfc9 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 4881dcef71..665b3d4c13 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -77,6 +77,8 @@ QPaintDevice *QCocoaBackingStore::paintDevice() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; m_qImage = QImage(m_requestedSize * scaleFactor, format); m_qImage.setDevicePixelRatio(scaleFactor); + if (format == QImage::Format_ARGB32_Premultiplied) + m_qImage.fill(Qt::transparent); } return &m_qImage; } -- cgit v1.2.3 From 79561dd899e06f47b562914710d055a02b5f91fe Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 25 Sep 2013 18:21:49 +0200 Subject: QMacNativeWidget: Background should be transparent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cocoa will draw it for us. Change-Id: I73c124749658ae76c97afe95b81b78c7ff15c378 Reviewed-by: Morten Johan Sørvig --- src/widgets/widgets/qmacnativewidget_mac.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm index 1d36c389a6..66a1ed7ce7 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.mm +++ b/src/widgets/widgets/qmacnativewidget_mac.mm @@ -127,6 +127,7 @@ QMacNativeWidget::QMacNativeWidget(NSView *parentView) setPalette(QPalette(Qt::transparent)); setAttribute(Qt::WA_SetPalette, false); setAttribute(Qt::WA_LayoutUsesWidgetRect); + setAttribute(Qt::WA_TranslucentBackground); } /*! -- cgit v1.2.3 From db9abc72ef6e374257e00c9553104584b973458a Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Sep 2013 20:00:41 +0200 Subject: QMacNativeWidget: Have example use a delegate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This would be the case in most if not all the real life use cases. Change-Id: Ib7ebc6dbe471ce50f4bd1df9becba8e9806008e7 Reviewed-by: Morten Johan Sørvig --- examples/widgets/mac/qmacnativewidget/main.mm | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/examples/widgets/mac/qmacnativewidget/main.mm b/examples/widgets/mac/qmacnativewidget/main.mm index 28cf2adc3b..4558143b75 100644 --- a/examples/widgets/mac/qmacnativewidget/main.mm +++ b/examples/widgets/mac/qmacnativewidget/main.mm @@ -79,12 +79,14 @@ char **qtArgv; QApplication *qtApp = 0; } -@interface WindowCreator : NSObject {} -- (void)createWindow; +@interface WindowCreator : NSObject @end @implementation WindowCreator -- (void)createWindow { + +- (void)applicationDidFinishLaunching:(NSNotification *)notification +{ + Q_UNUSED(notification) // Qt widgets rely on a QApplication being alive somewhere qtApp = new QApplication(qtArgc, qtArgv); @@ -120,18 +122,25 @@ QApplication *qtApp = 0; // Show the NSWindow [window makeKeyAndOrderFront:NSApp]; } + +- (void)applicationWillTerminate:(NSNotification *)notification +{ + Q_UNUSED(notification) + + delete qtApp; +} + @end int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + Q_UNUSED(pool); - // Normally, we would use the application delegate. - // We resort to the notification mechanism for conciseness. + // Normally, we would use let the main bundle instanciate and set + // the application delegate, but we set it manually for conciseness. WindowCreator *windowCreator= [WindowCreator alloc]; - [[NSNotificationCenter defaultCenter] - addObserver:windowCreator selector:@selector(createWindow) - name:NSApplicationDidFinishLaunchingNotification object:nil]; + [[NSApplication sharedApplication] setDelegate:windowCreator]; // Save these for QApplication qtArgc = argc; -- cgit v1.2.3 From 06e7d61b688778c47d2a29093384801ce6c9d55e Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Sep 2013 19:40:44 +0200 Subject: Cocoa: Allow widgets to receive events event when no app is running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is necessary for QMacNativeWidget, where there exists a QApplication, but is never executed. This directly translates in calls to the event dispatcher's processEvents() function, whose calls we keep track. If no calls have been made, we always allow timer and posted events to be processed. Change-Id: Ia0062ee8c59a2572082f520a2eb85ed44a9856a7 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaeventdispatcher.h | 1 + src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h index 93476ee1b4..33d7dcbcf4 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h @@ -165,6 +165,7 @@ public: bool currentExecIsNSAppRun; bool nsAppRunCalledByQt; bool cleanupModalSessionsNeeded; + uint processEventsCalled; NSModalSession currentModalSessionCached; NSModalSession currentModalSession(); void updateChildrenWorksWhenModal(); diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 8dfaacdf13..ee69cd7d86 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -118,7 +118,7 @@ static Boolean runLoopSourceEqualCallback(const void *info1, const void *info2) void QCocoaEventDispatcherPrivate::runLoopTimerCallback(CFRunLoopTimerRef, void *info) { QCocoaEventDispatcherPrivate *d = static_cast(info); - if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { + if (d->processEventsCalled && (d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { // processEvents() was called "manually," ignore this source for now d->maybeCancelWaitForMoreEvents(); return; @@ -364,6 +364,12 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) uint oldflags = d->processEventsFlags; d->processEventsFlags = flags; + + // Used to determine whether any eventloop has been exec'ed, and allow posted + // and timer events to be processed even if this function has never been called + // instead of being kept on hold for the next run of processEvents(). + ++d->processEventsCalled; + bool excludeUserEvents = d->processEventsFlags & QEventLoop::ExcludeUserInputEvents; bool retVal = false; forever { @@ -517,6 +523,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) } d->processEventsFlags = oldflags; + --d->processEventsCalled; // If we're interrupted, we need to interrupt the _current_ // recursion as well to check if it is still supposed to be @@ -770,6 +777,7 @@ QCocoaEventDispatcherPrivate::QCocoaEventDispatcherPrivate() currentExecIsNSAppRun(false), nsAppRunCalledByQt(false), cleanupModalSessionsNeeded(false), + processEventsCalled(0), currentModalSessionCached(0), lastSerial(-1), interrupt(false) @@ -893,7 +901,7 @@ void QCocoaEventDispatcherPrivate::firstLoopEntry(CFRunLoopObserverRef ref, void QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void *info) { QCocoaEventDispatcherPrivate *d = static_cast(info); - if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { + if (d->processEventsCalled && (d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { // processEvents() was called "manually," ignore this source for now d->maybeCancelWaitForMoreEvents(); return; -- cgit v1.2.3 From 00da2e615e89c46affbc130b4df6148785724a23 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 25 Sep 2013 22:19:33 +0200 Subject: rcc: Remove compile dependency on private headers. Not needed anymore now that it's using the new commandline parser. Change-Id: I1a44c8658d128e4fbb9a6fc5000025f55e5293c2 Reviewed-by: Marc Mutz --- src/tools/rcc/main.cpp | 1 - src/tools/rcc/rcc.pro | 1 - 2 files changed, 2 deletions(-) diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 510a552c12..972c59ef2e 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include -#include "../../corelib/kernel/qcorecmdlineargs_p.h" #include #include diff --git a/src/tools/rcc/rcc.pro b/src/tools/rcc/rcc.pro index 354747db01..de3cc90e1b 100644 --- a/src/tools/rcc/rcc.pro +++ b/src/tools/rcc/rcc.pro @@ -4,7 +4,6 @@ CONFIG += force_bootstrap DEFINES += QT_RCC QT_NO_CAST_FROM_ASCII include(rcc.pri) -HEADERS += ../../corelib/kernel/qcorecmdlineargs_p.h SOURCES += main.cpp load(qt_tool) -- cgit v1.2.3