From eecc9d287c6d9db62b24ee2c80eb994a5552e41f Mon Sep 17 00:00:00 2001 From: Stanislav Ionascu Date: Tue, 5 Jul 2011 12:48:11 +0200 Subject: Fixes switching runtime graphics system when the maximized window is shown or hidden. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 1287 Reviewed-by: Samuel Rødal --- src/plugins/graphicssystems/meego/qmeegographicssystem.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index 6268d4b..a034b0e 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -174,6 +174,14 @@ bool QMeeGoGraphicsSystemSwitchHandler::eventFilter(QObject *object, QEvent *eve QMeeGoGraphicsSystem::switchToMeeGo(); } } + } else if (event->type() == QEvent::Show + && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch) { + if (visibleWidgets() > 0) + QMeeGoGraphicsSystem::switchToMeeGo(); + } else if (event->type() == QEvent::Hide + && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch) { + if (visibleWidgets() == 0) + QMeeGoGraphicsSystem::switchToRaster(); } // resume processing of event -- cgit v0.12 From d9bdaeff3b25ae72fe766bf54a4f76f23d97705b Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 5 Jul 2011 16:14:01 +0300 Subject: Support partial input mode Connect the internal private API to the QApplication public attribute. This allows the enabling/disabling of the splitview functionality from apps without any hacks. Task-number: QTBUG-16572 Reviewed-by: Tomi Vihria --- src/gui/inputmethod/qcoefepinputcontext_p.h | 1 + src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 16 ++++++++++++---- src/gui/kernel/qapplication.cpp | 4 ++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index e929880..9fd2703 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -108,6 +108,7 @@ private: bool needsInputPanel(); void commitTemporaryPreeditString(); bool isWidgetVisible(QWidget *widget, int offset = 0); + bool isPartialKeyboardSupported(); private Q_SLOTS: void ensureInputCapabilitiesChanged(); diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 602c734..567f83b 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -83,6 +83,8 @@ Q_GUI_EXPORT void qt_s60_setPartialScreenInputMode(bool enable) { S60->partial_keyboard = enable; + QApplication::setAttribute(Qt::AA_S60DisablePartialScreenInputMode, !S60->partial_keyboard); + QInputContext *ic = 0; if (QApplication::focusWidget()) { ic = QApplication::focusWidget()->inputContext(); @@ -111,7 +113,7 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_fepState->SetObjectProvider(this); int defaultFlags = EAknEditorFlagDefault; if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) { - if (S60->partial_keyboard) { + if (isPartialKeyboardSupported()) { defaultFlags |= QT_EAknEditorFlagEnablePartialScreen; } defaultFlags |= QT_EAknEditorFlagSelectionVisible; @@ -420,7 +422,8 @@ void QCoeFepInputContext::mouseHandler(int x, QMouseEvent *event) //If splitview is open and T9 word is tapped, pass the pointer event to pointer handler. //This will open the "suggested words" list. Pass pointer position always as zero, to make //full word replacement in case user makes a selection. - if (S60->partial_keyboard && S60->partialKeyboardOpen + if (isPartialKeyboardSupported() + && S60->partialKeyboardOpen && m_pointerHandler && !(currentHints & Qt::ImhNoPredictiveText) && (x > 0 && x < m_preeditString.length())) { @@ -534,6 +537,11 @@ bool QCoeFepInputContext::isWidgetVisible(QWidget *widget, int offset) return visible; } +bool QCoeFepInputContext::isPartialKeyboardSupported() +{ + return (S60->partial_keyboard || !QApplication::testAttribute(Qt::AA_S60DisablePartialScreenInputMode)); +} + // Ensure that the input widget is visible in the splitview rect. void QCoeFepInputContext::ensureFocusWidgetVisible(QWidget *widget) @@ -644,7 +652,7 @@ void QCoeFepInputContext::updateHints(bool mustUpdateInputCapabilities) // we need to update its state separately. if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) { TInt currentFlags = m_fepState->Flags(); - if (S60->partial_keyboard) + if (isPartialKeyboardSupported()) currentFlags |= QT_EAknEditorFlagEnablePartialScreen; else currentFlags &= ~QT_EAknEditorFlagEnablePartialScreen; @@ -761,7 +769,7 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) flags = 0; if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) { - if (S60->partial_keyboard) + if (isPartialKeyboardSupported()) flags |= QT_EAknEditorFlagEnablePartialScreen; flags |= QT_EAknEditorFlagSelectionVisible; } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4552255..34ce9a8 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -1017,6 +1017,10 @@ void QApplicationPrivate::initialize() QApplicationPrivate::wheel_scroll_lines = 3; #endif +#ifdef Q_WS_S60 + q->setAttribute(Qt::AA_S60DisablePartialScreenInputMode); +#endif + if (qt_is_gui_used) initializeMultitouch(); } -- cgit v0.12 From be63b3e85c50e56b18d0f0bf93ad3b1c74049117 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 5 Jul 2011 15:53:57 +0200 Subject: Add a null check for the backend in QNetworkReplyImpl. This is a blurry attempt to fix a crash happening during bearer session loss/recovery. Reviewed-by: Markus Goetz --- src/network/access/qnetworkreplyimpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 574b6e9..8a0a944 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -924,7 +924,7 @@ bool QNetworkReplyImplPrivate::migrateBackend() return true; // Backend does not support resuming download. - if (!backend->canResume()) + if (backend && !backend->canResume()) return false; state = QNetworkReplyImplPrivate::Reconnecting; -- cgit v0.12 From ca0b81567d76d3af82ce025e029fb5efa50846ed Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 5 Jul 2011 17:13:04 +0300 Subject: Support partial input mode - documentation update Update the documentation related to the QApplication attribute. Task-number: QTBUG-16572 Reviewed-by: Tomi Vihria --- src/corelib/global/qnamespace.qdoc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 87b8255..eabaf10 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -156,12 +156,16 @@ whole lifetime. This attribute must be set before QApplication is constructed. - \omitvalue AA_S60DisablePartialScreenInputMode By default in Symbian^3, - a separate editing window is opened on top of an application. This is exactly - like editing on previous versions of Symbian behave. When this attribute - is true, a virtual keyboard window is shown on top of application and it - is ensured that the focused text widget is visible. This is only supported in - Symbian^3. (internal) + \value AA_S60DisablePartialScreenInputMode By default in Symbian^3, a separate + editing window is opened on top of an application. This is exactly like + editing on previous versions of Symbian behave. When this attribute is false, + a non-fullscreen virtual keyboard window is shown on top of application and + it is ensured that the focused text input widget is visible. + The auto-translation of input widget is only supported for applications + based on QGraphicsView, but the non-fullscreen virtual keyboard will + work for any kind of application (i.e. QWidgets-based). By default this + attribute is true. This attribute must be set after QApplication is + constructed. This is only supported in Symbian^3 and later Symbian releases. \omitvalue AA_AttributeCount */ -- cgit v0.12 From b487fb1cc1a3be4a197ec458fc3b575d7b57d6a5 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 5 Jul 2011 16:21:50 +0200 Subject: HTTP internals: do not discard data if not receiving gzip end marker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit some servers send gzip data without the gzip end markers. In that case, we should deliver all content and tear down the gzip data structures. Reviewed-by: Markus Goetz Patch-by: Tor Arne Vestbø and Peter Hartmann Task-number: QTBUG-16022 --- src/network/access/qhttpnetworkconnectionchannel.cpp | 7 +++++-- src/network/access/qhttpnetworkreply.cpp | 10 ++++++++-- src/network/access/qhttpnetworkreply_p.h | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 63f923f..7c2e2a1 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -599,8 +599,11 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete) int ret = Z_OK; if (content.size()) ret = reply->d_func()->gunzipBodyPartially(content, inflated); - int retCheck = (dataComplete) ? Z_STREAM_END : Z_OK; - if (ret >= retCheck) { + if (ret >= Z_OK) { + if (dataComplete && ret == Z_OK && !reply->d_func()->streamEnd) { + reply->d_func()->gunzipBodyPartiallyEnd(); + reply->d_func()->streamEnd = true; + } if (inflated.size()) { reply->d_func()->totalProgress += inflated.size(); reply->d_func()->appendUncompressedReplyData(inflated); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 516841a..01360d5 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -434,12 +434,18 @@ int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteA } while (inflateStrm.avail_out == 0); // clean up and return if (ret <= Z_ERRNO || ret == Z_STREAM_END) { - inflateEnd(&inflateStrm); - initInflate = false; + gunzipBodyPartiallyEnd(); } streamEnd = (ret == Z_STREAM_END); return ret; } + +void QHttpNetworkReplyPrivate::gunzipBodyPartiallyEnd() +{ + inflateEnd(&inflateStrm); + initInflate = false; +} + #endif qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket) diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 05feaa9..365308f 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -200,6 +200,7 @@ public: #ifndef QT_NO_COMPRESS bool gzipCheckHeader(QByteArray &content, int &pos); int gunzipBodyPartially(QByteArray &compressed, QByteArray &inflated); + void gunzipBodyPartiallyEnd(); #endif void removeAutoDecompressHeader(); -- cgit v0.12 From cc504be6500911d9109f513a60c8116cacb39fe4 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 5 Jul 2011 17:32:54 +0200 Subject: HTTP internals: continue gzip decompression if buffer fills exactly Reviewed-by: Markus Goetz Reviewed-by: Prasanth Ullattil Task-number: QTBUG-12908 --- src/network/access/qhttpnetworkreply.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 01360d5..0f2fcba 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -431,7 +431,7 @@ int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteA } have = sizeof(out) - inflateStrm.avail_out; inflated.append(QByteArray((const char *)out, have)); - } while (inflateStrm.avail_out == 0); + } while (inflateStrm.avail_out == 0 && inflateStrm.avail_in > 0); // clean up and return if (ret <= Z_ERRNO || ret == Z_STREAM_END) { gunzipBodyPartiallyEnd(); -- cgit v0.12 From db1c29aaed0730db38f19dfb376fd2c03d08c04e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Jul 2011 14:06:01 +0200 Subject: Fix QScopedPointerarray default constructor Since the compiler cannod find the template argument if there is no argument passed to the constructor, this effectively means there is no default constructor. Add a default constructor Task-number: QTBUG-20256 Change-Id: I310d5e1f3f94a8fe69fd3a5c46f2f51bca60facd Reviewed-on: http://codereview.qt.nokia.com/1165 Reviewed-by: Qt Sanity Bot Reviewed-by: Denis Dzyubenko (cherry picked from commit d789e40c58c1ce8441d3bb4d6ca8d01fe02ad1a7) --- src/corelib/tools/qscopedpointer.h | 4 +++- tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index b15bcac..a24f62e 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -208,8 +208,10 @@ template > class QScopedArrayPointer : public QScopedPointer { public: + inline QScopedArrayPointer() : QScopedPointer(0) {} + template - explicit inline QScopedArrayPointer(D *p = 0, typename QtPrivate::QScopedArrayEnsureSameType::Type = 0) + explicit inline QScopedArrayPointer(D *p, typename QtPrivate::QScopedArrayEnsureSameType::Type = 0) : QScopedPointer(p) { } diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index 1a6f944..06c0ecb 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -72,6 +72,7 @@ private Q_SLOTS: void isNullSignature(); void objectSize(); void comparison(); + void array(); // TODO instanciate on const object }; @@ -437,5 +438,26 @@ void tst_QScopedPointer::comparison() QCOMPARE( int(RefCounted::instanceCount), 0 ); } +void tst_QScopedPointer::array() +{ + int instCount = RefCounted::instanceCount; + { + QScopedArrayPointer array; + array.reset(new RefCounted[42]); + QCOMPARE(instCount + 42, int(RefCounted::instanceCount)); + } + QCOMPARE(instCount, int(RefCounted::instanceCount)); + { + QScopedArrayPointer array(new RefCounted[42]); + QCOMPARE(instCount + 42, int(RefCounted::instanceCount)); + array.reset(new RefCounted[28]); + QCOMPARE(instCount + 28, int(RefCounted::instanceCount)); + array.reset(0); + QCOMPARE(instCount, int(RefCounted::instanceCount)); + } + QCOMPARE(instCount, int(RefCounted::instanceCount)); +} + + QTEST_MAIN(tst_QScopedPointer) #include "tst_qscopedpointer.moc" -- cgit v0.12 From de85cf25be61c746b1a47a58873b5758d8e8ad5d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 6 Jul 2011 16:37:14 +0200 Subject: Use Q_DECL_CONSTEXPR in QFlags Change-Id: I851e0b1c3f80a7b33a38cb1ab2665dc0f3c73adc Reviewed-on: http://codereview.qt.nokia.com/1248 Reviewed-by: Qt Sanity Bot Reviewed-by: Gabriel de Dietrich (cherry picked from commit c0c6dd2b022cfd667f32b8a48bcac86ac07d3880) --- src/corelib/global/qglobal.h | 30 +++++++++++++++--------------- tests/auto/qflags/tst_qflags.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1f5f537..892ae73 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2267,9 +2267,9 @@ class QFlags int i; public: typedef Enum enum_type; - inline QFlags(const QFlags &f) : i(f.i) {} - inline QFlags(Enum f) : i(f) {} - inline QFlags(Zero = 0) : i(0) {} + Q_DECL_CONSTEXPR inline QFlags(const QFlags &f) : i(f.i) {} + Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {} + Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {} inline QFlags(QFlag f) : i(f) {} inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; } @@ -2280,18 +2280,18 @@ public: inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; } inline QFlags &operator^=(Enum f) { i ^= f; return *this; } - inline operator int() const { return i; } + Q_DECL_CONSTEXPR inline operator int() const { return i; } - inline QFlags operator|(QFlags f) const { QFlags g; g.i = i | f.i; return g; } - inline QFlags operator|(Enum f) const { QFlags g; g.i = i | f; return g; } - inline QFlags operator^(QFlags f) const { QFlags g; g.i = i ^ f.i; return g; } - inline QFlags operator^(Enum f) const { QFlags g; g.i = i ^ f; return g; } - inline QFlags operator&(int mask) const { QFlags g; g.i = i & mask; return g; } - inline QFlags operator&(uint mask) const { QFlags g; g.i = i & mask; return g; } - inline QFlags operator&(Enum f) const { QFlags g; g.i = i & f; return g; } - inline QFlags operator~() const { QFlags g; g.i = ~i; return g; } + Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); } + Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); } + Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); } + Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); } + Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); } + Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); } + Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); } + Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); } - inline bool operator!() const { return !i; } + Q_DECL_CONSTEXPR inline bool operator!() const { return !i; } inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); } }; @@ -2304,9 +2304,9 @@ inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \ { return QIncompatibleFlag(int(f1) | f2); } #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \ -inline QFlags operator|(Flags::enum_type f1, Flags::enum_type f2) \ +Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, Flags::enum_type f2) \ { return QFlags(f1) | f2; } \ -inline QFlags operator|(Flags::enum_type f1, QFlags f2) \ +Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, QFlags f2) \ { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) diff --git a/tests/auto/qflags/tst_qflags.cpp b/tests/auto/qflags/tst_qflags.cpp index 87025b6..85e64a6 100644 --- a/tests/auto/qflags/tst_qflags.cpp +++ b/tests/auto/qflags/tst_qflags.cpp @@ -47,6 +47,7 @@ private slots: void testFlag() const; void testFlagZeroFlag() const; void testFlagMultiBits() const; + void constExpr(); }; void tst_QFlags::testFlag() const @@ -96,5 +97,32 @@ void tst_QFlags::testFlagMultiBits() const } } +template bool verifyConstExpr(T n) { return n == N; } + +void tst_QFlags::constExpr() +{ +#ifdef Q_COMPILER_CONSTEXPR + Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; + switch (btn) { + case Qt::LeftButton: QVERIFY(false); break; + case Qt::RightButton: QVERIFY(false); break; + case Qt::LeftButton | Qt::RightButton: QVERIFY(true); break; + default: QVERIFY(false); + } + + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::LeftButton>(Qt::LeftButton)); + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::MiddleButton>(0)); + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) | Qt::MiddleButton>(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton)); + QVERIFY(verifyConstExpr<~(Qt::LeftButton | Qt::RightButton)>(~(Qt::LeftButton | Qt::RightButton))); + QVERIFY(verifyConstExpr(Qt::LeftButton ^ Qt::RightButton)); + QVERIFY(verifyConstExpr(0)); + QVERIFY(verifyConstExpr(Qt::RightButton)); + QVERIFY(verifyConstExpr(0xff)); + + QVERIFY(!verifyConstExpr(!Qt::MouseButtons(Qt::LeftButton))); +#endif +} + + QTEST_MAIN(tst_QFlags) #include "tst_qflags.moc" -- cgit v0.12 From f650c43d130d28fa7eca2f6accf8aacd76ae508d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 6 Jul 2011 16:35:04 +0200 Subject: Add Q_DECL_CONSTEXPR Defined to the c++0x constexpr when compiler supports it Change-Id: I82687fe46848eedf3cffc39982106749b3dde8aa Reviewed-on: http://codereview.qt.nokia.com/1247 Reviewed-by: Qt Sanity Bot Reviewed-by: Gabriel de Dietrich (cherry picked from commit 28f927f8e092a02e233559f6da7fa96cf722c77d) --- src/corelib/global/qglobal.h | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 892ae73..9c7f1c6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -536,6 +536,11 @@ namespace QT_NAMESPACE {} # define Q_COMPILER_LAMBDA # define Q_COMPILER_UNICODE_STRINGS # endif +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 + /* C++0x features supported in GCC 4.6: */ +# define Q_COMPILER_CONSTEXPR +# endif + # endif /* IBM compiler versions are a bit messy. There are actually two products: @@ -1135,6 +1140,12 @@ redefine to built-in booleans to make autotests work properly */ # define QT_FASTCALL #endif +#ifdef Q_COMPILER_CONSTEXPR +# define Q_DECL_CONSTEXPR constexpr +#else +# define Q_DECL_CONSTEXPR +#endif + //defines the type for the WNDPROC on windows //the alignment needs to be forced for sse2 to not crash with mingw #if defined(Q_WS_WIN) @@ -1166,25 +1177,25 @@ typedef double qreal; */ template -inline T qAbs(const T &t) { return t >= 0 ? t : -t; } +Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; } -inline int qRound(qreal d) +Q_DECL_CONSTEXPR inline int qRound(qreal d) { return d >= qreal(0.0) ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1); } #if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) -inline qint64 qRound64(double d) +Q_DECL_CONSTEXPR inline qint64 qRound64(double d) { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); } #else -inline qint64 qRound64(qreal d) +Q_DECL_CONSTEXPR inline qint64 qRound64(qreal d) { return d >= qreal(0.0) ? qint64(d + qreal(0.5)) : qint64(d - qreal(qint64(d-1)) + qreal(0.5)) + qint64(d-1); } #endif template -inline const T &qMin(const T &a, const T &b) { if (a < b) return a; return b; } +Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; } template -inline const T &qMax(const T &a, const T &b) { if (a < b) return b; return a; } +Q_DECL_CONSTEXPR inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; } template -inline const T &qBound(const T &min, const T &val, const T &max) +Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max) { return qMax(min, qMin(max, val)); } #ifdef QT3_SUPPORT @@ -1978,12 +1989,12 @@ inline bool operator!=(QBool b1, bool b2) { return !b1 != !b2; } inline bool operator!=(bool b1, QBool b2) { return !b1 != !b2; } inline bool operator!=(QBool b1, QBool b2) { return !b1 != !b2; } -static inline bool qFuzzyCompare(double p1, double p2) +Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2))); } -static inline bool qFuzzyCompare(float p1, float p2) +Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) { return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2))); } @@ -1991,7 +2002,7 @@ static inline bool qFuzzyCompare(float p1, float p2) /*! \internal */ -static inline bool qFuzzyIsNull(double d) +Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) { return qAbs(d) <= 0.000000000001; } @@ -1999,7 +2010,7 @@ static inline bool qFuzzyIsNull(double d) /*! \internal */ -static inline bool qFuzzyIsNull(float f) +Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) { return qAbs(f) <= 0.00001f; } -- cgit v0.12 From 999047177846695a809aa1a730330ce676d85959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Fri, 3 Jun 2011 17:55:09 +0200 Subject: Fix QProcess emitting two started signals on X11 On X11 QProcess would emit two started signals when calling QProcess::waitForStarted(). We should expect that the private implementation of waitForStarted() should emit the started signal and return true or false appropriately. Task-number: QTBUG-7039 Change-Id: I3d381399ab7a39bf57db03a110fa6747a4fc6a24 Reviewed-on: http://codereview.qt.nokia.com/331 Reviewed-by: Thiago Macieira (cherry picked from commit 883b120d2f39c532cdd1a98d962af83be5adc4bd) --- src/corelib/io/qprocess.cpp | 11 ++++------- tests/auto/qprocess/tst_qprocess.cpp | 28 ++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 4b689c5..e900663 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1683,13 +1683,10 @@ QProcessEnvironment QProcess::processEnvironment() const bool QProcess::waitForStarted(int msecs) { Q_D(QProcess); - if (d->processState == QProcess::Starting) { - if (!d->waitForStarted(msecs)) - return false; - setProcessState(QProcess::Running); - emit started(); - } - return d->processState == QProcess::Running; + if (d->processState == QProcess::Running) + return true; + + return d->waitForStarted(msecs); } /*! \reimp diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index 91e0abe..f54dfa3 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -73,7 +73,7 @@ Q_DECLARE_METATYPE(QProcess::ProcessState); { \ const bool ret = Process.Fn; \ if (ret == false) \ - qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \ + qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \ QVERIFY(ret); \ } @@ -157,6 +157,7 @@ private slots: void startFinishStartFinish(); void invalidProgramString_data(); void invalidProgramString(); + void onlyOneStartedSignal(); // keep these at the end, since they use lots of processes and sometimes // caused obscure failures to occur in tests that followed them (esp. on the Mac) @@ -2089,7 +2090,7 @@ void tst_QProcess::setStandardInputFile() #endif QPROCESS_VERIFY(process, waitForFinished()); - QByteArray all = process.readAll(); + QByteArray all = process.readAll(); QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0 QVERIFY(all == data); } @@ -2442,6 +2443,29 @@ void tst_QProcess::invalidProgramString() QVERIFY(!QProcess::startDetached(programString)); } +//----------------------------------------------------------------------------- +void tst_QProcess::onlyOneStartedSignal() +{ + QProcess process; + + QSignalSpy spyStarted(&process, SIGNAL(started())); + QSignalSpy spyFinished(&process, SIGNAL(finished(int, QProcess::ExitStatus))); + + process.start("testProcessNormal/testProcessNormal"); + QVERIFY(process.waitForStarted(5000)); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(spyStarted.count(), 1); + QCOMPARE(spyFinished.count(), 1); + + spyStarted.clear(); + spyFinished.clear(); + + process.start("testProcessNormal/testProcessNormal"); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(spyStarted.count(), 1); + QCOMPARE(spyFinished.count(), 1); +} + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" #endif -- cgit v0.12