diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-09-13 05:17:01 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-09-13 05:17:01 (GMT) |
commit | baaf73adf3430a3223fdd09e971138470f0126d2 (patch) | |
tree | 5735888a05b612eb55b048890268a9307e495690 /src | |
parent | 0b4cc3fff39f9f5a7b7c0e1cfdc241c70fa475d8 (diff) | |
parent | b8c1712988f00d7bb2e9ca02b598a77fb2a6ff01 (diff) | |
download | Qt-baaf73adf3430a3223fdd09e971138470f0126d2.zip Qt-baaf73adf3430a3223fdd09e971138470f0126d2.tar.gz Qt-baaf73adf3430a3223fdd09e971138470f0126d2.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
Don't add generic subdirs project twice.
Remove debug, quiet warnings.
Fix memory leaks and valgrind errors.
QStroker: Fix erroneous SvgMiterJoin behavior for parallel lines
Revert "Properly implement qobject_cast for const pointers."
Bearer management: Fix compilation with namespace.
fetch next token after class definition opening
delay next token fetching when opening namespace
don't let operator overloads confuse us
don't try to show source when no locations are given
Implement a private API for setting title widgets
Fix the bug for QSettings on Windows, to store qint32/quint32, qint64/quint64 in Windows registry.
fix CRLF
Added private API to install an x11EventFilter
NTLM code: Save domain in different variable
Update the error handling of invalid hostnames in QUrl.
Remove unsupported code from qobject.h for MSVC < .NET 2003
Properly implement qobject_cast for const pointers.
Revert "Doc: fixing page name bug caused by 07bbace404078dcfd82eff717daa97299b8ba52c changing qml elements page"
Diffstat (limited to 'src')
21 files changed, 239 insertions, 167 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<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(); } |