diff options
33 files changed, 404 insertions, 186 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 @@ <ul> <li><a href="qtquick.html">Qt Quick</a></li> <li><a href="qdeclarativeintroduction.html">Introduction to QML</a></li> - <li><a href="qmlelements.html">QML Elements</a></li> + <li><a href="qdeclarativeelements.html">QML Elements</a></li> <li><a href="qdeclarativeexamples.html">QML Examples and Demos</a></li> </ul> </div> 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/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<int>(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/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/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 1b613a6..d98d1f0 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<void *> *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<typename T> -inline T qFindChild(const QObject *o, const QString &name, T) -{ return static_cast<T>(qt_qFindChild_helper(o, name, ((T)0)->staticMetaObject)); } - -template<typename T> -inline QList<T> qFindChildren(const QObject *o, const QString &name, T) -{ - QList<T> list; - union { - QList<T> *typedList; - QList<void *> *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, name, 0, ((T)0)->staticMetaObject, u.voidList); - return list; -} - -template<typename T> -inline T qFindChild(const QObject *o, const QString &name) -{ return qFindChild<T>(o, name, T(0)); } - -template<typename T> -inline T qFindChild(const QObject *o) -{ return qFindChild<T>(o, QString(), T(0)); } - -template<typename T> -inline QList<T> qFindChildren(const QObject *o, const QString &name) -{ return qFindChildren<T>(o, name, T(0)); } - -template<typename T> -inline QList<T> qFindChildren(const QObject *o) -{ return qFindChildren<T>(o, QString(), T(0)); } - -#ifndef QT_NO_REGEXP -template<typename T> -inline QList<T> qFindChildren(const QObject *o, const QRegExp &re, T) -{ - QList<T> list; - union { - QList<T> *typedList; - QList<void *> *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, 0, &re, ((T)0)->staticMetaObject, u.voidList); - return list; -} - -template<typename T> -inline QList<T> qFindChildren(const QObject *o, const QRegExp &re) -{ return qFindChildren<T>(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 <class T> inline const char * qobject_interface_iid() -{ return 0; } - -template <class T> inline T qobject_cast_helper(QObject *object, T) -{ return static_cast<T>(((T)0)->staticMetaObject.cast(object)); } - -template <class T> inline T qobject_cast_helper(const QObject *object, T) -{ return static_cast<T>(const_cast<const QObject *>(((T)0)->staticMetaObject.cast(const_cast<QObject *>(object)))); } - -template <class T> -inline T qobject_cast(QObject *object) -{ return qobject_cast_helper<T>(object, T(0)); } - -template <class T> -inline T qobject_cast(const QObject *object) -{ return qobject_cast_helper<T>(object, T(0)); } - -#ifndef Q_MOC_RUN -# define Q_DECLARE_INTERFACE(IFace, IId) \ - template <> inline const char *qobject_interface_iid<IFace *>() \ - { return IId; } \ - template <> inline IFace *qobject_cast_helper<IFace *>(QObject *object, IFace *) \ - { return (IFace *)(object ? object->qt_metacast(IId) : 0); } \ - template <> inline IFace *qobject_cast_helper<IFace *>(const QObject *object, IFace *) \ - { return (IFace *)(object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0); } -#endif // Q_MOC_RUN - -#else - template<typename T> inline T qFindChild(const QObject *o, const QString &name) { return static_cast<T>(qt_qFindChild_helper(o, name, reinterpret_cast<T>(0)->staticMetaObject)); } @@ -482,8 +393,6 @@ template <class T> inline const char * qobject_interface_iid() { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0)); } #endif // Q_MOC_RUN -#endif - #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *); #endif 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<QX11FilterFunction>, x11Filters) + +Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func) +{ + Q_ASSERT(func); + + if (QList<QX11FilterFunction> *list = x11Filters()) + list->append(func); +} + +Q_GUI_EXPORT void qt_removeX11EventFilter(QX11FilterFunction func) +{ + Q_ASSERT(func); + + if (QList<QX11FilterFunction> *list = x11Filters()) + list->removeOne(func); +} + + static bool qt_x11EventFilter(XEvent* ev) { long unused; if (qApp->filterEvent(ev, &unused)) return true; + if (const QList<QX11FilterFunction> *list = x11Filters()) { + for (QList<QX11FilterFunction>::const_iterator it = list->constBegin(); it != list->constEnd(); ++it) { + if ((*it)(ev)) + return true; + } + } + return qApp->x11EventFilter(ev); } 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<QMainWindowLayout *>(q->layout())) { + + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout *>(q->layout())) { + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout *>(q->layout())) { + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) { mwl->updateHIToolBarStatus(); } } @@ -5138,7 +5139,7 @@ void QWidgetPrivate::macUpdateMetalAttribute() return; recreateMacWindow(); #else - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout *>(q->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q)); if (q->testAttribute(Qt::WA_MacBrushedMetal)) { if (layout) layout->updateHIToolBarStatus(); 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 { 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<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const { - QMainWindowLayout *result = qobject_cast<QMainWindowLayout*>(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<QMainWindowLayout*>(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<QMainWindowLayout*>(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<QMainWindow*>(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(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<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout*>(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<QDockWidgetLayout*>(layout); - QMainWindowLayout *mwlayout - = qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout()); + = qobject_cast<QDockWidgetLayout *>(layout); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindow*>(parentWidget()); - if (QMainWindowLayout *winLayout = - (win ? qobject_cast<QMainWindowLayout*>(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<QMainWindow*>(parentWidget()); - QMainWindowLayout *layout = 0; - if (win != 0) - layout = qobject_cast<QMainWindowLayout*>(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<QMainWindowLayout *>(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<QGridLayout *>(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<QMenuBar *>(d->layout->menuBar()); + QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(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<QMainWindowLayout*>(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<QMainWindowLayout*>(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<QWidget *>(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<QMainWindow*>(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(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<QMainWindow*>(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(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<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout*>(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<QMainWindow *>(parentWidget()); if (mainwindow) { #ifdef Q_WS_MAC - QMainWindowLayout *mainwin_layout = qobject_cast<QMainWindowLayout *>(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<QMainWindowLayout *>(parentWidget()->layout()); + QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(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<QMainWindowLayout *>(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<QMainWindowLayout*>(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<QMainWindow*>(tb->parentWidget())) { Qt::ToolBarArea area = win->toolBarArea(tb); if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) { - static_cast<QMainWindowLayout *>(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<QMainWindowLayout*>(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); if (expanded) { tb->raise(); } else { 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/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); 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 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 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 { 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(); } diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index f58f932..706e8d0 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -302,3 +302,44 @@ 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; +} + + + +// 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 7ac318e..f73fc64 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,22 @@ backslashed \ stuff.</source> </message> </context> <context> + <name>LotsaFun</name> + <message> + <location filename="main.cpp" line="318"/> + <source>this is inside operator<<</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>NameSchpace::YetMoreFun</name> + <message> + <location filename="main.cpp" line="342"/> + <source>funStuff!</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>Plurals, QCoreApplication</name> <message numerus="yes"> <location filename="main.cpp" line="81"/> 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); + } 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<QMainWindowLayout*>(mw->layout()); + QMainWindowLayout *l = qFindChild<QMainWindowLayout *>(mw->layout()); QVERIFY(l); QList<int> path; 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 <io.h> #endif +#if defined(Q_OS_WIN) +#include <QtCore/qt_windows.h> +#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<const wchar_t *>(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<const wchar_t *>(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() 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")); } } 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("<i>Source code not available</i>")); diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 970d44b..6ea7299 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; @@ -1678,6 +1693,8 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions) functionContextUnresolved.clear(); // Pointless prospectiveContext.clear(); pendingContext.clear(); + + yyTok = getToken(); } break; case Tok_namespace: @@ -1689,7 +1706,6 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions) HashString ns = HashString(text); yyTok = getToken(); if (yyTok == Tok_LeftBrace) { - yyTok = getToken(); namespaceDepths.push(namespaces.count()); enterNamespace(&namespaces, ns); @@ -1697,6 +1713,7 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions) functionContextUnresolved.clear(); prospectiveContext.clear(); pendingContext.clear(); + yyTok = getToken(); } else if (yyTok == Tok_Equals) { // e.g. namespace Is = OuterSpace::InnerSpace; QList<HashString> fullName; 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 = " <div class=\"header\" id=\"qtdocheader\">\n" \ " <li class=\"defaultLink\"><a href=\"modules.html\">Modules</a></li>\n" \ " <li class=\"defaultLink\"><a href=\"namespaces.html\">Namespaces</a></li>\n" \ " <li class=\"defaultLink\"><a href=\"qtglobal.html\">Global Declarations</a></li>\n" \ - " <li class=\"defaultLink\"><a href=\"qmlelements.html\">QML elements</a></li>\n" \ + " <li class=\"defaultLink\"><a href=\"qdeclarativeelements.html\">QML elements</a></li>\n" \ " </ul> \n" \ " </div>\n" \ " </div>\n" \ |