From 101a63a6fd53e00eaa7e7a56d1ece33327a19bf8 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Fri, 10 Sep 2010 10:07:39 +0200 Subject: Revert "Doc: fixing page name bug caused by 07bbace404078dcfd82eff717daa97299b8ba52c changing qml elements page" Doc: pulling back redundant fix that is breaking links - qmlelements.html/declarativeelements.html This reverts commit 064b7fe6f97bcf214f749794c5ccab3b4cf0bcc7. --- doc/src/index.qdoc | 2 +- tools/qdoc3/test/qt-html-templates.qdocconf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index edb4d1e..77856ec 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -77,7 +77,7 @@ diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index dc56ac9..1203357 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -89,7 +89,7 @@ HTML.postheader = "
\n" \ "
  • Modules
  • \n" \ "
  • Namespaces
  • \n" \ "
  • Global Declarations
  • \n" \ - "
  • QML elements
  • \n" \ + "
  • QML elements
  • \n" \ " \n" \ "
    \n" \ " \n" \ -- cgit v0.12 From 0b0aa7603b27447a5abe55c55d0514bc56b35f9e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Sep 2010 10:10:30 +0200 Subject: Properly implement qobject_cast for const pointers. Instead of using ugly const_cast in public headers and Q_UNUSED (which expands to nothing in release builds), use a properly-const method. Reviewed-By: Bradley T. Hughes --- src/corelib/kernel/qmetaobject.cpp | 20 +++++++++++++++++++- src/corelib/kernel/qobject.h | 6 +----- src/corelib/kernel/qobjectdefs.h | 1 + 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 9854e68..3b9b04a 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -266,7 +266,25 @@ QObject *QMetaObject::cast(QObject *obj) const const QMetaObject *m = obj->metaObject(); do { if (m == this) - return const_cast(obj); + return obj; + } while ((m = m->d.superdata)); + } + return 0; +} + +/*! + \internal + + Returns \a obj if object \a obj inherits from this + meta-object; otherwise returns 0. +*/ +const QObject *QMetaObject::cast(const QObject *obj) const +{ + if (obj) { + const QMetaObject *m = obj->metaObject(); + do { + if (m == this) + return obj; } while ((m = m->d.superdata)); } return 0; diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 1b613a6..c533fa1 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -458,14 +458,10 @@ inline T qobject_cast(QObject *object) template inline T qobject_cast(const QObject *object) { - // this will cause a compilation error if T is not const - register T ptr = static_cast(object); - Q_UNUSED(ptr); - #if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(const_cast(object))); #endif - return static_cast(const_cast(reinterpret_cast(0)->staticMetaObject.cast(const_cast(object)))); + return static_cast(reinterpret_cast(0)->staticMetaObject.cast(object)); } diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 555a1f5..0d045dc 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -298,6 +298,7 @@ struct Q_CORE_EXPORT QMetaObject const QMetaObject *superClass() const; QObject *cast(QObject *obj) const; + const QObject *cast(const QObject *obj) const; #ifndef QT_NO_TRANSLATION // ### Qt 4: Merge overloads -- cgit v0.12 From 16aeed255560b5e9479efe9b74517fb647922694 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 9 Sep 2010 10:51:23 +0200 Subject: Remove unsupported code from qobject.h for MSVC < .NET 2003 Reviewed-By: Joerg Bornemann --- src/corelib/kernel/qobject.h | 91 -------------------------------------------- 1 file changed, 91 deletions(-) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index c533fa1..b5c772e 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -325,95 +325,6 @@ Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString const QMetaObject &mo, QList *list); Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo); -#if defined Q_CC_MSVC && _MSC_VER < 1300 - -template -inline T qFindChild(const QObject *o, const QString &name, T) -{ return static_cast(qt_qFindChild_helper(o, name, ((T)0)->staticMetaObject)); } - -template -inline QList qFindChildren(const QObject *o, const QString &name, T) -{ - QList list; - union { - QList *typedList; - QList *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, name, 0, ((T)0)->staticMetaObject, u.voidList); - return list; -} - -template -inline T qFindChild(const QObject *o, const QString &name) -{ return qFindChild(o, name, T(0)); } - -template -inline T qFindChild(const QObject *o) -{ return qFindChild(o, QString(), T(0)); } - -template -inline QList qFindChildren(const QObject *o, const QString &name) -{ return qFindChildren(o, name, T(0)); } - -template -inline QList qFindChildren(const QObject *o) -{ return qFindChildren(o, QString(), T(0)); } - -#ifndef QT_NO_REGEXP -template -inline QList qFindChildren(const QObject *o, const QRegExp &re, T) -{ - QList list; - union { - QList *typedList; - QList *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, 0, &re, ((T)0)->staticMetaObject, u.voidList); - return list; -} - -template -inline QList qFindChildren(const QObject *o, const QRegExp &re) -{ return qFindChildren(o, re, T(0)); } - -#endif - -#ifdef Q_MOC_RUN -# define Q_DECLARE_INTERFACE(IFace, IId) Q_DECLARE_INTERFACE(IFace, IId) -#endif // Q_MOC_RUN - - -template inline const char * qobject_interface_iid() -{ return 0; } - -template inline T qobject_cast_helper(QObject *object, T) -{ return static_cast(((T)0)->staticMetaObject.cast(object)); } - -template inline T qobject_cast_helper(const QObject *object, T) -{ return static_cast(const_cast(((T)0)->staticMetaObject.cast(const_cast(object)))); } - -template -inline T qobject_cast(QObject *object) -{ return qobject_cast_helper(object, T(0)); } - -template -inline T qobject_cast(const QObject *object) -{ return qobject_cast_helper(object, T(0)); } - -#ifndef Q_MOC_RUN -# define Q_DECLARE_INTERFACE(IFace, IId) \ - template <> inline const char *qobject_interface_iid() \ - { return IId; } \ - template <> inline IFace *qobject_cast_helper(QObject *object, IFace *) \ - { return (IFace *)(object ? object->qt_metacast(IId) : 0); } \ - template <> inline IFace *qobject_cast_helper(const QObject *object, IFace *) \ - { return (IFace *)(object ? const_cast(object)->qt_metacast(IId) : 0); } -#endif // Q_MOC_RUN - -#else - template inline T qFindChild(const QObject *o, const QString &name) { return static_cast(qt_qFindChild_helper(o, name, reinterpret_cast(0)->staticMetaObject)); } @@ -478,8 +389,6 @@ template inline const char * qobject_interface_iid() { return reinterpret_cast((object ? const_cast(object)->qt_metacast(IId) : 0)); } #endif // Q_MOC_RUN -#endif - #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *); #endif -- cgit v0.12 From ecac806359a092e2e09adb027e5a45d2cd993a9f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 7 Sep 2010 19:00:10 +0200 Subject: Update the error handling of invalid hostnames in QUrl. This should let QUrl::errorString() show the original, invalid hostname in the URL it reports to be invalid. There may be a side-effect that QUrl::toEncoded() may include the broken hostname on the first call, then miss it in the next calls. But since QUrl::isValid() is returning false, we can consider that the result of toEncoded() is undefined, so anything goes. Reviewed-by: Olivier Goffart --- src/corelib/io/qurl.cpp | 25 +++++++++++++++++++------ tests/auto/qurl/tst_qurl.cpp | 10 ++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 74c24b5..d1fab2d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3417,9 +3417,8 @@ QString QUrlPrivate::canonicalHost() const that->host = host.toLower(); } else { that->host = qt_ACE_do(host, NormalizeAce); - if (that->host.isNull()) - that->isHostValid = false; } + that->isHostValid = !that->host.isNull(); return that->host; } @@ -3734,6 +3733,10 @@ void QUrlPrivate::validate() const QString auth = authority(); // causes the non-encoded forms to be valid + // authority() calls canonicalHost() which sets this + if (!isHostValid) + return; + if (scheme == QLatin1String("mailto")) { if (!host.isEmpty() || port != -1 || !userName.isEmpty() || !password.isEmpty()) { that->isValid = false; @@ -3907,9 +3910,10 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const url += scheme.toLatin1(); url += ':'; } + QString savedHost = host; // pre-validation, may be invalid! QString auth = authority(); bool doFileScheme = scheme == QLatin1String("file") && encodedPath.startsWith('/'); - if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority && (!auth.isEmpty() || doFileScheme)) { + if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority && (!auth.isEmpty() || doFileScheme || !savedHost.isEmpty())) { if (doFileScheme && !encodedPath.startsWith('/')) url += '/'; url += "//"; @@ -3935,6 +3939,12 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const url += '['; url += host.toLatin1(); url += ']'; + } else if (host.isEmpty() && !savedHost.isEmpty()) { + // this case is only possible with an invalid URL + // it's here only so that we can keep the original, invalid hostname + // in encodedOriginal. + // QUrl::isValid() will return false, so toEncoded() can be anything (it's not valid) + url += savedHost.toUtf8(); } else { url += QUrl::toAce(host); } @@ -4054,7 +4064,7 @@ const QByteArray &QUrlPrivate::normalized() const QString QUrlPrivate::createErrorString() { - if (isValid) + if (isValid && isHostValid) return QString(); QString errorString(QLatin1String(QT_TRANSLATE_NOOP(QUrl, "Invalid URL \""))); @@ -4078,7 +4088,10 @@ QString QUrlPrivate::createErrorString() errorString += QLatin1String(QT_TRANSLATE_NOOP(QUrl, "\'")); } else { errorString += QLatin1String(QT_TRANSLATE_NOOP(QUrl, ": ")); - errorString += QLatin1String(errorInfo._message); + if (isHostValid) + errorString += QLatin1String(errorInfo._message); + else + errorString += QLatin1String(QT_TRANSLATE_NOOP(QUrl, "invalid hostname")); } if (errorInfo._found) { errorString += QLatin1String(QT_TRANSLATE_NOOP(QUrl, ", but found \'")); @@ -4441,7 +4454,7 @@ void QUrl::setAuthority(const QString &authority) if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); detach(); - QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized); + QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized); d->setAuthority(authority); } diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index b5236e5..63f9721 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -2478,16 +2478,26 @@ void tst_QUrl::isValid() QUrl url = QUrl::fromEncoded("http://strange;hostname/here"); QVERIFY(!url.isValid()); QCOMPARE(url.path(), QString("/here")); + url.setAuthority("strange;hostname"); + QVERIFY(!url.isValid()); url.setAuthority("foobar@bar"); QVERIFY(url.isValid()); + url.setAuthority("strange;hostname"); + QVERIFY(!url.isValid()); + QVERIFY(url.errorString().contains("invalid hostname")); } { QUrl url = QUrl::fromEncoded("foo://stuff;1/g"); QVERIFY(!url.isValid()); QCOMPARE(url.path(), QString("/g")); + url.setHost("stuff;1"); + QVERIFY(!url.isValid()); url.setHost("stuff-1"); QVERIFY(url.isValid()); + url.setHost("stuff;1"); + QVERIFY(!url.isValid()); + QVERIFY(url.errorString().contains("invalid hostname")); } } -- cgit v0.12 From 759c3c2a2a62648b0fc4b2970a1fdb3a52c488a7 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 10 Sep 2010 10:53:41 +0200 Subject: NTLM code: Save domain in different variable Reviewed-by: Markus Goetz --- src/network/kernel/qauthenticator.cpp | 39 +++++++++++++++++++++++++++-------- src/network/kernel/qauthenticator_p.h | 1 + 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 18cc14e..f97d833 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -210,19 +210,38 @@ void QAuthenticator::setUser(const QString &user) switch(d->method) { case QAuthenticatorPrivate::DigestMd5: - case QAuthenticatorPrivate::Ntlm: - if((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1) - { + if((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1) { //domain name is present + d->userDomain.clear(); d->realm = user.left(separatorPosn); d->user = user.mid(separatorPosn + 1); } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) { //domain name is present + d->userDomain.clear(); d->realm = user.mid(separatorPosn + 1); d->user = user.left(separatorPosn); } else { d->user = user; d->realm.clear(); + d->userDomain.clear(); + } + break; + + case QAuthenticatorPrivate::Ntlm: + if((separatorPosn = user.indexOf(QLatin1String("\\"))) != -1) { + //domain name is present + d->realm.clear(); + d->userDomain = user.left(separatorPosn); + d->user = user.mid(separatorPosn + 1); + } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) { + //domain name is present + d->realm.clear(); + d->userDomain = user.left(separatorPosn); + d->user = user.left(separatorPosn); + } else { + d->user = user; + d->realm.clear(); + d->userDomain.clear(); } break; // For other auth mechanisms, domain name will be part of username @@ -1178,7 +1197,7 @@ static QByteArray qCreatev2Hash(const QAuthenticatorPrivate *ctx, // Assuming the user and domain is always unicode in challenge QByteArray message = qStringAsUcs2Le(ctx->user.toUpper()) + - qStringAsUcs2Le(ctx->realm); + qStringAsUcs2Le(phase3->domainStr); phase3->v2Hash = qEncodeHmacMd5(hashKey, message); } @@ -1364,9 +1383,6 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas bool unicode = ch.flags & NTLMSSP_NEGOTIATE_UNICODE; - if(ctx->realm.isEmpty()) - ctx->realm = ch.targetNameStr; - pb.flags = NTLMSSP_NEGOTIATE_NTLM; if (unicode) pb.flags |= NTLMSSP_NEGOTIATE_UNICODE; @@ -1377,8 +1393,13 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas int offset = QNtlmPhase3BlockBase::Size; Q_ASSERT(QNtlmPhase3BlockBase::Size == sizeof(QNtlmPhase3BlockBase)); - offset = qEncodeNtlmString(pb.domain, offset, ctx->realm, unicode); - pb.domainStr = ctx->realm; + if(ctx->userDomain.isEmpty()) { + offset = qEncodeNtlmString(pb.domain, offset, ch.targetNameStr, unicode); + pb.domainStr = ch.targetNameStr; + } else { + offset = qEncodeNtlmString(pb.domain, offset, ctx->userDomain, unicode); + pb.domainStr = ctx->userDomain; + } offset = qEncodeNtlmString(pb.user, offset, ctx->user, unicode); pb.userStr = ctx->user; diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h index 1096601..4e09360 100644 --- a/src/network/kernel/qauthenticator_p.h +++ b/src/network/kernel/qauthenticator_p.h @@ -91,6 +91,7 @@ public: // ntlm specific QString workstation; + QString userDomain; QByteArray calculateResponse(const QByteArray &method, const QByteArray &path); -- cgit v0.12 From 839e2ed4746d748df67570934a0be9e0a9cd0c3d Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Thu, 9 Sep 2010 16:03:45 +0200 Subject: Added private API to install an x11EventFilter Some libs need to intercept X11 events without actually being able to subclass QApplication, so add a private API to allow setting event filter functions. Reviewed By: Robert Griebl --- src/gui/kernel/qapplication_x11.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 7495f6d..e7b7ed8 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -400,11 +400,39 @@ QTabletDeviceDataList *qt_tablet_devices() extern bool qt_tabletChokeMouse; #endif +typedef bool(*QX11FilterFunction)(XEvent *event); + +Q_GLOBAL_STATIC(QList, x11Filters) + +Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func) +{ + Q_ASSERT(func); + + if (QList *list = x11Filters()) + list->append(func); +} + +Q_GUI_EXPORT void qt_removeX11EventFilter(QX11FilterFunction func) +{ + Q_ASSERT(func); + + if (QList *list = x11Filters()) + list->removeOne(func); +} + + static bool qt_x11EventFilter(XEvent* ev) { long unused; if (qApp->filterEvent(ev, &unused)) return true; + if (const QList *list = x11Filters()) { + for (QList::const_iterator it = list->constBegin(); it != list->constEnd(); ++it) { + if ((*it)(ev)) + return true; + } + } + return qApp->x11EventFilter(ev); } -- cgit v0.12 From 60bfb40e3c398163fe17834c26cdf97579946cc2 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 10 Sep 2010 11:01:44 +0200 Subject: fix CRLF --- tests/auto/qlineedit/tst_qlineedit.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index bfa9406..93bd447 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -3747,15 +3747,15 @@ void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup() void tst_QLineEdit::QTBUG13520_textNotVisible() { LineEdit le; - le.setAlignment( Qt::AlignRight | Qt::AlignVCenter); - le.show(); - QTest::qWaitForWindowShown(&le); - le.setText("01-ST16-01SIL-MPL001wfgsdfgsdgsdfgsdfgsdfgsdfgsdfg"); - le.setCursorPosition(0); - QTest::qWait(100); //just make sure we get he lineedit correcly painted - - QVERIFY(le.cursorRect().center().x() < le.width() / 2); - + le.setAlignment( Qt::AlignRight | Qt::AlignVCenter); + le.show(); + QTest::qWaitForWindowShown(&le); + le.setText("01-ST16-01SIL-MPL001wfgsdfgsdgsdfgsdfgsdfgsdfgsdfg"); + le.setCursorPosition(0); + QTest::qWait(100); //just make sure we get he lineedit correcly painted + + QVERIFY(le.cursorRect().center().x() < le.width() / 2); + } -- cgit v0.12 From 7e05bf257d589e97e54b36cb112f96ae17cbd6f2 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 10 Sep 2010 14:06:59 +0200 Subject: Fix the bug for QSettings on Windows, to store qint32/quint32, qint64/quint64 in Windows registry. Reviewed-by: Prasanth Ullattil Reviewed-by: Joerg Bornemann Task: QTBUT-13249 AutoTest: Included --- src/corelib/io/qsettings_win.cpp | 24 +++++++++++-- tests/auto/qsettings/tst_qsettings.cpp | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp index de96e06..b3fe734 100644 --- a/src/corelib/io/qsettings_win.cpp +++ b/src/corelib/io/qsettings_win.cpp @@ -535,6 +535,15 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa break; } + case REG_QWORD: { + Q_ASSERT(data.size() == sizeof(qint64)); + qint64 i; + memcpy((char*)&i, data.constData(), sizeof(qint64)); + if (value != 0) + *value = i; + break; + } + default: qWarning("QSettings: Unknown data %d type in Windows registry", static_cast(dataType)); if (value != 0) @@ -683,10 +692,19 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value) break; } - case QVariant::Int: { + case QVariant::Int: + case QVariant::UInt: { type = REG_DWORD; - int i = value.toInt(); - regValueBuff = QByteArray((const char*)&i, sizeof(int)); + qint32 i = value.toInt(); + regValueBuff = QByteArray((const char*)&i, sizeof(qint32)); + break; + } + + case QVariant::LongLong: + case QVariant::ULongLong: { + type = REG_QWORD; + qint64 i = value.toLongLong(); + regValueBuff = QByteArray((const char*)&i, sizeof(qint64)); break; } diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp index 058a750..0395eff 100644 --- a/tests/auto/qsettings/tst_qsettings.cpp +++ b/tests/auto/qsettings/tst_qsettings.cpp @@ -60,6 +60,10 @@ #include #endif +#if defined(Q_OS_WIN) +#include +#endif + #ifndef QSETTINGS_P_H_VERSION #define QSETTINGS_P_H_VERSION 1 #endif @@ -127,6 +131,9 @@ private slots: #if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) void dontReorderIniKeysNeedlessly(); #endif +#if defined(Q_OS_WIN) + void qtbug_13249(); +#endif /* These tests were developed for the Qt 3 QSettings class. @@ -3801,6 +3808,62 @@ void tst_QSettings::setPathBug() } #endif +#if defined(Q_OS_WIN) + +static DWORD readKeyType(HKEY handle, const QString &rSubKey) +{ + DWORD dataType; + DWORD dataSize; + LONG res = RegQueryValueEx(handle, reinterpret_cast(rSubKey.utf16()), 0, &dataType, 0, &dataSize); + + if (res == ERROR_SUCCESS) + return dataType; + + return 0; +} + +void tst_QSettings::qtbug_13249() +{ + QSettings settings1(QSettings::UserScope, "software.org", "KillerAPP"); + + qint32 x = 1024; + settings1.setValue("qtbug_13249_a", (qint32)x); + QCOMPARE(settings1.value("qtbug_13249_a").toInt(), (qint32)1024); + settings1.setValue("qtbug_13249_b", (quint32)x); + QCOMPARE(settings1.value("qtbug_13249_b").toUInt(), (quint32)1024); + settings1.setValue("qtbug_13249_c", (qint64)x); + QCOMPARE(settings1.value("qtbug_13249_c").toLongLong(), (qint64)1024); + settings1.setValue("qtbug_13249_d", (quint64)x); + QCOMPARE(settings1.value("qtbug_13249_d").toULongLong(), (quint64)1024); + settings1.sync(); + + HKEY handle; + LONG res; + QString keyName = "Software\\software.org\\KillerAPP"; + res = RegOpenKeyEx(HKEY_CURRENT_USER, reinterpret_cast(keyName.utf16()), 0, KEY_READ, &handle); + if (res == ERROR_SUCCESS) + { + DWORD dataType; + dataType = readKeyType(handle, QString("qtbug_13249_a")); + if (dataType != 0) { + QCOMPARE((int)REG_DWORD, (int)dataType); + } + dataType = readKeyType(handle, QString("qtbug_13249_b")); + if (dataType != 0) { + QCOMPARE((int)REG_DWORD, (int)dataType); + } + dataType = readKeyType(handle, QString("qtbug_13249_c")); + if (dataType != 0) { + QCOMPARE((int)REG_QWORD, (int)dataType); + } + dataType = readKeyType(handle, QString("qtbug_13249_d")); + if (dataType != 0) { + QCOMPARE((int)REG_QWORD, (int)dataType); + } + RegCloseKey(handle); + } +} +#endif /* // Not tested at the moment. void tst_QSettings::oldSubkeyList() -- cgit v0.12 From 0b78630df897864feb3e3ec5f1da0b21dd13f7b0 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 10 Sep 2010 15:13:00 +0200 Subject: Implement a private API for setting title widgets Meego and Orbit use client side decorations, so implement a top-level layout in QMainWindow that allows us to set title widgets. To prevent regressions on other platforms, the API is disabled by default. Rev-By: Robert Griebl Rev-By: Thierry Bastian --- src/gui/kernel/qwidget_mac.mm | 9 ++-- src/gui/widgets/qdockarealayout.cpp | 10 +++-- src/gui/widgets/qdockwidget.cpp | 37 +++++++--------- src/gui/widgets/qmainwindow.cpp | 71 +++++++++++++++++++++++++++--- src/gui/widgets/qmainwindowlayout.cpp | 11 +++-- src/gui/widgets/qmainwindowlayout_p.h | 2 +- src/gui/widgets/qtoolbar.cpp | 20 +++++---- src/gui/widgets/qtoolbararealayout.cpp | 5 ++- src/gui/widgets/qtoolbarlayout.cpp | 7 ++- tests/auto/qmainwindow/tst_qmainwindow.cpp | 3 +- 10 files changed, 123 insertions(+), 52 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 1979c84..159c45d 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2375,7 +2375,8 @@ void QWidgetPrivate::recreateMacWindow() HIViewRemoveFromSuperview(myView); determineWindowClass(); createWindow_sys(); - if (QMainWindowLayout *mwl = qobject_cast(q->layout())) { + + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast(q))) { mwl->updateHIToolBarStatus(); } @@ -2912,7 +2913,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) // We do this down below for wasCreated, so avoid doing this twice // (only for performance, it gets called a lot anyway). if (!wasCreated) { - if (QMainWindowLayout *mwl = qobject_cast(q->layout())) { + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast(q))) { mwl->updateHIToolBarStatus(); } } @@ -2937,7 +2938,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) // If we were a unified window, We just transfered our toolbars out of the unified toolbar. // So redo the status one more time. It apparently is not an issue with Cocoa. if (q->isWindow()) { - if (QMainWindowLayout *mwl = qobject_cast(q->layout())) { + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast(q))) { mwl->updateHIToolBarStatus(); } } @@ -5138,7 +5139,7 @@ void QWidgetPrivate::macUpdateMetalAttribute() return; recreateMacWindow(); #else - QMainWindowLayout *layout = qobject_cast(q->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast(q)); if (q->testAttribute(Qt::WA_MacBrushedMetal)) { if (layout) layout->updateHIToolBarStatus(); diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 171000b..b540e76 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -60,6 +60,9 @@ QT_BEGIN_NAMESPACE +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + enum { StateFlagVisible = 1, StateFlagFloating = 2 }; /****************************************************************************** @@ -1480,7 +1483,7 @@ QList QDockAreaLayoutInfo::indexOf(QWidget *widget) const QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const { - QMainWindowLayout *result = qobject_cast(mainWindow->layout()); + QMainWindowLayout *result = qt_mainwindow_layout(mainWindow); Q_ASSERT(result != 0); return result; } @@ -3070,8 +3073,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after, void QDockAreaLayout::apply(bool animate) { - QWidgetAnimator &widgetAnimator - = qobject_cast(mainWindow->layout())->widgetAnimator; + QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator; for (int i = 0; i < QInternal::DockCount; ++i) docks[i].apply(animate); @@ -3176,7 +3178,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const if (j < separatorWidgets.size()) { sepWidget = separatorWidgets.at(j); } else { - sepWidget = qobject_cast(mainWindow->layout())->getSeparatorWidget(); + sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget(); separatorWidgets.append(sepWidget); } j++; diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 11f0a94..df9b171 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -68,6 +68,9 @@ QT_BEGIN_NAMESPACE extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) { return (priv->features & feature) == feature; } @@ -690,7 +693,7 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) QMainWindow *win = qobject_cast(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (layout->pluggingWidget != 0) // the main window is animating a docking operation return; @@ -711,8 +714,7 @@ void QDockWidgetPrivate::startDrag() if (state == 0 || state->dragging) return; - QMainWindowLayout *layout - = qobject_cast(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast(q->parentWidget())); Q_ASSERT(layout != 0); state->widgetItem = layout->unplug(q); @@ -739,8 +741,7 @@ void QDockWidgetPrivate::endDrag(bool abort) q->releaseMouse(); if (state->dragging) { - QMainWindowLayout *mwLayout = - qobject_cast(q->parentWidget()->layout()); + QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast(q->parentWidget())); Q_ASSERT(mwLayout != 0); if (abort || !mwLayout->plug(state->widgetItem)) { @@ -780,8 +781,7 @@ bool QDockWidgetPrivate::isAnimating() const if (mainWin == 0) return false; - QMainWindowLayout *mainWinLayout - = qobject_cast(mainWin->layout()); + QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin); if (mainWinLayout == 0) return false; @@ -847,9 +847,8 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) return ret; QDockWidgetLayout *dwlayout - = qobject_cast(layout); - QMainWindowLayout *mwlayout - = qobject_cast(q->parentWidget()->layout()); + = qobject_cast(layout); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast(q->parentWidget())); if (!dwlayout->nativeWindowDeco()) { if (!state->dragging && mwlayout->pluggingWidget == 0 @@ -943,8 +942,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) } #ifdef Q_OS_MAC else { // workaround for lack of mouse-grab on Mac - QMainWindowLayout *layout - = qobject_cast(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast(q->parentWidget())); Q_ASSERT(layout != 0); q->move(event->globalPos() - state->pressPos); @@ -980,8 +978,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event) if (state->ctrlDrag) return; - QMainWindowLayout *layout - = qobject_cast(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast(q->parentWidget())); Q_ASSERT(layout != 0); QPoint globalMousePos = event->pos() + state->pressPos; @@ -1009,7 +1006,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect Q_Q(QDockWidget); if (!floating && parent) { - QMainWindowLayout *mwlayout = qobject_cast(q->parentWidget()->layout()); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast(q->parentWidget())); if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea) return; // this dockwidget can't be redocked } @@ -1055,7 +1052,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect if (floating != wasFloating) { emit q->topLevelChanged(floating); if (!floating && parent) { - QMainWindowLayout *mwlayout = qobject_cast(q->parentWidget()->layout()); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast(q->parentWidget())); if (mwlayout) emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); } @@ -1326,10 +1323,10 @@ void QDockWidget::changeEvent(QEvent *event) #ifndef QT_NO_TABBAR { QMainWindow *win = qobject_cast(parentWidget()); - if (QMainWindowLayout *winLayout = - (win ? qobject_cast(win->layout()) : 0)) + if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) { if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this)) info->updateTabBar(); + } } #endif // QT_NO_TABBAR break; @@ -1382,9 +1379,7 @@ bool QDockWidget::event(QEvent *event) Q_D(QDockWidget); QMainWindow *win = qobject_cast(parentWidget()); - QMainWindowLayout *layout = 0; - if (win != 0) - layout = qobject_cast(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); switch (event->type()) { #ifndef QT_NO_ACTION diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 44483ea..1183be6 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +//#define QT_EXPERIMENTAL_CLIENT_DECORATIONS + #include "qmainwindow.h" #include "qmainwindowlayout_p.h" @@ -99,12 +101,70 @@ public: uint hasOldCursor : 1; uint cursorAdjusted : 1; #endif + + static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow) + { + return mainWindow ? mainWindow->d_func()->layout : static_cast(0); + } }; +QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow) +{ + return QMainWindowPrivate::mainWindowLayout(mainWindow); +} + +#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS +Q_GUI_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget) +{ + QGridLayout *topLayout = qobject_cast(mainWindow->layout()); + Q_ASSERT(topLayout); + + int row = 0; + int column = 0; + + switch (area) { + case Qt::LeftDockWidgetArea: + row = 1; + column = 0; + break; + case Qt::TopDockWidgetArea: + row = 0; + column = 1; + break; + case Qt::BottomDockWidgetArea: + row = 2; + column = 1; + break; + case Qt::RightDockWidgetArea: + row = 1; + column = 2; + break; + default: + Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area"); + return; + } + + if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column)) + delete oldItem->widget(); + topLayout->addWidget(widget, row, column); +} +#endif + void QMainWindowPrivate::init() { Q_Q(QMainWindow); - layout = new QMainWindowLayout(q); + +#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS + QGridLayout *topLayout = new QGridLayout(q); + topLayout->setContentsMargins(0, 0, 0, 0); + + layout = new QMainWindowLayout(q, topLayout); + + topLayout->addItem(layout, 1, 1); +#else + layout = new QMainWindowLayout(q, 0); +#endif + const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); iconSize = QSize(metric, metric); q->setAttribute(Qt::WA_Hover); @@ -461,10 +521,11 @@ QMenuBar *QMainWindow::menuBar() const */ void QMainWindow::setMenuBar(QMenuBar *menuBar) { - Q_D(QMainWindow); - if (d->layout->menuBar() && d->layout->menuBar() != menuBar) { + QLayout *topLayout = layout(); + + if (topLayout->menuBar() && topLayout->menuBar() != menuBar) { // Reparent corner widgets before we delete the old menu bar. - QMenuBar *oldMenuBar = qobject_cast(d->layout->menuBar()); + QMenuBar *oldMenuBar = qobject_cast(topLayout->menuBar()); if (menuBar) { // TopLeftCorner widget. QWidget *cornerWidget = oldMenuBar->cornerWidget(Qt::TopLeftCorner); @@ -478,7 +539,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) oldMenuBar->hide(); oldMenuBar->deleteLater(); } - d->layout->setMenuBar(menuBar); + topLayout->setMenuBar(menuBar); } /*! diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 62ee398..4dd5208 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -160,7 +160,7 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayout &layout, QString void qt_dumpLayout(QTextStream &qout, QMainWindow *window) { - QMainWindowLayout *layout = qobject_cast(window->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(window); dumpLayout(qout, layout->layoutState.dockAreaLayout, QString()); } @@ -235,7 +235,7 @@ void QMainWindowLayoutState::apply(bool animated) dockAreaLayout.apply(animated); #else if (centralWidgetItem != 0) { - QMainWindowLayout *layout = qobject_cast(mainWindow->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); Q_ASSERT(layout != 0); layout->widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animated); } @@ -1674,8 +1674,8 @@ void QMainWindowLayout::restore(bool keepSavedState) updateGapIndicator(); } -QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow) - : QLayout(mainwindow) +QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout) + : QLayout(parentLayout ? static_cast(0) : mainwindow) , layoutState(mainwindow) , savedState(mainwindow) , dockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks) @@ -1698,6 +1698,9 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow) , blockVisiblityCheck(false) #endif { + if (parentLayout) + setParent(parentLayout); + #ifndef QT_NO_DOCKWIDGET #ifndef QT_NO_TABBAR sep = mainwindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainwindow); diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h index 955693d..e1b981c 100644 --- a/src/gui/widgets/qmainwindowlayout_p.h +++ b/src/gui/widgets/qmainwindowlayout_p.h @@ -159,7 +159,7 @@ class Q_AUTOTEST_EXPORT QMainWindowLayout : public QLayout public: QMainWindowLayoutState layoutState, savedState; - explicit QMainWindowLayout(QMainWindow *mainwindow); + QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout); ~QMainWindowLayout(); QMainWindow::DockOptions dockOptions; diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 7ed27ea..316bb44 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -82,6 +82,9 @@ static void qt_mac_updateToolBarButtonHint(QWidget *parentWidget) } #endif +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + /****************************************************************************** ** QToolBarPrivate */ @@ -197,7 +200,7 @@ void QToolBarPrivate::initDrag(const QPoint &pos) QMainWindow *win = qobject_cast(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (layout->pluggingWidget != 0) // the main window is animating a docking operation return; @@ -223,7 +226,7 @@ void QToolBarPrivate::startDrag(bool moving) QMainWindow *win = qobject_cast(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (!moving) { @@ -247,8 +250,7 @@ void QToolBarPrivate::endDrag() q->releaseMouse(); if (state->dragging) { - QMainWindowLayout *layout = - qobject_cast(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast(q->parentWidget())); Q_ASSERT(layout != 0); if (!layout->plug(state->widgetItem)) { @@ -340,7 +342,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) if (win == 0) return true; - QMainWindowLayout *layout = qobject_cast(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (layout->pluggingWidget == 0 @@ -588,7 +590,7 @@ QToolBar::~QToolBar() QMainWindow *mainwindow = qobject_cast(parentWidget()); if (mainwindow) { #ifdef Q_WS_MAC - QMainWindowLayout *mainwin_layout = qobject_cast(mainwindow->layout()); + QMainWindowLayout *mainwin_layout = qt_mainwindow_layout(mainwindow); if (mainwin_layout && mainwin_layout->layoutState.toolBarAreaLayout.isEmpty() && mainwindow->testAttribute(Qt::WA_WState_Created)) macWindowToolbarShow(mainwindow, false); @@ -1135,7 +1137,7 @@ bool QToolBar::event(QEvent *event) if (toolbarInUnifiedToolBar(this)) { // I can static_cast because I did the qobject_cast in the if above, therefore // we must have a QMainWindowLayout here. - QMainWindowLayout *mwLayout = static_cast(parentWidget()->layout()); + QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast(parentWidget())); mwLayout->fixSizeInUnifiedToolbar(this); mwLayout->syncUnifiedToolbarVisibility(); } @@ -1289,6 +1291,8 @@ QWidget *QToolBar::widgetForAction(QAction *action) const return d->layout->itemAt(index)->widget(); } +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + /*! \internal */ @@ -1315,7 +1319,7 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const if (!mainWindow) return; - QMainWindowLayout *layout = qobject_cast(mainWindow->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()", "QMainWindow->layout() != QMainWindowLayout"); diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index 8327af5..b312751 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -59,6 +59,9 @@ QT_BEGIN_NAMESPACE +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow); + QSize QToolBarAreaLayoutItem::minimumSize() const { if (skip()) @@ -872,7 +875,7 @@ void QToolBarAreaLayout::insertItem(QToolBar *before, QLayoutItem *item) void QToolBarAreaLayout::apply(bool animate) { - QMainWindowLayout *layout = qobject_cast(mainWindow->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); Q_ASSERT(layout != 0); Qt::LayoutDirection dir = mainWindow->layoutDirection(); diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp index f87510f..59b027e 100644 --- a/src/gui/widgets/qtoolbarlayout.cpp +++ b/src/gui/widgets/qtoolbarlayout.cpp @@ -57,6 +57,9 @@ QT_BEGIN_NAMESPACE +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + /****************************************************************************** ** QToolBarItem */ @@ -404,7 +407,7 @@ void QToolBarLayout::setGeometry(const QRect &rect) if (QMainWindow *win = qobject_cast(tb->parentWidget())) { Qt::ToolBarArea area = win->toolBarArea(tb); if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) { - static_cast(win->layout())->fixSizeInUnifiedToolbar(tb); + qt_mainwindow_layout(win)->fixSizeInUnifiedToolbar(tb); } } # endif @@ -659,7 +662,7 @@ void QToolBarLayout::setExpanded(bool exp) #else animating = !tb->isWindow() && win->isAnimated(); #endif - QMainWindowLayout *layout = qobject_cast(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); if (expanded) { tb->raise(); } else { diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp index 1273e85..6f95672 100644 --- a/tests/auto/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp @@ -1449,8 +1449,7 @@ Q_DECLARE_METATYPE(MoveList) void MoveSeparator::apply(QMainWindow *mw) const { - - QMainWindowLayout *l = qobject_cast(mw->layout()); + QMainWindowLayout *l = qFindChild(mw->layout()); QVERIFY(l); QList path; -- cgit v0.12 From 94584dcdd02e2c08e05ca75f6f8b460c0c320947 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 9 Sep 2010 13:25:55 +0200 Subject: don't try to show source when no locations are given Task-number: QTBUG-13466 --- tools/linguist/linguist/mainwindow.cpp | 6 +++--- tools/linguist/linguist/sourcecodeview.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index 265df05..18baa24 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -1522,7 +1522,7 @@ void MainWindow::selectedMessageChanged(const QModelIndex &sortedIndex, const QM } m_phraseView->setSourceText(-1, QString()); } - if (m) { + if (m && !m->fileName().isEmpty()) { if (hasFormPreview(m->fileName())) { m_sourceAndFormView->setCurrentWidget(m_formPreviewView); m_formPreviewView->setSourceContext(model, m); @@ -1577,7 +1577,7 @@ void MainWindow::updateTranslation(const QStringList &translations) return; m->setTranslations(translations); - if (hasFormPreview(m->fileName())) + if (!m->fileName().isEmpty() && hasFormPreview(m->fileName())) m_formPreviewView->setSourceContext(m_currentIndex.model(), m); updateDanger(m_currentIndex, true); @@ -1996,7 +1996,7 @@ void MainWindow::updateLatestModel(int model) if (m_currentIndex.isValid()) { if (MessageItem *item = m_dataModel->messageItem(m_currentIndex)) { - if (hasFormPreview(item->fileName())) + if (!item->fileName().isEmpty() && hasFormPreview(item->fileName())) m_formPreviewView->setSourceContext(model, item); if (enableRw && !item->isObsolete()) m_phraseView->setSourceText(model, item->text()); diff --git a/tools/linguist/linguist/sourcecodeview.cpp b/tools/linguist/linguist/sourcecodeview.cpp index b8dd9c0..d2eef56 100644 --- a/tools/linguist/linguist/sourcecodeview.cpp +++ b/tools/linguist/linguist/sourcecodeview.cpp @@ -64,7 +64,7 @@ void SourceCodeView::setSourceContext(const QString &fileName, const int lineNum m_fileToLoad.clear(); setToolTip(fileName); - if (fileName.isNull()) { + if (fileName.isEmpty()) { clear(); m_currentFileName.clear(); appendHtml(tr("Source code not available")); -- cgit v0.12 From c2d6eb9dca7546bbe8d9c6c62db683615e4b23a7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 9 Sep 2010 18:34:18 +0200 Subject: don't let operator overloads confuse us Task-number: QTBUG-11426 --- .../linguist/lupdate/testdata/good/parsecpp/main.cpp | 16 ++++++++++++++++ .../lupdate/testdata/good/parsecpp/project.ts.result | 8 ++++++++ tools/linguist/lupdate/cpp.cpp | 15 +++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index f58f932..c56ba7c 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -302,3 +302,19 @@ static inline QString message2() } } + + + +// QTBUG-11426: operator overloads +class LotsaFun : public QObject +{ + Q_OBJECT +public: + int operator<<(int left, int right); +}; + +int LotsaFun::operator<<(int left, int right) +{ + tr("this is inside operator<<"); + return left << right; +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 7ac318e..1a6d551 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -141,6 +141,14 @@ backslashed \ stuff. + LotsaFun + + + this is inside operator<< + + + + Plurals, QCoreApplication diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 970d44b..009d5a7 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -489,6 +489,7 @@ STRING(class); STRING(findMessage); STRING(friend); STRING(namespace); +STRING(operator); STRING(qtTrId); STRING(return); STRING(struct); @@ -753,6 +754,20 @@ uint CppParser::getToken() if (yyWord == strnamespace) return Tok_namespace; break; + case 'o': + if (yyWord == stroperator) { + // Operator overload declaration/definition. + // We need to prevent those characters from confusing the followup + // parsing. Actually using them does not add value, so just eat them. + while (isspace(yyCh)) + yyCh = getChar(); + while (yyCh == '+' || yyCh == '-' || yyCh == '*' || yyCh == '/' || yyCh == '%' + || yyCh == '=' || yyCh == '<' || yyCh == '>' || yyCh == '!' + || yyCh == '&' || yyCh == '|' || yyCh == '~' || yyCh == '^' + || yyCh == '[' || yyCh == ']') + yyCh = getChar(); + } + break; case 'q': if (yyWord == strqtTrId) return Tok_trid; -- cgit v0.12 From f7db9a602a83b05ccad6ac33a2ab63acf3367481 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Sep 2010 09:34:43 +0200 Subject: delay next token fetching when opening namespace otherwise, if the next token to be fetched is a non-empty #define, it would save the context before entering the namespace, and thus the post-define context restore would just discard the namespace entry. Task-number: QTBUG-12683 --- .../lupdate/testdata/good/parsecpp/main.cpp | 25 ++++++++++++++++++++++ .../testdata/good/parsecpp/project.ts.result | 8 +++++++ tools/linguist/lupdate/cpp.cpp | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index c56ba7c..706e8d0 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -318,3 +318,28 @@ int LotsaFun::operator<<(int left, int right) tr("this is inside operator<<"); return left << right; } + + + +// QTBUG-12683: define in re-opened namespace +namespace NameSchpace { + +class YetMoreFun : public QObject +{ + Q_OBJECT +public: + void funStuff(); +}; + +} + +namespace NameSchpace { + +#define somevar 1 + +void YetMoreFun::funStuff() +{ + tr("funStuff!"); +} + +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 1a6d551..f73fc64 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -149,6 +149,14 @@ backslashed \ stuff. + NameSchpace::YetMoreFun + + + funStuff! + + + + Plurals, QCoreApplication diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 009d5a7..d701d7f 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1704,7 +1704,6 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) HashString ns = HashString(text); yyTok = getToken(); if (yyTok == Tok_LeftBrace) { - yyTok = getToken(); namespaceDepths.push(namespaces.count()); enterNamespace(&namespaces, ns); @@ -1712,6 +1711,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) functionContextUnresolved.clear(); prospectiveContext.clear(); pendingContext.clear(); + yyTok = getToken(); } else if (yyTok == Tok_Equals) { // e.g. namespace Is = OuterSpace::InnerSpace; QList fullName; -- cgit v0.12 From b7ae28f8abcf591d8897c8e47a096aabb2c36a2b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 10 Sep 2010 16:25:18 +0200 Subject: fetch next token after class definition opening this makes no real difference, as at this point the token is known to be an opening brace which will be handled without side effects in the next iteration, but this is a tad more efficient and simply cleaner. --- tools/linguist/lupdate/cpp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index d701d7f..6ea7299 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1693,6 +1693,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) functionContextUnresolved.clear(); // Pointless prospectiveContext.clear(); pendingContext.clear(); + + yyTok = getToken(); } break; case Tok_namespace: -- cgit v0.12 From e26cba5c15ae02ae0fba9b73ed90c9b1f7b5286b Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 10 Sep 2010 17:55:06 +0200 Subject: Bearer management: Fix compilation with namespace. --- src/plugins/bearer/connman/qofonoservice_linux_p.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/bearer/connman/qofonoservice_linux_p.h b/src/plugins/bearer/connman/qofonoservice_linux_p.h index 4892666..0ac1e4a 100644 --- a/src/plugins/bearer/connman/qofonoservice_linux_p.h +++ b/src/plugins/bearer/connman/qofonoservice_linux_p.h @@ -329,4 +329,6 @@ Q_SIGNALS: void incomingMessage(const QString &message, const QVariantMap &info); }; +QT_END_NAMESPACE + #endif //QOFONOSERVICE_H -- cgit v0.12 From 288244c528ca169d1a3b015e27fc9561d7094563 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 11 Sep 2010 09:58:43 +0200 Subject: Revert "Properly implement qobject_cast for const pointers." This commit added new symbols to the 4.7 branch after 4.7.0 was frozen. This reverts commit 0b0aa7603b27447a5abe55c55d0514bc56b35f9e. --- src/corelib/kernel/qmetaobject.cpp | 20 +------------------- src/corelib/kernel/qobject.h | 6 +++++- src/corelib/kernel/qobjectdefs.h | 1 - 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 3b9b04a..9854e68 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -266,25 +266,7 @@ QObject *QMetaObject::cast(QObject *obj) const const QMetaObject *m = obj->metaObject(); do { if (m == this) - return obj; - } while ((m = m->d.superdata)); - } - return 0; -} - -/*! - \internal - - Returns \a obj if object \a obj inherits from this - meta-object; otherwise returns 0. -*/ -const QObject *QMetaObject::cast(const QObject *obj) const -{ - if (obj) { - const QMetaObject *m = obj->metaObject(); - do { - if (m == this) - return obj; + return const_cast(obj); } while ((m = m->d.superdata)); } return 0; diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index b5c772e..d98d1f0 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -369,10 +369,14 @@ inline T qobject_cast(QObject *object) template inline T qobject_cast(const QObject *object) { + // this will cause a compilation error if T is not const + register T ptr = static_cast(object); + Q_UNUSED(ptr); + #if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(const_cast(object))); #endif - return static_cast(reinterpret_cast(0)->staticMetaObject.cast(object)); + return static_cast(const_cast(reinterpret_cast(0)->staticMetaObject.cast(const_cast(object)))); } diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 0d045dc..555a1f5 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -298,7 +298,6 @@ struct Q_CORE_EXPORT QMetaObject const QMetaObject *superClass() const; QObject *cast(QObject *obj) const; - const QObject *cast(const QObject *obj) const; #ifndef QT_NO_TRANSLATION // ### Qt 4: Merge overloads -- cgit v0.12 From d9f5115eb7f7ba78db245ff9e66ae638317f5b70 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 12 Sep 2010 19:19:52 +0200 Subject: QStroker: Fix erroneous SvgMiterJoin behavior for parallel lines QLineF::intersect() yields an undefined intersectionPoint for parallel lines. Thus if the distance to 0,0 is shorter than the current miter limit, we would draw a triangle to 0,0. Handle this by not drawing the triangle for parallel lines. This matches the behavior of Qt::MiterJoin. --- src/gui/painting/qstroker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index eabbd8a..9cff339 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -609,7 +609,7 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine } QLineF miterLine(QPointF(qt_fixed_to_real(focal_x), qt_fixed_to_real(focal_y)), isect); - if (miterLine.length() > qt_fixed_to_real(m_strokeWidth * m_miterLimit) / 2) { + if (type == QLineF::NoIntersection || miterLine.length() > qt_fixed_to_real(m_strokeWidth * m_miterLimit) / 2) { emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); } else { -- cgit v0.12 From b7d98cb89889032d7fc7b7e16b5183305dfb714b Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 13 Sep 2010 12:08:22 +1000 Subject: Fix memory leaks and valgrind errors. --- src/network/bearer/qbearerengine.cpp | 3 +++ src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp index 2f8624a..b074924 100644 --- a/src/network/bearer/qbearerengine.cpp +++ b/src/network/bearer/qbearerengine.cpp @@ -58,18 +58,21 @@ QBearerEngine::~QBearerEngine() it.value()->isValid = false; it.value()->id.clear(); } + snapConfigurations.clear(); for (it = accessPointConfigurations.begin(), end = accessPointConfigurations.end(); it != end; ++it) { it.value()->isValid = false; it.value()->id.clear(); } + accessPointConfigurations.clear(); for (it = userChoiceConfigurations.begin(), end = userChoiceConfigurations.end(); it != end; ++it) { it.value()->isValid = false; it.value()->id.clear(); } + userChoiceConfigurations.clear(); } bool QBearerEngine::requiresPolling() const diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index 29445ce..554f9b7 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -97,6 +97,10 @@ QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent) QNetworkManagerEngine::~QNetworkManagerEngine() { + qDeleteAll(connections); + qDeleteAll(accessPoints); + qDeleteAll(wirelessDevices); + qDeleteAll(activeConnections); } void QNetworkManagerEngine::initialize() @@ -389,7 +393,7 @@ void QNetworkManagerEngine::deviceRemoved(const QDBusObjectPath &path) { QMutexLocker locker(&mutex); - delete wirelessDevices.value(path.path()); + delete wirelessDevices.take(path.path()); } void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, @@ -455,6 +459,8 @@ void QNetworkManagerEngine::removeConnection(const QString &path) QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id); + connection->deleteLater(); + locker.unlock(); emit configurationRemoved(ptr); } @@ -631,7 +637,8 @@ void QNetworkManagerEngine::removeAccessPoint(const QString &path, locker.unlock(); emit configurationChanged(ptr); - return; + locker.relock(); + break; } } } else { -- cgit v0.12 From d1b522c76eb1132254f195c2f59bd5d55cd2f525 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 13 Sep 2010 13:26:22 +1000 Subject: Remove debug, quiet warnings. --- examples/network/bearermonitor/sessionwidget.cpp | 2 +- src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp index ecc2a93..5ec9d53 100644 --- a/examples/network/bearermonitor/sessionwidget.cpp +++ b/examples/network/bearermonitor/sessionwidget.cpp @@ -107,7 +107,7 @@ void SessionWidget::updateSession() if (session->state() == QNetworkSession::Connected) statsTimer = startTimer(1000); - else + else if (statsTimer != -1) killTimer(statsTimer); if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint) diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index f47c97c..499fe5a 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -743,8 +743,6 @@ bool QNetworkManagerSettingsConnection::isAutoConnect() quint64 QNetworkManagerSettingsConnection::getTimestamp() { - qDebug() << d->settingsMap.value(QLatin1String("connection")); - return d->settingsMap.value(QLatin1String("connection")) .value(QLatin1String("timestamp")).toUInt(); } -- cgit v0.12 From b8c1712988f00d7bb2e9ca02b598a77fb2a6ff01 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 13 Sep 2010 14:26:00 +1000 Subject: Don't add generic subdirs project twice. Task-number: QTBUG-13519 --- src/plugins/bearer/bearer.pro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro index bbe8ab1..d1d75f0 100644 --- a/src/plugins/bearer/bearer.pro +++ b/src/plugins/bearer/bearer.pro @@ -3,9 +3,9 @@ TEMPLATE = subdirs contains(QT_CONFIG, dbus) { contains(QT_CONFIG, icd) { SUBDIRS += icd - } else { + } else:linux* { SUBDIRS += generic - linux*:SUBDIRS += connman networkmanager + SUBDIRS += connman networkmanager } } @@ -16,4 +16,4 @@ macx:contains(QT_CONFIG, corewlan):SUBDIRS += corewlan macx:SUBDIRS += generic symbian:SUBDIRS += symbian -isEmpty(SUBDIRS):SUBDIRS += generic +isEmpty(SUBDIRS):SUBDIRS = generic -- cgit v0.12