diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-06-01 03:09:17 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-06-01 03:09:17 (GMT) |
commit | 33a65a1def8e6d40819ead6e7548cb7345f3b922 (patch) | |
tree | f00cf93cb202d8d54ebacd3dedc01ff31d23a9a4 /src | |
parent | 91cb226780d05f0f7d8fd1875121427ade52c1a8 (diff) | |
parent | 5f6b50f99a6457c208c7f186db45a2dba690bace (diff) | |
download | Qt-33a65a1def8e6d40819ead6e7548cb7345f3b922.zip Qt-33a65a1def8e6d40819ead6e7548cb7345f3b922.tar.gz Qt-33a65a1def8e6d40819ead6e7548cb7345f3b922.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src')
38 files changed, 356 insertions, 263 deletions
diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 49b1cbe..8cb0e53 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -c58dc2f491a824ac56e31c440fcf7fe16dab09c4 +f59a934694947496cedecc5256a71bff60c43c4c diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 1db0c55..fb78e36 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 531b0d7cd2af830f0d17b83b6e4a489794481539 + c58dc2f491a824ac56e31c440fcf7fe16dab09c4 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index daf10fa..ff7d214 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,13 @@ +2010-05-31 Oswald Buddenhagen <oswald.buddenhagen@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Escape backslashes in the .pro files + + qmake in Qt 4.7 warns about unescaped backspaces and deprecates them. + + * WebCore.pro: + 2010-05-28 Antti Koivisto <koivisto@iki.fi> Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 5def728..63e78a7 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -159,7 +159,7 @@ defineTest(addExtraCompiler) { for(file,input) { base = $$basename(file) - base ~= s/\..+// + base ~= s/\\..+// newfile=$$replace(outputRule,\\$\\{QMAKE_FILE_BASE\\},$$base) SOURCES += $$newfile } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro b/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro index 389fb5f..22d4c8d 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro +++ b/src/3rdparty/webkit/WebKit/qt/Api/DerivedSources.pro @@ -28,7 +28,7 @@ qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}define QT_QTWEBKIT_MOD qtheader_module.commands += echo $${QUOTE}$${LITERAL_HASH}include $${ESCAPE}<QtNetwork/QtNetwork$${ESCAPE}>$${QUOTE} >> $${qtheader_module.target} && WEBKIT_CLASS_HEADERS = $${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}$${LITERAL_DOLLAR}PWD/QtWebKit -regex = ".*\sclass\sQWEBKIT_EXPORT\s(\w+)\s(.*)" +regex = ".*\\sclass\\sQWEBKIT_EXPORT\\s(\\w+)\\s(.*)" for(HEADER, WEBKIT_API_HEADERS) { # 1. Append to QtWebKit header that includes all other header files @@ -70,7 +70,7 @@ for(HEADER, WEBKIT_API_HEADERS) { res = $$find(src, $$regex) isEmpty(res):break() - exp = $$replace(src, $$regex, "EXPORTED_CLASS = \1") + exp = $$replace(src, $$regex, "EXPORTED_CLASS = \\1") eval($$exp) CLASS_TARGET = "qtheader_$${EXPORTED_CLASS}" @@ -87,7 +87,7 @@ for(HEADER, WEBKIT_API_HEADERS) { # Qt's QRegExp does not support inline non-greedy matching, # so we'll have to work around it by updating the haystack - src = $$replace(src, $$regex, "\2") + src = $$replace(src, $$regex, "\\2") src_words = $$join(src, $${LITERAL_WHITESPACE}) } } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index a61ca2e..564c6fe 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -3620,7 +3620,7 @@ QString QWebPage::userAgentForUrl(const QUrl&) const languageName = d->client->ownerWidget()->locale().name(); else languageName = QLocale().name(); - languageName[2] = QLatin1Char('-'); + languageName.replace(QLatin1Char('_'), QLatin1Char('-')); // Application name/version QString appName = QCoreApplication::applicationName(); diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index cc2d39a..b6cbf92 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,24 @@ +2010-05-31 Oswald Buddenhagen <oswald.buddenhagen@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Escape backslashes in the .pro files + + qmake in Qt 4.7 warns about unescaped backspaces and deprecates them. + + * Api/DerivedSources.pro: + * docs/docs.pri: + +2010-05-19 Denis Dzyubenko <denis.dzyubenko@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + When creating the UA, do not sassmue the language code is a + two-letter iso639-1 code. + + * Api/qwebpage.cpp: + (QWebPage::userAgentForUrl): + 2010-05-28 Antti Koivisto <koivisto@iki.fi> Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/docs/docs.pri b/src/3rdparty/webkit/WebKit/qt/docs/docs.pri index 804817b..a56ddb4 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/docs.pri +++ b/src/3rdparty/webkit/WebKit/qt/docs/docs.pri @@ -3,7 +3,7 @@ include(../../../WebKit.pri) unix { QDOC = SRCDIR=$$PWD/../../.. OUTPUT_DIR=$$OUTPUT_DIR $$(QTDIR)/bin/qdoc3 } else { - QDOC = $$(QTDIR)\bin\qdoc3.exe + QDOC = $$(QTDIR)\\bin\\qdoc3.exe } unix { diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index c66047a..a333153 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -335,11 +335,6 @@ #define QT_NO_DATESTRING #endif -// QtDBus module -#if !defined(QT_NO_DBUS) && (defined(QT_NO_PROPERTIES)) -#define QT_NO_DBUS -#endif - // QDial #if !defined(QT_NO_DIAL) && (defined(QT_NO_SLIDER)) #define QT_NO_DIAL @@ -515,6 +510,11 @@ #define QT_NO_CONTEXTMENU #endif +// QtDBus module +#if !defined(QT_NO_DBUS) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_DOM)) +#define QT_NO_DBUS +#endif + // File Transfer Protocol #if !defined(QT_NO_FTP) && (defined(QT_NO_URLINFO) || defined(QT_NO_TEXTDATE)) #define QT_NO_FTP diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index ed173b1..3e6af24 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -1373,7 +1373,7 @@ SeeAlso: ??? Feature: DBUS Description: Provides classes for D-Bus. Section: D-Bus -Requires: PROPERTIES +Requires: PROPERTIES DOM Name: QtDBus module SeeAlso: ??? diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index ae12007..853f311 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -560,7 +560,7 @@ void QXmlStreamReader::clear() chunk of XML can be added with addData(), if the XML is being read from a QByteArray, or by waiting for more data to arrive if the XML is being read from a QIODevice. Either way, atEnd() will - return false once more adata is available. + return false once more data is available. \sa hasError(), error(), device(), QIODevice::atEnd() */ diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index 32a6321..a05e426 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -263,7 +263,9 @@ void QDeclarativeAnimatedImage::movieRequestFinished() d->_movie = new QMovie(d->reply); if (!d->_movie->isValid()){ +#ifndef QT_NO_DEBUG_STREAM qmlInfo(this) << "Error Reading Animated Image File " << d->url; +#endif delete d->_movie; d->_movie = 0; return; diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 7bd08ce..134bd6d 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -3131,6 +3131,7 @@ bool QDeclarativeItem::event(QEvent *ev) return QGraphicsObject::event(ev); } +#ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, QDeclarativeItem *item) { if (!item) { @@ -3144,6 +3145,7 @@ QDebug operator<<(QDebug debug, QDeclarativeItem *item) << ", z =" << item->zValue() << ')'; return debug; } +#endif qint64 QDeclarativeItemPrivate::consistentTime = -1; void QDeclarativeItemPrivate::setConsistentTime(qint64 t) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index 29fd241..77e316b 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -209,7 +209,9 @@ T qobject_cast(QGraphicsItem *item) return qobject_cast<T>(o); } +#ifndef QT_NO_DEBUG_STREAM QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, QDeclarativeItem *item); +#endif QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 151a9e9..0be8dac 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -112,9 +112,11 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType<QDeclarativePathPercent>("Qt",4,7,"PathPercent"); qmlRegisterType<QDeclarativePathQuad>("Qt",4,7,"PathQuad"); qmlRegisterType<QDeclarativePathView>("Qt",4,7,"PathView"); +#ifndef QT_NO_VALIDATOR qmlRegisterType<QIntValidator>("Qt",4,7,"IntValidator"); qmlRegisterType<QDoubleValidator>("Qt",4,7,"DoubleValidator"); qmlRegisterType<QRegExpValidator>("Qt",4,7,"RegExpValidator"); +#endif qmlRegisterType<QDeclarativeRectangle>("Qt",4,7,"Rectangle"); qmlRegisterType<QDeclarativeRepeater>("Qt",4,7,"Repeater"); qmlRegisterType<QGraphicsRotation>("Qt",4,7,"Rotation"); @@ -138,7 +140,9 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType<QDeclarativePathElement>(); qmlRegisterType<QDeclarativeCurve>(); qmlRegisterType<QDeclarativeScaleGrid>(); +#ifndef QT_NO_VALIDATOR qmlRegisterType<QValidator>(); +#endif qmlRegisterType<QDeclarativeVisualModel>(); #ifndef QT_NO_ACTION qmlRegisterType<QAction>(); diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index 301ca00..de3dbcd 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -202,8 +202,20 @@ void QDeclarativeRectangle::doUpdate() A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. - To keep the border smooth (rather than blurry), odd widths cause the rectangle to be painted at - a half-pixel offset; + If \c border.width is an odd number, the rectangle is painted at a half-pixel offset to retain + border smoothness. Also, the border is rendered evenly on either side of the + rectangle's boundaries, and the spare pixel is rendered to the right and below the + rectangle (as documented for QRect rendering). This can cause unintended effects if + \c border.width is 1 and the rectangle is \l{clip}{clipped} by a parent item: + + \table + \row + \o \snippet doc/src/snippets/declarative/rect-border-width.qml 0 + \o \image rect-border-width.png + \endtable + + Here, the innermost rectangle's border is clipped on the bottom and right edges by its + parent. To avoid this, the border width can be set to two instead of one. */ QDeclarativePen *QDeclarativeRectangle::border() { diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 04076f8..691cfa2 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -80,14 +80,20 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() The index is always exposed as an accessible \c index property. In the case of an object or string list, the data element (of type string or object) is available as the \c modelData property. In the case of a Qt model, - all roles are available as named properties just like in the view classes. The - following example shows how to use the index property inside the instantiated - items. + all roles are available as named properties just like in the view classes. - \snippet doc/src/snippets/declarative/repeater-index.qml 0 + The following example shows how to use the \c index property inside the instantiated + items: + \snippet doc/src/snippets/declarative/repeater-index.qml 0 \image repeater-index.png + The repeater could also use the \c modelData property to reference the data for a + particular index: + + \snippet doc/src/snippets/declarative/repeater-modeldata.qml 0 + \image repeater-modeldata.png + Items instantiated by the Repeater are inserted, in order, as children of the Repeater's parent. The insertion starts immediately after the repeater's position in its parent stacking list. This is to allow diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 2c1eb67..55cef8b 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -318,7 +318,11 @@ void QDeclarativeText::setText(const QString &n) if (d->richText) { if (isComponentComplete()) { d->ensureDoc(); +#ifndef QT_NO_TEXTHTMLPARSER d->doc->setHtml(n); +#else + d->doc->setPlainText(n); +#endif } } @@ -605,7 +609,11 @@ void QDeclarativeText::setTextFormat(TextFormat format) } else if (!wasRich && d->richText) { if (isComponentComplete()) { d->ensureDoc(); +#ifndef QT_NO_TEXTHTMLPARSER d->doc->setHtml(d->text); +#else + d->doc->setPlainText(d->text); +#endif } d->updateLayout(); d->markImgDirty(); @@ -991,7 +999,11 @@ void QDeclarativeText::reloadWithResources() Q_D(QDeclarativeText); if (!d->richText) return; +#ifndef QT_NO_TEXTHTMLPARSER d->doc->setHtml(d->text); +#else + d->doc->setPlainText(d->text); +#endif d->updateLayout(); d->markImgDirty(); } @@ -1121,7 +1133,11 @@ void QDeclarativeText::componentComplete() if (d->dirty) { if (d->richText) { d->ensureDoc(); +#ifndef QT_NO_TEXTHTMLPARSER d->doc->setHtml(d->text); +#else + d->doc->setPlainText(d->text); +#endif } d->updateLayout(); d->dirty = false; diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index ab5aa63..ffb7dfe 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -127,9 +127,11 @@ QString QDeclarativeTextEdit::text() const { Q_D(const QDeclarativeTextEdit); +#ifndef QT_NO_TEXTHTMLPARSER if (d->richText) return d->document->toHtml(); else +#endif return d->document->toPlainText(); } @@ -260,7 +262,11 @@ void QDeclarativeTextEdit::setText(const QString &text) d->text = text; d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text)); if (d->richText) { +#ifndef QT_NO_TEXTHTMLPARSER d->control->setHtml(text); +#else + d->control->setPlainText(text); +#endif } else { d->control->setPlainText(text); } @@ -325,7 +331,11 @@ void QDeclarativeTextEdit::setTextFormat(TextFormat format) d->control->setPlainText(d->text); updateSize(); } else if (!wasRich && d->richText) { +#ifndef QT_NO_TEXTHTMLPARSER d->control->setHtml(d->text); +#else + d->control->setPlainText(d->text); +#endif updateSize(); } d->format = format; @@ -570,7 +580,7 @@ int QDeclarativeTextEdit::positionAt(int x, int y) const } /*! - \qmlmethod int TextEdit::moveCursorSeletion(int pos) + \qmlmethod int TextEdit::moveCursorSelection(int pos) Moves the cursor to \a position and updates the selection accordingly. (To only move the cursor, set the \l cursorPosition property.) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 25a2b49..7b96c0c 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -641,6 +641,7 @@ void QDeclarativeTextInput::setAutoScroll(bool b) \sa acceptableInput, inputMask */ +#ifndef QT_NO_VALIDATOR QValidator* QDeclarativeTextInput::validator() const { Q_D(const QDeclarativeTextInput); @@ -662,6 +663,7 @@ void QDeclarativeTextInput::setValidator(QValidator* v) emit validatorChanged(); } +#endif // QT_NO_VALIDATOR /*! \qmlproperty string TextInput::inputMask @@ -852,7 +854,7 @@ QRectF QDeclarativeTextInput::positionToRectangle(int x) const int QDeclarativeTextInput::positionAt(int x) const { Q_D(const QDeclarativeTextInput); - return d->control->xToPos(x - d->hscroll); + return d->control->xToPos(x + d->hscroll); } void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index 0b7ddd5..6bc6fc4 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -79,7 +79,9 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextInput : public QDeclarativePaintedIte Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged) Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged) +#ifndef QT_NO_VALIDATOR Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged) +#endif Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged) Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints) @@ -154,9 +156,10 @@ public: int maxLength() const; void setMaxLength(int ml); +#ifndef QT_NO_VALIDATOR QValidator * validator() const; void setValidator(QValidator* v); - +#endif QString inputMask() const; void setInputMask(const QString &im); @@ -248,10 +251,12 @@ private: QT_END_NAMESPACE QML_DECLARE_TYPE(QDeclarativeTextInput) +#ifndef QT_NO_VALIDATOR QML_DECLARE_TYPE(QValidator) QML_DECLARE_TYPE(QIntValidator) QML_DECLARE_TYPE(QDoubleValidator) QML_DECLARE_TYPE(QRegExpValidator) +#endif QT_END_HEADER diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index d27aced..80a1093 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -240,6 +240,7 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop, if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: color expected")); } break; +#ifndef QT_NO_TEXTDATE case QVariant::Date: { bool ok; @@ -261,6 +262,7 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop, if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: datetime expected")); } break; +#endif // QT_NO_TEXTDATE case QVariant::Point: case QVariant::PointF: { @@ -414,6 +416,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop, instr.storeColor.value = c.rgba(); } break; +#ifndef QT_NO_TEXTDATE case QVariant::Date: { QDate d = QDeclarativeStringConverters::dateFromString(string); @@ -447,6 +450,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop, instr.storeDateTime.valueIndex = index; } break; +#endif // QT_NO_TEXTDATE case QVariant::Point: case QVariant::PointF: { diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 8679e76..39b0802 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -155,14 +155,26 @@ void QDeclarativeEnginePrivate::defineModule() \qmlclass Qt QDeclarativeEnginePrivate \brief The QML global Qt object provides useful enums and functions from Qt. -The Qt object provides useful enums and functions from Qt, for use in all QML files. +The \c Qt object provides useful enums and functions from Qt, for use in all QML files. + +The \c Qt object is not a QML element; it cannot be instantiated. It is a global object +with enums and functions. To use it, call the members of the global \c Qt object directly. +For example: + +\qml +import Qt 4.7 + +Text { + color: Qt.rgba(255, 0, 0, 1) + text: Qt.md5("hello, world") +} +\endqml -You do not create instances of this type, but instead use the members of the global "Qt" object. \section1 Enums The Qt object contains all enums in the Qt namespace. For example, you can -access the AlignLeft member of the Qt::AlignmentFlag enum with \c Qt.AlignLeft. +access the \c AlignLeft member of the \c Qt::AlignmentFlag enum with \c Qt.AlignLeft. For a full list of enums, see the \l{Qt Namespace} documentation. @@ -172,7 +184,7 @@ data types. This is primarily useful when setting the properties of an item when the property has one of the following types: \list -\o \c color - use \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()} +\o \c color - use \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::hsla()}{Qt.hsla()}, \l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()} \o \c rect - use \l{Qt::rect()}{Qt.rect()} \o \c point - use \l{Qt::point()}{Qt.point()} \o \c size - use \l{Qt::size()}{Qt.size()} @@ -200,8 +212,8 @@ items from files or strings. See \l{Dynamic Object Management} for an overview of their use. \list - \o \l{Qt::createComponent}{object Qt.createComponent(url)} - \o \l{Qt::createQmlObject}{object Qt.createQmlObject(string qml, object parent, string filepath)} + \o \l{Qt::createComponent()}{object Qt.createComponent(url)} + \o \l{Qt::createQmlObject()}{object Qt.createQmlObject(string qml, object parent, string filepath)} \endlist */ @@ -284,10 +296,12 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr qtObject.setProperty(QLatin1String("tint"), newFunction(QDeclarativeEnginePrivate::tint, 2)); } +#ifndef QT_NO_TEXTDATE //date/time formatting qtObject.setProperty(QLatin1String("formatDate"),newFunction(QDeclarativeEnginePrivate::formatDate, 2)); qtObject.setProperty(QLatin1String("formatTime"),newFunction(QDeclarativeEnginePrivate::formatTime, 2)); qtObject.setProperty(QLatin1String("formatDateTime"),newFunction(QDeclarativeEnginePrivate::formatDateTime, 2)); +#endif //misc methods qtObject.setProperty(QLatin1String("openUrlExternally"),newFunction(QDeclarativeEnginePrivate::desktopOpenUrl, 1)); @@ -1034,7 +1048,7 @@ QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url) /*! \qmlmethod object Qt::createComponent(url) -Returns a \l Component object created from the QML file at the specified \a url, +Returns a \l Component object created using the QML file at the specified \a url, or \c null if there was an error in creating the component. Call \l {Component::createObject()}{Component.createObject()} on the returned @@ -1219,6 +1233,7 @@ QScriptValue QDeclarativeEnginePrivate::vector3d(QScriptContext *ctxt, QScriptEn \qmlmethod string Qt::formatDate(datetime date, variant format) Returns the string representation of \c date, formatted according to \c format. */ +#ifndef QT_NO_TEXTDATE QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine) { int argCount = ctxt->argumentCount(); @@ -1356,11 +1371,12 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); } +#endif // QT_NO_TEXTDATE /*! \qmlmethod color Qt::rgba(real red, real green, real blue, real alpha) -Returns a Color with the specified \c red, \c green, \c blue and \c alpha components. +Returns a color with the specified \c red, \c green, \c blue and \c alpha components. All components should be in the range 0-1 inclusive. */ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine) @@ -1388,7 +1404,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine /*! \qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha) -Returns a Color with the specified \c hue, \c saturation, \c lightness and \c alpha components. +Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components. All components should be in the range 0-1 inclusive. */ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine *engine) @@ -1416,7 +1432,9 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine /*! \qmlmethod rect Qt::rect(int x, int y, int width, int height) -Returns a Rect with the top-left corner at \c x, \c y and the specified \c width and \c height. +Returns a \c rect with the top-left corner at \c x, \c y and the specified \c width and \c height. + +The returned object has \c x, \c y, \c width and \c height attributes with the given values. */ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine) { diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 804476c..3269e98 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -302,10 +302,11 @@ public: static QScriptValue consoleLog(QScriptContext*, QScriptEngine*); static QScriptValue quit(QScriptContext*, QScriptEngine*); +#ifndef QT_NO_TEXTDATE static QScriptValue formatDate(QScriptContext*, QScriptEngine*); static QScriptValue formatTime(QScriptContext*, QScriptEngine*); static QScriptValue formatDateTime(QScriptContext*, QScriptEngine*); - +#endif static QScriptEngine *getScriptEngine(QDeclarativeEngine *e) { return &e->d_func()->scriptEngine; } static QDeclarativeEngine *getEngine(QScriptEngine *e) { return static_cast<QDeclarativeScriptEngine*>(e)->p->q_func(); } static QDeclarativeEnginePrivate *get(QDeclarativeEngine *e) { return e->d_func(); } diff --git a/src/declarative/qml/qdeclarativeinfo.h b/src/declarative/qml/qdeclarativeinfo.h index 2ac28f4..b41abd8 100644 --- a/src/declarative/qml/qdeclarativeinfo.h +++ b/src/declarative/qml/qdeclarativeinfo.h @@ -81,7 +81,9 @@ public: inline QDeclarativeInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; } inline QDeclarativeInfo &operator<<(QTextStreamFunction f) { QDebug::operator<<(f); return *this; } inline QDeclarativeInfo &operator<<(QTextStreamManipulator m) { QDebug::operator<<(m); return *this; } +#ifndef QT_NO_DEBUG_STREAM inline QDeclarativeInfo &operator<<(const QUrl &t) { static_cast<QDebug &>(*this) << t; return *this; } +#endif private: friend Q_DECLARATIVE_EXPORT QDeclarativeInfo qmlInfo(const QObject *me); diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp index b86d082..0f7b09d 100644 --- a/src/declarative/qml/qdeclarativeinstruction.cpp +++ b/src/declarative/qml/qdeclarativeinstruction.cpp @@ -49,6 +49,10 @@ QT_BEGIN_NAMESPACE void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx) { +#ifdef QT_NO_DEBUG_STREAM + Q_UNUSED(instr) + Q_UNUSED(idx) +#else QByteArray lineNumber = QByteArray::number(instr->line); if (instr->line == (unsigned short)-1) lineNumber = "NA"; @@ -217,6 +221,7 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx) qWarning().nospace() << idx << "\t\t" << line << "\t" << "XXX UNKOWN INSTRUCTION" << "\t" << instr->type; break; } +#endif // QT_NO_DEBUG_STREAM } QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp index bbcc00b..8bd2cf1 100644 --- a/src/declarative/qml/qdeclarativestringconverters.cpp +++ b/src/declarative/qml/qdeclarativestringconverters.cpp @@ -106,12 +106,14 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s, int p return QVariant(uint(qRound(s.toDouble(ok)))); case QMetaType::QColor: return QVariant::fromValue(colorFromString(s, ok)); +#ifndef QT_NO_TEXTDATE case QMetaType::QDate: return QVariant::fromValue(dateFromString(s, ok)); case QMetaType::QTime: return QVariant::fromValue(timeFromString(s, ok)); case QMetaType::QDateTime: return QVariant::fromValue(dateTimeFromString(s, ok)); +#endif // QT_NO_TEXTDATE case QMetaType::QPointF: return QVariant::fromValue(pointFFromString(s, ok)); case QMetaType::QPoint: @@ -150,6 +152,7 @@ QColor QDeclarativeStringConverters::colorFromString(const QString &s, bool *ok) } } +#ifndef QT_NO_TEXTDATE QDate QDeclarativeStringConverters::dateFromString(const QString &s, bool *ok) { QDate d = QDate::fromString(s, Qt::ISODate); @@ -170,6 +173,7 @@ QDateTime QDeclarativeStringConverters::dateTimeFromString(const QString &s, boo if (ok) *ok = d.isValid(); return d; } +#endif // QT_NO_TEXTDATE //expects input of "x,y" QPointF QDeclarativeStringConverters::pointFFromString(const QString &s, bool *ok) diff --git a/src/declarative/qml/qdeclarativestringconverters_p.h b/src/declarative/qml/qdeclarativestringconverters_p.h index 97f72fc..842d1b3 100644 --- a/src/declarative/qml/qdeclarativestringconverters_p.h +++ b/src/declarative/qml/qdeclarativestringconverters_p.h @@ -73,9 +73,11 @@ namespace QDeclarativeStringConverters QVariant Q_DECLARATIVE_EXPORT variantFromString(const QString &, int preferredType, bool *ok = 0); QColor Q_DECLARATIVE_EXPORT colorFromString(const QString &, bool *ok = 0); +#ifndef QT_NO_TEXTDATE QDate Q_DECLARATIVE_EXPORT dateFromString(const QString &, bool *ok = 0); QTime Q_DECLARATIVE_EXPORT timeFromString(const QString &, bool *ok = 0); QDateTime Q_DECLARATIVE_EXPORT dateTimeFromString(const QString &, bool *ok = 0); +#endif QPointF Q_DECLARATIVE_EXPORT pointFFromString(const QString &, bool *ok = 0); QSizeF Q_DECLARATIVE_EXPORT sizeFFromString(const QString &, bool *ok = 0); QRectF Q_DECLARATIVE_EXPORT rectFFromString(const QString &, bool *ok = 0); diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index b5f7900..dc2b2cc 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -486,6 +486,7 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit // All the local reverts now become part of the ongoing revertList d->revertList << additionalReverts; +#ifndef QT_NO_DEBUG_STREAM // Output for debugging if (stateChangeDebug()) { foreach(const QDeclarativeAction &action, applyList) { @@ -497,6 +498,7 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit << "To:" << action.toValue; } } +#endif d->transitionManager.transition(applyList, trans); } diff --git a/src/declarative/util/qdeclarativetransitionmanager.cpp b/src/declarative/util/qdeclarativetransitionmanager.cpp index 368d484..9f198e4 100644 --- a/src/declarative/util/qdeclarativetransitionmanager.cpp +++ b/src/declarative/util/qdeclarativetransitionmanager.cpp @@ -233,6 +233,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> & action.property.write(action.toValue); } } +#ifndef QT_NO_DEBUG_STREAM if (stateChangeDebug()) { foreach(const QDeclarativeAction &action, applyList) { if (action.event) @@ -243,6 +244,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> & << "To:" << action.toValue; } } +#endif if (!transition) d->applyBindings(); } diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index b57615c..77f8fc0 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -253,7 +253,9 @@ Qt::DropAction QDrag::exec(Qt::DropActions supportedActions) can take some time, but this function does not block the event loop. Other events are still delivered to the application while the operation is performed. On Windows, the Qt event loop is - blocked while during the operation. + blocked during the operation. However, QDrag::exec() on + Windows causes processEvents() to be called frequently to keep the GUI responsive. + If any loops or operations are called while a drag operation is active, it will block the drag operation. */ Qt::DropAction QDrag::exec(Qt::DropActions supportedActions, Qt::DropAction defaultDropAction) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index ce7915d..3f67408 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -858,7 +858,8 @@ QRectF QTextLayout::boundingRect() const const QScriptLine &si = d->lines[i]; xmin = qMin(xmin, si.x); ymin = qMin(ymin, si.y); - xmax = qMax(xmax, si.x+qMax(si.width, si.textWidth)); + QFixed lineWidth = si.width < QFIXED_MAX ? qMax(si.width, si.textWidth) : si.textWidth; + xmax = qMax(xmax, si.x+lineWidth); // ### shouldn't the ascent be used in ymin??? ymax = qMax(ymax, si.y+si.height()); } diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index 555df3c..1ec6106 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -53,7 +53,9 @@ public: virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel")); +#ifndef QT_NO_DIRMODEL qmlRegisterType<QDeclarativeFolderListModel>(uri,1,0,"FolderListModel"); +#endif } }; //![class decl] diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp index fccb9d4..9cf81ca 100644 --- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp @@ -45,6 +45,8 @@ #include <QDebug> #include <qdeclarativecontext.h> +#ifndef QT_NO_DIRMODEL + QT_BEGIN_NAMESPACE class QDeclarativeFolderListModelPrivate @@ -397,3 +399,5 @@ void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) //![code] QT_END_NAMESPACE + +#endif // QT_NO_DIRMODEL diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h index ea7d701..1bab5f84 100644 --- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h @@ -47,6 +47,8 @@ #include <QUrl> #include <QAbstractListModel> +#ifndef QT_NO_DIRMODEL + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -152,4 +154,6 @@ QML_DECLARE_TYPE(QDeclarativeFolderListModel) QT_END_HEADER +#endif // QT_NO_DIRMODEL + #endif // QDECLARATIVEFOLDERLISTMODEL_H diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 3cd18fb..e08d135 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -122,19 +122,10 @@ void QNetworkSessionPrivateImpl::configurationRemoved(QNetworkConfigurationPriva if (!publicConfig.isValid()) return; - SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(config); - - symbianConfig->mutex.lock(); - TUint32 configNumericId = symbianConfig->numericId; - symbianConfig->mutex.unlock(); - - symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - TUint32 publicNumericId = symbianConfig->numericId; - symbianConfig->mutex.unlock(); + TUint32 publicNumericId = + toSymbianConfig(privateConfiguration(publicConfig))->numericIdentifier(); - if (configNumericId == publicNumericId) { + if (toSymbianConfig(config)->numericIdentifier() == publicNumericId) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "configurationRemoved IAP: " << QString::number(publicNumericId) << " : going to State: Invalid"; @@ -380,13 +371,11 @@ void QNetworkSessionPrivateImpl::open() SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); - QMutexLocker configLocker(&symbianConfig->mutex); - - if (connInfo().iIapId == symbianConfig->numericId) { + if (connInfo().iIapId == symbianConfig->numericIdentifier()) { if (iConnection.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { activeConfig = publicConfig; #ifndef QT_NO_NETWORKINTERFACE - activeInterface = interface(symbianConfig->numericId); + activeInterface = interface(symbianConfig->numericIdentifier()); #endif connected = ETrue; startTime = QDateTime::currentDateTime(); @@ -416,9 +405,7 @@ void QNetworkSessionPrivateImpl::open() TConnPrefList pref; TExtendedConnPref prefs; - symbianConfig->mutex.lock(); - prefs.SetIapId(symbianConfig->numericId); - symbianConfig->mutex.unlock(); + prefs.SetIapId(symbianConfig->numericIdentifier()); if (iConnectInBackground) { prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent ); } @@ -427,9 +414,7 @@ void QNetworkSessionPrivateImpl::open() TCommDbConnPref pref; pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); - symbianConfig->mutex.lock(); - pref.SetIapId(symbianConfig->numericId); - symbianConfig->mutex.unlock(); + pref.SetIapId(symbianConfig->numericIdentifier()); #endif iConnection.Start(pref, iStatus); if (!IsActive()) { @@ -444,17 +429,13 @@ void QNetworkSessionPrivateImpl::open() #ifdef OCC_FUNCTIONALITY_AVAILABLE TConnPrefList snapPref; TExtendedConnPref prefs; - symbianConfig->mutex.lock(); - prefs.SetSnapId(symbianConfig->numericId); - symbianConfig->mutex.unlock(); + prefs.SetSnapId(symbianConfig->numericIdentifier()); if (iConnectInBackground) { prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent ); } snapPref.AppendL(&prefs); #else - symbianConfig->mutex.lock(); - TConnSnapPref snapPref(symbianConfig->numericId); - symbianConfig->mutex.unlock(); + TConnSnapPref snapPref(symbianConfig->numericIdentifier()); #endif iConnection.Start(snapPref, iStatus); if (!IsActive()) { @@ -592,10 +573,8 @@ void QNetworkSessionPrivateImpl::stop() SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); - QMutexLocker configLocker(&symbianConfig->mutex); - // See if connection Id matches with our Id. If so, stop() it. - if (symbianConfig->connectionId == connectionId) { + if (symbianConfig->connectionIdentifier() == connectionId) { ret = iConnectionMonitor.SetBoolAttribute(connectionId, 0, // subConnectionId don't care KConnectionStop, @@ -715,12 +694,8 @@ void QNetworkSessionPrivateImpl::PreferredCarrierAvailable(TAccessPointInfo aOld SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(configs[i])); - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->numericId == aNewAPInfo.AccessPoint()) { - configLocker.unlock(); + if (symbianConfig->numericIdentifier() == aNewAPInfo.AccessPoint()) emit preferredConfigurationChanged(configs[i], aIsSeamless); - } } } else { migrate(); @@ -854,9 +829,7 @@ quint64 QNetworkSessionPrivateImpl::transferredData(TUint dataType) const SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(configs[i])); - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->numericId == apId) { + if (symbianConfig->numericIdentifier() == apId) { configFound = true; break; } @@ -865,10 +838,8 @@ quint64 QNetworkSessionPrivateImpl::transferredData(TUint dataType) const SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(config)); - symbianConfig->mutex.lock(); - if (symbianConfig->numericId == apId) + if (symbianConfig->numericIdentifier() == apId) configFound = true; - symbianConfig->mutex.unlock(); } if (configFound) { TUint tData; @@ -908,8 +879,7 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia SymbianNetworkConfigurationPrivate *childConfig = toSymbianConfig(privateConfiguration(children[i])); - QMutexLocker childLocker(&childConfig->mutex); - if (childConfig->numericId == iapId) + if (childConfig->numericIdentifier() == iapId) return children[i]; } @@ -928,15 +898,11 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(pt)); if (symbianConfig) { - QMutexLocker configLocker(&symbianConfig->mutex); - for (int i=0; i < children.count(); i++) { SymbianNetworkConfigurationPrivate *childConfig = toSymbianConfig(privateConfiguration(children[i])); - QMutexLocker childLocker(&childConfig->mutex); - - if (childConfig->mappingName == symbianConfig->mappingName) { + if (childConfig->configMappingName() == symbianConfig->configMappingName()) { return children[i]; } } @@ -1034,15 +1000,13 @@ void QNetworkSessionPrivateImpl::RunL() SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(activeConfig)); - symbianConfig->mutex.lock(); #ifndef QT_NO_NETWORKINTERFACE - activeInterface = interface(symbianConfig->numericId); + activeInterface = interface(symbianConfig->numericIdentifier()); #endif if (publicConfig.type() == QNetworkConfiguration::UserChoice) { serviceConfig = QNetworkConfigurationManager() - .configurationFromIdentifier(symbianConfig->id); + .configurationFromIdentifier(activeConfig.identifier()); } - symbianConfig->mutex.unlock(); startTime = QDateTime::currentDateTime(); @@ -1105,13 +1069,11 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint newState == QNetworkSession::Connected) { activeConfig = activeConfiguration(accessPointId); +#ifndef QT_NO_NETWORKINTERFACE SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(activeConfig)); -#ifndef QT_NO_NETWORKINTERFACE - symbianConfig->mutex.lock(); - activeInterface = interface(symbianConfig->numericId); - symbianConfig->mutex.unlock(); + activeInterface = interface(symbianConfig->numericIdentifier()); #endif #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -1187,10 +1149,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); - QMutexLocker configLocker(&symbianConfig->mutex); - if (symbianConfig->numericId == accessPointId) { - configLocker.unlock(); - + if (symbianConfig->numericIdentifier() == accessPointId) { state = newState; #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed B to: " << state; @@ -1202,10 +1161,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(activeConfig)); - QMutexLocker configLocker(&symbianConfig->mutex); - if (symbianConfig->numericId == accessPointId) { - configLocker.unlock(); - + if (symbianConfig->numericIdentifier() == accessPointId) { state = newState; #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed C to: " << state; @@ -1219,9 +1175,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(subConfigurations[i])); - QMutexLocker configLocker(&symbianConfig->mutex); - - if (symbianConfig->numericId == accessPointId) { + if (symbianConfig->numericIdentifier() == accessPointId) { if (newState != QNetworkSession::Disconnected) { state = newState; #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG @@ -1234,8 +1188,6 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if ((config.state() == QNetworkConfiguration::Defined) || (config.state() == QNetworkConfiguration::Discovered)) { - configLocker.unlock(); - state = newState; #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed E to: " << state; @@ -1271,9 +1223,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); - symbianConfig->mutex.lock(); - iDeprecatedConnectionId = symbianConfig->connectionId; - symbianConfig->mutex.unlock(); + iDeprecatedConnectionId = symbianConfig->connectionIdentifier(); } return retVal; @@ -1369,7 +1319,11 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "reporting disconnection to manager."; #endif if (publicConfig.isValid()) { - engine->configurationStateChangeReport(toSymbianConfig(privateConfiguration(publicConfig))->numericId, QNetworkSession::Disconnected); + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + engine->configurationStateChangeReport(symbianConfig->numericIdentifier(), + QNetworkSession::Disconnected); } break; // Unhandled state diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index cea8b67..8c26cf0 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -115,13 +115,18 @@ QString SymbianNetworkConfigurationPrivate::bearerName() const SymbianEngine::SymbianEngine(QObject *parent) : QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true), - iIgnoringUpdates(false), iTimeToWait(0), iIgnoreEventLoop(0) + iIgnoringUpdates(false) { +} + +void SymbianEngine::initialize() +{ + QMutexLocker locker(&mutex); + CActiveScheduler::Add(this); // Seed the randomgenerator qsrand(QTime(0,0,0).secsTo(QTime::currentTime()) + QCoreApplication::applicationPid()); - iIgnoreEventLoop = new QEventLoop(this); TRAPD(error, ipCommsDB = CCommsDatabase::NewL(EDatabaseTypeIAP)); if (error != KErrNone) { @@ -132,18 +137,13 @@ SymbianEngine::SymbianEngine(QObject *parent) TRAP_IGNORE(iConnectionMonitor.ConnectL()); TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); -#ifdef SNAP_FUNCTIONALITY_AVAILABLE +#ifdef SNAP_FUNCTIONALITY_AVAILABLE TRAP(error, iCmManager.OpenL()); if (error != KErrNone) { iInitOk = false; return; } #endif -} - -void SymbianEngine::initialize() -{ - QMutexLocker locker(&mutex); SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; cpPriv->name = "UserChoice"; @@ -238,19 +238,14 @@ void SymbianEngine::requestUpdate() void SymbianEngine::updateConfigurations() { - QMutexLocker locker(&mutex); - - if (!iInitOk) { + if (!iInitOk) return; - } TRAP_IGNORE(updateConfigurationsL()); } void SymbianEngine::updateConfigurationsL() { - QMutexLocker locker(&mutex); - QList<QString> knownConfigs = accessPointConfigurations.keys(); QList<QString> knownSnapConfigs = snapConfigurations.keys(); @@ -276,9 +271,9 @@ void SymbianEngine::updateConfigurationsL() QNetworkConfigurationPrivatePointer ptr(cpPriv); accessPointConfigurations.insert(ptr->id, ptr); - locker.unlock(); + mutex.unlock(); emit configurationAdded(ptr); - locker.relock(); + mutex.lock(); } } CleanupStack::PopAndDestroy(&connectionMethod); @@ -317,9 +312,9 @@ void SymbianEngine::updateConfigurationsL() QNetworkConfigurationPrivatePointer ptr(cpPriv); snapConfigurations.insert(ident, ptr); - locker.unlock(); + mutex.unlock(); emit configurationAdded(ptr); - locker.relock(); + mutex.lock(); CleanupStack::Pop(cpPriv); } @@ -338,34 +333,35 @@ void SymbianEngine::updateConfigurationsL() TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); if (error == KErrNone) { QNetworkConfigurationPrivatePointer ptr(cpPriv); - toSymbianConfig(ptr)->serviceNetworkPtr = privSNAP; accessPointConfigurations.insert(ptr->id, ptr); - locker.unlock(); + mutex.unlock(); emit configurationAdded(ptr); - locker.relock(); + mutex.lock(); + QMutexLocker configLocker(&privSNAP->mutex); privSNAP->serviceNetworkMembers.append(ptr); } } else { knownConfigs.removeOne(iface); // Check that IAP can be found from related SNAP's configuration list bool iapFound = false; + QMutexLocker snapConfigLocker(&privSNAP->mutex); for (int i = 0; i < privSNAP->serviceNetworkMembers.count(); i++) { - if (toSymbianConfig(privSNAP->serviceNetworkMembers[i])->numericId == iapId) { + if (toSymbianConfig(privSNAP->serviceNetworkMembers[i])->numericIdentifier() == + iapId) { iapFound = true; break; } } - if (!iapFound) { - toSymbianConfig(priv)->serviceNetworkPtr = privSNAP; + if (!iapFound) privSNAP->serviceNetworkMembers.append(priv); - } } CleanupStack::PopAndDestroy(&connectionMethod); } + QMutexLocker snapConfigLocker(&privSNAP->mutex); if (privSNAP->serviceNetworkMembers.count() > 1) { // Roaming is supported only if SNAP contains more than one IAP privSNAP->roamingSupported = true; @@ -410,17 +406,18 @@ void SymbianEngine::updateConfigurationsL() //remove non existing IAP QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(oldIface); - locker.unlock(); + mutex.unlock(); emit configurationRemoved(ptr); - locker.relock(); + mutex.lock(); // Remove non existing IAP from SNAPs foreach (const QString &iface, snapConfigurations.keys()) { QNetworkConfigurationPrivatePointer ptr2 = snapConfigurations.value(iface); // => Check if one of the IAPs of the SNAP is active + QMutexLocker snapConfigLocker(&ptr2->mutex); for (int i = 0; i < ptr2->serviceNetworkMembers.count(); ++i) { - if (toSymbianConfig(ptr2->serviceNetworkMembers[i])->numericId == - toSymbianConfig(ptr)->numericId) { + if (toSymbianConfig(ptr2->serviceNetworkMembers[i])->numericIdentifier() == + toSymbianConfig(ptr)->numericIdentifier()) { ptr2->serviceNetworkMembers.removeAt(i); break; } @@ -432,18 +429,21 @@ void SymbianEngine::updateConfigurationsL() //remove non existing SNAPs QNetworkConfigurationPrivatePointer ptr = snapConfigurations.take(oldIface); - locker.unlock(); + mutex.unlock(); emit configurationRemoved(ptr); - locker.relock(); + mutex.lock(); } + + // find default configuration. + stopCommsDatabaseNotifications(); + TRAP_IGNORE(defaultConfig = defaultConfigurationL()); + startCommsDatabaseNotifications(); } #ifdef SNAP_FUNCTIONALITY_AVAILABLE SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( RCmConnectionMethod& connectionMethod) { - QMutexLocker locker(&mutex); - SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; CleanupStack::PushL(cpPriv); @@ -526,8 +526,6 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( bool SymbianEngine::readNetworkConfigurationValuesFromCommsDb( TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration) { - QMutexLocker locker(&mutex); - TRAPD(error, readNetworkConfigurationValuesFromCommsDbL(aApId,apNetworkConfiguration)); if (error != KErrNone) { return false; @@ -538,8 +536,6 @@ bool SymbianEngine::readNetworkConfigurationValuesFromCommsDb( void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration) { - QMutexLocker locker(&mutex); - CApDataHandler* pDataHandler = CApDataHandler::NewLC(*ipCommsDB); CApAccessPointItem* pAPItem = CApAccessPointItem::NewLC(); TBuf<KCommsDbSvrMaxColumnNameLength> name; @@ -602,15 +598,7 @@ QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfiguration() { QMutexLocker locker(&mutex); - QNetworkConfigurationPrivatePointer ptr; - - if (iInitOk) { - stopCommsDatabaseNotifications(); - TRAP_IGNORE(ptr = defaultConfigurationL()); - startCommsDatabaseNotifications(); - } - - return ptr; + return defaultConfig; } QStringList SymbianEngine::accessPointConfigurationIdentifiers() @@ -622,8 +610,6 @@ QStringList SymbianEngine::accessPointConfigurationIdentifiers() QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL() { - QMutexLocker locker(&mutex); - QNetworkConfigurationPrivatePointer ptr; #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -639,18 +625,18 @@ QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL() } #endif - if (!ptr || !ptr->isValid) { - QString iface = QString::number(qHash(KUserChoiceIAPId)); - ptr = userChoiceConfigurations.value(iface); + if (ptr) { + QMutexLocker configLocker(&ptr->mutex); + if (ptr->isValid) + return ptr; } - - return ptr; + + QString iface = QString::number(qHash(KUserChoiceIAPId)); + return userChoiceConfigurations.value(iface); } void SymbianEngine::updateActiveAccessPoints() { - QMutexLocker locker(&mutex); - bool online = false; QList<QString> inactiveConfigs = accessPointConfigurations.keys(); @@ -681,8 +667,9 @@ void SymbianEngine::updateActiveAccessPoints() online = true; inactiveConfigs.removeOne(ident); - QMutexLocker configLocker(&ptr->mutex); + ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; + ptr->mutex.unlock(); // Configuration is Active changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); @@ -702,16 +689,14 @@ void SymbianEngine::updateActiveAccessPoints() if (iOnline != online) { iOnline = online; - locker.unlock(); + mutex.unlock(); emit this->onlineStateChanged(iOnline); - locker.relock(); + mutex.lock(); } } void SymbianEngine::updateAvailableAccessPoints() { - QMutexLocker locker(&mutex); - if (!ipAccessPointsAvailabilityScanner) { ipAccessPointsAvailabilityScanner = new AccessPointsAvailabilityScanner(*this, iConnectionMonitor); } @@ -723,8 +708,6 @@ void SymbianEngine::updateAvailableAccessPoints() void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo) { - QMutexLocker locker(&mutex); - iUpdateGoingOn = false; if (scanSuccessful) { QList<QString> unavailableConfigs = accessPointConfigurations.keys(); @@ -736,6 +719,8 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { unavailableConfigs.removeOne(ident); + + QMutexLocker configLocker(&ptr->mutex); if (ptr->state < QNetworkConfiguration::Active) { // Configuration is either Discovered or Active changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered); @@ -757,25 +742,28 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn if (!iFirstUpdate) { startCommsDatabaseNotifications(); - locker.unlock(); + mutex.unlock(); emit updateCompleted(); - locker.relock(); + mutex.lock(); } } void SymbianEngine::updateStatesToSnaps() { - QMutexLocker locker(&mutex); - // Go through SNAPs and set correct state to SNAPs foreach (const QString &iface, snapConfigurations.keys()) { bool discovered = false; bool active = false; QNetworkConfigurationPrivatePointer ptr = snapConfigurations.value(iface); + + QMutexLocker snapConfigLocker(&ptr->mutex); + // => Check if one of the IAPs of the SNAP is discovered or active // => If one of IAPs is active, also SNAP is active // => If one of IAPs is discovered but none of the IAPs is active, SNAP is discovered for (int i=0; i<ptr->serviceNetworkMembers.count(); i++) { + QMutexLocker configLocker(&ptr->serviceNetworkMembers[i]->mutex); + if ((ptr->serviceNetworkMembers[i]->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { active = true; @@ -798,16 +786,14 @@ void SymbianEngine::updateStatesToSnaps() bool SymbianEngine::changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState) { - QMutexLocker locker(&mutex); - ptr->mutex.lock(); if (newState != ptr->state) { ptr->state = newState; ptr->mutex.unlock(); - locker.unlock(); + mutex.unlock(); emit configurationChanged(ptr); - locker.relock(); + mutex.lock(); return true; } else { @@ -823,16 +809,14 @@ bool SymbianEngine::changeConfigurationStateTo(QNetworkConfigurationPrivatePoint bool SymbianEngine::changeConfigurationStateAtMinTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState) { - QMutexLocker locker(&mutex); - ptr->mutex.lock(); if ((newState | ptr->state) != ptr->state) { ptr->state = (ptr->state | newState); ptr->mutex.unlock(); - locker.unlock(); + mutex.unlock(); emit configurationChanged(ptr); - locker.relock(); + mutex.lock(); return true; } else { @@ -849,16 +833,14 @@ bool SymbianEngine::changeConfigurationStateAtMinTo(QNetworkConfigurationPrivate bool SymbianEngine::changeConfigurationStateAtMaxTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState) { - QMutexLocker locker(&mutex); - ptr->mutex.lock(); if ((newState & ptr->state) != ptr->state) { ptr->state = (newState & ptr->state); ptr->mutex.unlock(); - locker.unlock(); + mutex.unlock(); emit configurationChanged(ptr); - locker.relock(); + mutex.lock(); return true; } else { @@ -869,8 +851,6 @@ bool SymbianEngine::changeConfigurationStateAtMaxTo(QNetworkConfigurationPrivate void SymbianEngine::startCommsDatabaseNotifications() { - QMutexLocker locker(&mutex); - if (!iWaitingCommsDatabaseNotifications) { iWaitingCommsDatabaseNotifications = ETrue; if (!IsActive()) { @@ -883,19 +863,9 @@ void SymbianEngine::startCommsDatabaseNotifications() void SymbianEngine::stopCommsDatabaseNotifications() { - QMutexLocker locker(&mutex); - if (iWaitingCommsDatabaseNotifications) { iWaitingCommsDatabaseNotifications = EFalse; - if (!IsActive()) { - SetActive(); - // Make sure that notifier recorded events will not be returned - // as soon as the client issues the next RequestNotification() request. - ipCommsDB->RequestNotification(iStatus); - ipCommsDB->CancelRequestNotification(); - } else { - ipCommsDB->CancelRequestNotification(); - } + Cancel(); } } @@ -910,46 +880,48 @@ void SymbianEngine::RunL() return; } - if (iStatus != KErrCancel) { - RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); + RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); - switch (event) { - case RDbNotifier::EUnlock: /** All read locks have been removed. */ - case RDbNotifier::ECommit: /** A transaction has been committed. */ - case RDbNotifier::ERollback: /** A transaction has been rolled back */ - case RDbNotifier::ERecover: /** The database has been recovered */ + switch (event) { + case RDbNotifier::EUnlock: /** All read locks have been removed. */ + case RDbNotifier::ECommit: /** A transaction has been committed. */ + case RDbNotifier::ERollback: /** A transaction has been rolled back */ + case RDbNotifier::ERecover: /** The database has been recovered */ #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); + qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); #endif - iIgnoringUpdates = true; - // Other events than ECommit get lower priority. In practice with those events, - // we delay_before_updating methods, whereas - // with ECommit we _update_before_delaying the reaction to next event. - // Few important notes: 1) listening to only ECommit does not seem to be adequate, - // but updates will be missed. Hence other events are reacted upon too. - // 2) RDbNotifier records the most significant event, and that will be returned once - // we issue new RequestNotification, and hence updates will not be missed even - // when we are 'not reacting to them' for few seconds. - if (event == RDbNotifier::ECommit) { - TRAPD(error, updateConfigurationsL()); - if (error == KErrNone) { - updateStatesToSnaps(); - } - waitRandomTime(); - } else { - waitRandomTime(); - TRAPD(error, updateConfigurationsL()); - if (error == KErrNone) { - updateStatesToSnaps(); - } + iIgnoringUpdates = true; + // Other events than ECommit get lower priority. In practice with those events, + // we delay_before_updating methods, whereas + // with ECommit we _update_before_delaying the reaction to next event. + // Few important notes: 1) listening to only ECommit does not seem to be adequate, + // but updates will be missed. Hence other events are reacted upon too. + // 2) RDbNotifier records the most significant event, and that will be returned once + // we issue new RequestNotification, and hence updates will not be missed even + // when we are 'not reacting to them' for few seconds. + if (event == RDbNotifier::ECommit) { + TRAPD(error, updateConfigurationsL()); + if (error == KErrNone) { + updateStatesToSnaps(); + } + locker.unlock(); + waitRandomTime(); + locker.relock(); + } else { + locker.unlock(); + waitRandomTime(); + locker.relock(); + TRAPD(error, updateConfigurationsL()); + if (error == KErrNone) { + updateStatesToSnaps(); } - iIgnoringUpdates = false; // Wait time done, allow updating again - iWaitingCommsDatabaseNotifications = true; - break; - default: - // Do nothing - break; } + iIgnoringUpdates = false; // Wait time done, allow updating again + iWaitingCommsDatabaseNotifications = true; + break; + default: + // Do nothing + break; } if (iWaitingCommsDatabaseNotifications) { @@ -991,9 +963,11 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QString ident = QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { - QMutexLocker configLocker(&ptr->mutex); + ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; - emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Connecting); + ptr->mutex.unlock(); + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Connecting); } } else if (connectionStatus == KLinkLayerOpen) { // Connection has been successfully opened @@ -1006,13 +980,17 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QString ident = QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { - QMutexLocker configLocker(&ptr->mutex); + ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; + ptr->mutex.unlock(); + // Configuration is Active if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) { updateStatesToSnaps(); } - emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Connected); + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Connected); + if (!iOnline) { iOnline = true; emit this->onlineStateChanged(iOnline); @@ -1022,8 +1000,8 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TUint connectionId = realEvent->ConnectionId(); QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); if (ptr) { - QMutexLocker configLocker(&ptr->mutex); - emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Closing); + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Closing); } } else if (connectionStatus == KLinkLayerClosed || connectionStatus == KConnectionClosed) { @@ -1037,8 +1015,8 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) updateStatesToSnaps(); } - QMutexLocker configLocker(&ptr->mutex); - emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, connectionId, QNetworkSession::Disconnected); + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Disconnected); } bool online = false; @@ -1121,6 +1099,8 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) // manager). Currently only 'Disconnected' state is of interest because it has proven to be troublesome. void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetworkSession::State newState) { + QMutexLocker locker(&mutex); + #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNCM A session reported state change for IAP ID: " << accessPointId << " whose new state is: " << newState; #endif @@ -1135,10 +1115,11 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo updateStatesToSnaps(); } - QMutexLocker configLocker(&ptr->mutex); - emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, - toSymbianConfig(ptr)->connectionId, - QNetworkSession::Disconnected); + locker.unlock(); + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + toSymbianConfig(ptr)->connectionIdentifier(), + QNetworkSession::Disconnected); + locker.relock(); } } break; @@ -1150,28 +1131,23 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo // Waits for 2..6 seconds. void SymbianEngine::waitRandomTime() { - iTimeToWait = (qAbs(qrand()) % 7) * 1000; - if (iTimeToWait < 2000) { - iTimeToWait = 2000; - } + int iTimeToWait = qMax(2000, (qAbs(qrand()) % 7) * 1000); #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug("QNCM waiting random time: %d ms", iTimeToWait); #endif - QTimer::singleShot(iTimeToWait, iIgnoreEventLoop, SLOT(quit())); - iIgnoreEventLoop->exec(); + QEventLoop loop; + QTimer::singleShot(iTimeToWait, &loop, SLOT(quit())); + loop.exec(); } QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aConnectionId) { - QMutexLocker locker(&mutex); - QNetworkConfiguration item; QHash<QString, QNetworkConfigurationPrivatePointer>::const_iterator i = accessPointConfigurations.constBegin(); while (i != accessPointConfigurations.constEnd()) { QNetworkConfigurationPrivatePointer ptr = i.value(); - QMutexLocker configLocker(&ptr->mutex); - if (toSymbianConfig(ptr)->connectionId == aConnectionId) + if (toSymbianConfig(ptr)->connectionIdentifier() == aConnectionId) return ptr; ++i; @@ -1218,6 +1194,8 @@ void AccessPointsAvailabilityScanner::StartScanning() void AccessPointsAvailabilityScanner::RunL() { + QMutexLocker locker(&iOwner.mutex); + if (iStatus.Int() != KErrNone) { iIapBuf().iCount = 0; iOwner.accessPointScanningReady(false,iIapBuf()); diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 7d565db..18fd249 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -87,7 +87,23 @@ public: QString bearerName() const; - QNetworkConfigurationPrivatePointer serviceNetworkPtr; + inline TUint32 numericIdentifier() const + { + QMutexLocker locker(&mutex); + return numericId; + } + + inline TUint connectionIdentifier() const + { + QMutexLocker locker(&mutex); + return connectionId; + } + + inline QString configMappingName() const + { + QMutexLocker locker(&mutex); + return mappingName; + } QString mappingName; @@ -196,11 +212,11 @@ private: // Data TBool iInitOk; TBool iUpdateGoingOn; TBool iIgnoringUpdates; - TUint iTimeToWait; - QEventLoop* iIgnoreEventLoop; AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner; - + + QNetworkConfigurationPrivatePointer defaultConfig; + friend class QNetworkSessionPrivate; friend class AccessPointsAvailabilityScanner; friend class QNetworkSessionPrivateImpl; |