From 7944ac1fb6eb0ae3bbbfdf6780b52f7174174a93 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 26 Feb 2010 15:22:02 +1000 Subject: check that wifi is powered on before trying to scan. also fix crash and remove useless warning messages. Alex --- src/plugins/bearer/corewlan/qcorewlanengine.mm | 122 ++++++++++++------------- 1 file changed, 59 insertions(+), 63 deletions(-) diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index a5384d1..9a28a33 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -154,9 +154,9 @@ void QCoreWlanEngine::connectToId(const QString &id) NSDictionary *parametersDict; NSArray* apArray; - CW8021XProfile *user8021XProfile; - NSError *err; - NSMutableDictionary *params; + CW8021XProfile *user8021XProfile; + NSError *err; + NSMutableDictionary *params; while ((wProfile = [enumerator nextObject])) { //CWWirelessProfile @@ -185,10 +185,8 @@ void QCoreWlanEngine::connectToId(const QString &id) bool result = [wifiInterface associateToNetwork: apNetwork parameters:[NSDictionary dictionaryWithDictionary:params] error:&err]; if(!result) { - qWarning() <<"ERROR"<< nsstringToQString([err localizedDescription ]); emit connectionError(id, ConnectError); } else { - [apNetwork release]; [autoreleasepool release]; return; } @@ -350,83 +348,81 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName) NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; CWInterface *currentInterface = [CWInterface interfaceWithName:qstringToNSString(interfaceName)]; - NSError *err = nil; - NSDictionary *parametersDict = nil; - NSArray* apArray = [currentInterface scanForNetworksWithParameters:parametersDict error:&err]; + if([currentInterface power]) { + NSError *err = nil; + NSDictionary *parametersDict = nil; + NSArray* apArray = [currentInterface scanForNetworksWithParameters:parametersDict error:&err]; - CWNetwork *apNetwork; - if (!err) { - for(uint row=0; row < [apArray count]; row++ ) { - NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init]; + CWNetwork *apNetwork; + if (!err) { + for(uint row=0; row < [apArray count]; row++ ) { + NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init]; - apNetwork = [apArray objectAtIndex:row]; + apNetwork = [apArray objectAtIndex:row]; - const QString networkSsid = nsstringToQString([apNetwork ssid]); + const QString networkSsid = nsstringToQString([apNetwork ssid]); - const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid)); - found.append(id); + const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid)); + found.append(id); - QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; + QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; - if ([currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) { - if (networkSsid == nsstringToQString([currentInterface ssid])) - state = QNetworkConfiguration::Active; - } else { - if (isKnownSsid(interfaceName, networkSsid)) - state = QNetworkConfiguration::Discovered; - else - state = QNetworkConfiguration::Defined; - } + if ([currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) { + if (networkSsid == nsstringToQString([currentInterface ssid])) + state = QNetworkConfiguration::Active; + } else { + if (isKnownSsid(interfaceName, networkSsid)) + state = QNetworkConfiguration::Discovered; + else + state = QNetworkConfiguration::Defined; + } - if (accessPointConfigurations.contains(id)) { - QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + if (accessPointConfigurations.contains(id)) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); - bool changed = false; + bool changed = false; - if (!ptr->isValid) { - ptr->isValid = true; - changed = true; - } + if (!ptr->isValid) { + ptr->isValid = true; + changed = true; + } - if (ptr->name != networkSsid) { - ptr->name = networkSsid; - changed = true; - } + if (ptr->name != networkSsid) { + ptr->name = networkSsid; + changed = true; + } - if (ptr->id != id) { - ptr->id = id; - changed = true; - } + if (ptr->id != id) { + ptr->id = id; + changed = true; + } - if (ptr->state != state) { - ptr->state = state; - changed = true; - } + if (ptr->state != state) { + ptr->state = state; + changed = true; + } - if (changed) - emit configurationChanged(ptr); - } else { - QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); + if (changed) + emit configurationChanged(ptr); + } else { + QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); - ptr->name = networkSsid; - ptr->isValid = true; - ptr->id = id; - ptr->state = state; - ptr->type = QNetworkConfiguration::InternetAccessPoint; - ptr->bearer = QLatin1String("WLAN"); + ptr->name = networkSsid; + ptr->isValid = true; + ptr->id = id; + ptr->state = state; + ptr->type = QNetworkConfiguration::InternetAccessPoint; + ptr->bearer = QLatin1String("WLAN"); - accessPointConfigurations.insert(id, ptr); - configurationInterface.insert(id, interfaceName); + accessPointConfigurations.insert(id, ptr); + configurationInterface.insert(id, interfaceName); - emit configurationAdded(ptr); + emit configurationAdded(ptr); + } + [looppool release]; } - [looppool release]; } - } else { - qWarning() << "ERROR scanning for ssids" << nsstringToQString([err localizedDescription]) - < Date: Fri, 26 Feb 2010 09:43:43 +0100 Subject: doc: Added \since 4.7 to several \qmlclass elements. --- .../graphicsitems/qmlgraphicseffects.cpp | 4 ++++ .../graphicsitems/qmlgraphicsevents.cpp | 1 + .../graphicsitems/qmlgraphicsflickable.cpp | 1 + .../graphicsitems/qmlgraphicsgridview.cpp | 1 + src/declarative/qml/qmlscript.cpp | 1 + src/declarative/util/qmlanimation.cpp | 23 +++++++++++----------- src/declarative/util/qmlbehavior.cpp | 1 + src/declarative/util/qmleasefollow.cpp | 1 + src/declarative/util/qmlfontloader.cpp | 1 + src/declarative/util/qmllistmodel.cpp | 2 ++ src/declarative/util/qmlspringfollow.cpp | 1 + src/declarative/util/qmlstategroup.cpp | 1 + src/declarative/util/qmlstateoperations.cpp | 3 +++ src/declarative/util/qmlsystempalette.cpp | 1 + src/declarative/util/qmltimer.cpp | 1 + src/multimedia/qml/qmlaudio.cpp | 1 + src/multimedia/qml/qmlgraphicsvideo.cpp | 1 + src/multimedia/qml/qsoundeffect.cpp | 1 + tools/qdoc3/node.cpp | 8 ++++++++ tools/qdoc3/node.h | 2 +- 20 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicseffects.cpp b/src/declarative/graphicsitems/qmlgraphicseffects.cpp index 6a93b12..8cd4e6f 100644 --- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp +++ b/src/declarative/graphicsitems/qmlgraphicseffects.cpp @@ -45,6 +45,7 @@ /*! \qmlclass Blur QGraphicsBlurEffect + \since 4.7 \brief The Blur object provides a blur effect. A blur effect blurs the source item. This effect is useful for reducing details; @@ -80,6 +81,7 @@ /*! \qmlclass Colorize QGraphicsColorizeEffect + \since 4.7 \brief The Colorize object provides a colorize effect. A colorize effect renders the source item with a tint of its color. @@ -106,6 +108,7 @@ /*! \qmlclass DropShadow QGraphicsDropShadowEffect + \since 4.7 \brief The DropShadow object provides a drop shadow effect. A drop shadow effect renders the source item with a drop shadow. The color of @@ -147,6 +150,7 @@ /*! \qmlclass Opacity QGraphicsOpacityEffect + \since 4.7 \brief The Opacity object provides an opacity effect. An opacity effect renders the source with an opacity. This effect is useful diff --git a/src/declarative/graphicsitems/qmlgraphicsevents.cpp b/src/declarative/graphicsitems/qmlgraphicsevents.cpp index e8ba885..1fb5cd0 100644 --- a/src/declarative/graphicsitems/qmlgraphicsevents.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsevents.cpp @@ -114,6 +114,7 @@ Item { /*! \qmlclass MouseEvent QmlGraphicsMouseEvent + \since 4.7 \brief The MouseEvent object provides information about a mouse event. The position of the mouse can be found via the x and y properties. diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index e92fea4..6933890 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -336,6 +336,7 @@ void QmlGraphicsFlickablePrivate::updateBeginningEnd() /*! \qmlclass Flickable QmlGraphicsFlickable + \since 4.7 \brief The Flickable item provides a surface that can be "flicked". \inherits Item diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index bf370ae..e54ed8e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -675,6 +675,7 @@ void QmlGraphicsGridViewPrivate::updateCurrent(int modelIndex) /*! \qmlclass GridView QmlGraphicsGridView + \since 4.7 \inherits Flickable \brief The GridView item provides a grid view of items provided by a model. diff --git a/src/declarative/qml/qmlscript.cpp b/src/declarative/qml/qmlscript.cpp index ef142a5..ef8bb93 100644 --- a/src/declarative/qml/qmlscript.cpp +++ b/src/declarative/qml/qmlscript.cpp @@ -43,6 +43,7 @@ /*! \qmlclass Script QmlScript + \since 4.7 \brief The Script element provides a way to add JavaScript code snippets in QML. \ingroup group_utility diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 1be95df..e8a920a 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -143,7 +143,7 @@ QML_DEFINE_NOCREATE_TYPE(QmlAbstractAnimation) /*! \qmlclass Animation QmlAbstractAnimation - \since 4.7 + \since 4.7 \brief The Animation element is the base of all QML animations. The Animation element cannot be used directly in a QML file. It exists @@ -590,7 +590,7 @@ void QmlAbstractAnimation::timelineComplete() /*! \qmlclass PauseAnimation QmlPauseAnimation - \since 4.7 + \since 4.7 \inherits Animation \brief The PauseAnimation element provides a pause for an animation. @@ -664,7 +664,7 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() /*! \qmlclass ColorAnimation QmlColorAnimation - \since 4.7 + \since 4.7 \inherits PropertyAnimation \brief The ColorAnimation element allows you to animate color changes. @@ -728,7 +728,7 @@ QML_DEFINE_TYPE(Qt,4,6,ColorAnimation,QmlColorAnimation) /*! \qmlclass ScriptAction QmlScriptAction - \since 4.7 + \since 4.7 \inherits Animation \brief The ScriptAction element allows scripts to be run during an animation. @@ -835,7 +835,7 @@ QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction) /*! \qmlclass PropertyAction QmlPropertyAction - \since 4.7 + \since 4.7 \inherits Animation \brief The PropertyAction element allows immediate property changes during animation. @@ -1084,7 +1084,7 @@ QML_DEFINE_TYPE(Qt,4,6,PropertyAction,QmlPropertyAction) /*! \qmlclass ParentAction QmlParentAction - \since 4.7 + \since 4.7 \inherits Animation \brief The ParentAction element allows parent changes during animation. @@ -1288,7 +1288,7 @@ QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction) /*! \qmlclass NumberAnimation QmlNumberAnimation - \since 4.7 + \since 4.7 \inherits PropertyAnimation \brief The NumberAnimation element allows you to animate changes in properties of type qreal. @@ -1352,7 +1352,7 @@ QML_DEFINE_TYPE(Qt,4,6,NumberAnimation,QmlNumberAnimation) /*! \qmlclass Vector3dAnimation QmlVector3dAnimation - \since 4.7 + \since 4.7 \inherits PropertyAnimation \brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d. */ @@ -1411,6 +1411,7 @@ QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation) /*! \qmlclass RotationAnimation QmlRotationAnimation + \since 4.7 \inherits PropertyAnimation \brief The RotationAnimation element allows you to animate rotations. @@ -1619,7 +1620,7 @@ QmlListProperty QmlAnimationGroup::animations() /*! \qmlclass SequentialAnimation QmlSequentialAnimation - \since 4.7 + \since 4.7 \inherits Animation \brief The SequentialAnimation element allows you to run animations sequentially. @@ -1680,7 +1681,7 @@ QML_DEFINE_TYPE(Qt,4,6,SequentialAnimation,QmlSequentialAnimation) /*! \qmlclass ParallelAnimation QmlParallelAnimation - \since 4.7 + \since 4.7 \inherits Animation \brief The ParallelAnimation element allows you to run animations in parallel. @@ -1789,7 +1790,7 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) /*! \qmlclass PropertyAnimation QmlPropertyAnimation - \since 4.7 + \since 4.7 \inherits Animation \brief The PropertyAnimation element allows you to animate property changes. diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp index d65d8cd..6d397c0 100644 --- a/src/declarative/util/qmlbehavior.cpp +++ b/src/declarative/util/qmlbehavior.cpp @@ -69,6 +69,7 @@ public: /*! \qmlclass Behavior QmlBehavior + \since 4.7 \brief The Behavior element allows you to specify a default animation for a property change. Behaviors provide one way to specify \l{qmlanimation.html}{animations} in QML. diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp index deb474a..214f6f6 100644 --- a/src/declarative/util/qmleasefollow.cpp +++ b/src/declarative/util/qmleasefollow.cpp @@ -251,6 +251,7 @@ void QmlEaseFollowPrivate::tick(int t) /*! \qmlclass EaseFollow QmlEaseFollow + \since 4.7 \brief The EaseFollow element allows a property to smoothly track a value. The EaseFollow smoothly animates a property's value to a set target value diff --git a/src/declarative/util/qmlfontloader.cpp b/src/declarative/util/qmlfontloader.cpp index 4599b99..52110d3 100644 --- a/src/declarative/util/qmlfontloader.cpp +++ b/src/declarative/util/qmlfontloader.cpp @@ -74,6 +74,7 @@ QML_DEFINE_TYPE(Qt,4,6,FontLoader,QmlFontLoader) /*! \qmlclass FontLoader QmlFontLoader + \since 4.7 \ingroup group_utility \brief This item allows using fonts by name or url. diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 8fda3ae..6958b18 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -78,6 +78,7 @@ static void dump(ModelNode *node, int ind); /*! \qmlclass ListModel QmlListModel + \since 4.7 \brief The ListModel element defines a free-form list data source. The ListModel is a simple hierarchy of elements containing data roles. The contents can @@ -957,6 +958,7 @@ QML_DEFINE_CUSTOM_TYPE(Qt, 4,6, ListModel, QmlListModel, QmlListModelParser) /*! \qmlclass ListElement + \since 4.7 \brief The ListElement element defines a data item in a ListModel. \sa ListModel diff --git a/src/declarative/util/qmlspringfollow.cpp b/src/declarative/util/qmlspringfollow.cpp index 6d4ecf2..b180d1e 100644 --- a/src/declarative/util/qmlspringfollow.cpp +++ b/src/declarative/util/qmlspringfollow.cpp @@ -213,6 +213,7 @@ void QmlSpringFollowPrivate::stop() /*! \qmlclass SpringFollow QmlSpringFollow + \since 4.7 \brief The SpringFollow element allows a property to track a value. In example below, \e rect2 will follow \e rect1 moving with a velocity of up to 200: diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 4ad77c8..7e6dc58 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -84,6 +84,7 @@ public: /*! \qmlclass StateGroup QmlStateGroup + \since 4.7 \brief The StateGroup element provides state support for non-Item elements. Item (and all dervied elements) provides built in support for states and transitions diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index bd1f5f0..5f06045 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -147,6 +147,7 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics /*! \preliminary \qmlclass ParentChange QmlParentChange + \since 4.7 \brief The ParentChange element allows you to reparent an Item in a state change. ParentChange reparents an Item while preserving its visual appearance (position, rotation, @@ -316,6 +317,7 @@ public: /*! \qmlclass StateChangeScript QmlStateChangeScript + \since 4.7 \brief The StateChangeScript element allows you to run a script in a state. The script specified will be run immediately when the state is made current. @@ -394,6 +396,7 @@ QString QmlStateChangeScript::typeName() const /*! \qmlclass AnchorChanges QmlAnchorChanges + \since 4.7 \brief The AnchorChanges element allows you to change the anchors of an item in a state. In the following example we change the top and bottom anchors of an item: diff --git a/src/declarative/util/qmlsystempalette.cpp b/src/declarative/util/qmlsystempalette.cpp index cc4fb3e..4e78518 100644 --- a/src/declarative/util/qmlsystempalette.cpp +++ b/src/declarative/util/qmlsystempalette.cpp @@ -58,6 +58,7 @@ QML_DEFINE_TYPE(Qt,4,6,SystemPalette,QmlSystemPalette) /*! \qmlclass SystemPalette QmlSystemPalette + \since 4.7 \ingroup group_utility \brief The SystemPalette item gives access to the Qt palettes. \sa QPalette diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index d3a1a7c..1779b22 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -70,6 +70,7 @@ public: /*! \qmlclass Timer QmlTimer + \since 4.7 \brief The Timer item triggers a handler at a specified interval. A timer can be used to trigger an action either once, or repeatedly diff --git a/src/multimedia/qml/qmlaudio.cpp b/src/multimedia/qml/qmlaudio.cpp index 89f045e..80f5678 100644 --- a/src/multimedia/qml/qmlaudio.cpp +++ b/src/multimedia/qml/qmlaudio.cpp @@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass Audio QmlAudio + \since 4.7 \brief The Audio element allows you to add audio playback to a scene. \qml diff --git a/src/multimedia/qml/qmlgraphicsvideo.cpp b/src/multimedia/qml/qmlgraphicsvideo.cpp index 7289f4d..baf96ba 100644 --- a/src/multimedia/qml/qmlgraphicsvideo.cpp +++ b/src/multimedia/qml/qmlgraphicsvideo.cpp @@ -69,6 +69,7 @@ void QmlGraphicsVideo::_q_error(int errorCode, const QString &errorString) /*! \qmlclass Video QmlGraphicsVideo + \since 4.7 \brief The Video element allows you to add videos to a scene. \inherits Item diff --git a/src/multimedia/qml/qsoundeffect.cpp b/src/multimedia/qml/qsoundeffect.cpp index 919aa75..541e6c9 100644 --- a/src/multimedia/qml/qsoundeffect.cpp +++ b/src/multimedia/qml/qsoundeffect.cpp @@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE /*! \qmlclass SoundEffect QSoundEffect + \since 4.7 \brief The SoundEffect element provides a way to play sound effects in qml. The following example plays a wav file on mouse click. diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 5357597..83014d3 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -1275,6 +1275,14 @@ QmlClassNode::QmlClassNode(InnerNode *parent, } /*! + I made this so I could print a debug message here. + */ +QmlClassNode::~QmlClassNode() +{ + qDebug() << "Deleting QmlClassNode:" << name(); +} + +/*! The base file name for this kind of node has "qml_" prepended to it. diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index 3798e4e..fd39698 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -379,7 +379,7 @@ class QmlClassNode : public FakeNode QmlClassNode(InnerNode *parent, const QString& name, const ClassNode* cn); - virtual ~QmlClassNode() { } + virtual ~QmlClassNode(); const ClassNode* classNode() const { return cnode; } virtual QString fileBase() const; -- cgit v0.12 From 9e040eb916f01b78331560722f50cb41bb7f8d4c Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 26 Feb 2010 13:03:57 +0100 Subject: Doc: summarize new QtMultimedia functionality in What's New page. --- doc/src/qt4-intro.qdoc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index a18bc13..cf53df0 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -483,7 +483,14 @@ QNetworkAccessManager uses this API for HTTP level roaming. - \section1 Multimedia - playback and playlist management + \section1 Multimedia - playback and declarative elements + + The Multimedia API provides media playback and playlist support + for Qt Applications. Play music and movies through a single interface + with selectable output for movies to widgets or graphics view. + + Multimedia support for Quick is also available with the new multimedia + declarative elements. \section1 New Classes, Functions, Macros, etc. -- cgit v0.12 From 5601e13aa10ad616a3dd9ba263bc14e4c7e39dfb Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Fri, 26 Feb 2010 13:26:18 +0100 Subject: Modified configure script not to override $XPLATFORM in case of CYGWIN Reviewed-by: Thiago Macieira --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 87551fa..a25dee1 100755 --- a/configure +++ b/configure @@ -2407,7 +2407,9 @@ if [ "$CFG_EMBEDDED" != "no" ]; then fi ;; CYGWIN*:*) - CFG_EMBEDDED=x86 + if [ -z "$XPLATFORM" ]; then + CFG_EMBEDDED=x86 + fi ;; *) echo "Qt for Embedded Linux is not supported on this platform. Disabling." -- cgit v0.12 From 68c02d299f0e423582d34169b3d4597d179a53a2 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 26 Feb 2010 14:07:54 +0100 Subject: Add benchmarks for QMetaType type introspection functions Reviewed-by: Harald Fernengel --- tests/benchmarks/corelib/kernel/kernel.pro | 1 + .../corelib/kernel/qmetatype/qmetatype.pro | 7 + .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 233 +++++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro create mode 100644 tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp diff --git a/tests/benchmarks/corelib/kernel/kernel.pro b/tests/benchmarks/corelib/kernel/kernel.pro index 91cf3c5..da3f0d6 100644 --- a/tests/benchmarks/corelib/kernel/kernel.pro +++ b/tests/benchmarks/corelib/kernel/kernel.pro @@ -2,5 +2,6 @@ TEMPLATE = subdirs SUBDIRS = \ events \ qmetaobject \ + qmetatype \ qobject \ qvariant diff --git a/tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro b/tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro new file mode 100644 index 0000000..80f9a2a --- /dev/null +++ b/tests/benchmarks/corelib/kernel/qmetatype/qmetatype.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +QT = core +TEMPLATE = app +TARGET = tst_qmetatype + +SOURCES += tst_qmetatype.cpp + diff --git a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp new file mode 100644 index 0000000..c3324df --- /dev/null +++ b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +//TESTED_FILES= + +class tst_QMetaType : public QObject +{ + Q_OBJECT + +public: + tst_QMetaType(); + virtual ~tst_QMetaType(); + +private slots: + void typeBuiltin_data(); + void typeBuiltin(); + void typeBuiltinNotNormalized_data(); + void typeBuiltinNotNormalized(); + void typeCustom(); + void typeCustomNotNormalized(); + void typeNotRegistered(); + void typeNotRegisteredNotNormalized(); + + void typeNameBuiltin_data(); + void typeNameBuiltin(); + void typeNameCustom(); + void typeNameNotRegistered(); + + void isRegisteredBuiltin_data(); + void isRegisteredBuiltin(); + void isRegisteredCustom(); + void isRegisteredNotRegistered(); +}; + +tst_QMetaType::tst_QMetaType() +{ +} + +tst_QMetaType::~tst_QMetaType() +{ +} + +void tst_QMetaType::typeBuiltin_data() +{ + QTest::addColumn("typeName"); + for (int i = 0; i < QMetaType::User; ++i) { + const char *name = QMetaType::typeName(i); + if (name) + QTest::newRow(name) << QByteArray(name); + } +} + +void tst_QMetaType::typeBuiltin() +{ + QFETCH(QByteArray, typeName); + const char *nm = typeName.constData(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + QMetaType::type(nm); + } +} + +void tst_QMetaType::typeBuiltinNotNormalized_data() +{ + QTest::addColumn("typeName"); + for (int i = 0; i < QMetaType::User; ++i) { + const char *name = QMetaType::typeName(i); + if (name) + QTest::newRow(name) << QByteArray(name).append(" "); + } +} + +void tst_QMetaType::typeBuiltinNotNormalized() +{ + QFETCH(QByteArray, typeName); + const char *nm = typeName.constData(); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + QMetaType::type(nm); + } +} + +struct Foo { int i; }; + +void tst_QMetaType::typeCustom() +{ + qRegisterMetaType("Foo"); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + QMetaType::type("Foo"); + } +} + +void tst_QMetaType::typeCustomNotNormalized() +{ + qRegisterMetaType("Foo"); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + QMetaType::type("Foo "); + } +} + +void tst_QMetaType::typeNotRegistered() +{ + Q_ASSERT(QMetaType::type("Bar") == 0); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + QMetaType::type("Bar"); + } +} + +void tst_QMetaType::typeNotRegisteredNotNormalized() +{ + Q_ASSERT(QMetaType::type("Bar") == 0); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + QMetaType::type("Bar "); + } +} + +void tst_QMetaType::typeNameBuiltin_data() +{ + QTest::addColumn("type"); + for (int i = 0; i < QMetaType::User; ++i) { + const char *name = QMetaType::typeName(i); + if (name) + QTest::newRow(name) << i; + } +} + +void tst_QMetaType::typeNameBuiltin() +{ + QFETCH(int, type); + QBENCHMARK { + for (int i = 0; i < 500000; ++i) + QMetaType::typeName(type); + } +} + +void tst_QMetaType::typeNameCustom() +{ + int type = qRegisterMetaType("Foo"); + QBENCHMARK { + for (int i = 0; i < 100000; ++i) + QMetaType::typeName(type); + } +} + +void tst_QMetaType::typeNameNotRegistered() +{ + // We don't care much about this case, but test it anyway. + Q_ASSERT(QMetaType::typeName(-1) == 0); + QBENCHMARK { + for (int i = 0; i < 500000; ++i) + QMetaType::typeName(-1); + } +} + +void tst_QMetaType::isRegisteredBuiltin_data() +{ + typeNameBuiltin_data(); +} + +void tst_QMetaType::isRegisteredBuiltin() +{ + QFETCH(int, type); + QBENCHMARK { + for (int i = 0; i < 500000; ++i) + QMetaType::isRegistered(type); + } +} + +void tst_QMetaType::isRegisteredCustom() +{ + int type = qRegisterMetaType("Foo"); + QBENCHMARK { + for (int i = 0; i < 100000; ++i) + QMetaType::isRegistered(type); + } +} + +void tst_QMetaType::isRegisteredNotRegistered() +{ + Q_ASSERT(QMetaType::typeName(-1) == 0); + QBENCHMARK { + for (int i = 0; i < 100000; ++i) + QMetaType::isRegistered(-1); + } +} + +QTEST_MAIN(tst_QMetaType) +#include "tst_qmetatype.moc" -- cgit v0.12 From 7ce54e9cc4b35d16c32f4dfc5875038797731f2f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 26 Feb 2010 14:13:41 +0100 Subject: Improve lookup speed of QMetaType::type() for normalized types Two improvements are made: 1) Store the length of the built-in types to avoid calling strcmp() when there's no way the types will match; and 2) Speculate on the input already being normalized. When the type name is already in normalized form (which we believe to be the common case), normalizing is wasteful (allocating a bytearray that's going to contain exactly the same string as the original input). Use the same pattern as used in QObject::connect(), which speculates on the signature already being normalized; only if the lookup fails, the signature is normalized and looked up again. For the QMetaType::builtinTypes benchmark, this improves performance by roughly 4x. For the QMetaType::builtinTypesNotNormalized benchmark, the performance is half of that before, because the lookup is done twice. But we choose to optimize for the already-normalized case. This makes a big difference in the QtScript QObject bindings, for example. Reviewed-by: Harald Fernengel --- src/corelib/kernel/qmetatype.cpp | 197 ++++++++++++++++++++------------------- 1 file changed, 103 insertions(+), 94 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 870baab..bfc3e28 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -223,100 +223,103 @@ QT_BEGIN_NAMESPACE \sa Q_DECLARE_METATYPE(), QVariant::setValue(), QVariant::value(), QVariant::fromValue() */ +#define QT_ADD_STATIC_METATYPE(STR, TP) \ + { STR, sizeof(STR) - 1, TP } + /* Note: these MUST be in the order of the enums */ -static const struct { const char * typeName; int type; } types[] = { +static const struct { const char * typeName; int typeNameLength; int type; } types[] = { /* All Core types */ - {"void", QMetaType::Void}, - {"bool", QMetaType::Bool}, - {"int", QMetaType::Int}, - {"uint", QMetaType::UInt}, - {"qlonglong", QMetaType::LongLong}, - {"qulonglong", QMetaType::ULongLong}, - {"double", QMetaType::Double}, - {"QChar", QMetaType::QChar}, - {"QVariantMap", QMetaType::QVariantMap}, - {"QVariantList", QMetaType::QVariantList}, - {"QString", QMetaType::QString}, - {"QStringList", QMetaType::QStringList}, - {"QByteArray", QMetaType::QByteArray}, - {"QBitArray", QMetaType::QBitArray}, - {"QDate", QMetaType::QDate}, - {"QTime", QMetaType::QTime}, - {"QDateTime", QMetaType::QDateTime}, - {"QUrl", QMetaType::QUrl}, - {"QLocale", QMetaType::QLocale}, - {"QRect", QMetaType::QRect}, - {"QRectF", QMetaType::QRectF}, - {"QSize", QMetaType::QSize}, - {"QSizeF", QMetaType::QSizeF}, - {"QLine", QMetaType::QLine}, - {"QLineF", QMetaType::QLineF}, - {"QPoint", QMetaType::QPoint}, - {"QPointF", QMetaType::QPointF}, - {"QRegExp", QMetaType::QRegExp}, - {"QVariantHash", QMetaType::QVariantHash}, + QT_ADD_STATIC_METATYPE("void", QMetaType::Void), + QT_ADD_STATIC_METATYPE("bool", QMetaType::Bool), + QT_ADD_STATIC_METATYPE("int", QMetaType::Int), + QT_ADD_STATIC_METATYPE("uint", QMetaType::UInt), + QT_ADD_STATIC_METATYPE("qlonglong", QMetaType::LongLong), + QT_ADD_STATIC_METATYPE("qulonglong", QMetaType::ULongLong), + QT_ADD_STATIC_METATYPE("double", QMetaType::Double), + QT_ADD_STATIC_METATYPE("QChar", QMetaType::QChar), + QT_ADD_STATIC_METATYPE("QVariantMap", QMetaType::QVariantMap), + QT_ADD_STATIC_METATYPE("QVariantList", QMetaType::QVariantList), + QT_ADD_STATIC_METATYPE("QString", QMetaType::QString), + QT_ADD_STATIC_METATYPE("QStringList", QMetaType::QStringList), + QT_ADD_STATIC_METATYPE("QByteArray", QMetaType::QByteArray), + QT_ADD_STATIC_METATYPE("QBitArray", QMetaType::QBitArray), + QT_ADD_STATIC_METATYPE("QDate", QMetaType::QDate), + QT_ADD_STATIC_METATYPE("QTime", QMetaType::QTime), + QT_ADD_STATIC_METATYPE("QDateTime", QMetaType::QDateTime), + QT_ADD_STATIC_METATYPE("QUrl", QMetaType::QUrl), + QT_ADD_STATIC_METATYPE("QLocale", QMetaType::QLocale), + QT_ADD_STATIC_METATYPE("QRect", QMetaType::QRect), + QT_ADD_STATIC_METATYPE("QRectF", QMetaType::QRectF), + QT_ADD_STATIC_METATYPE("QSize", QMetaType::QSize), + QT_ADD_STATIC_METATYPE("QSizeF", QMetaType::QSizeF), + QT_ADD_STATIC_METATYPE("QLine", QMetaType::QLine), + QT_ADD_STATIC_METATYPE("QLineF", QMetaType::QLineF), + QT_ADD_STATIC_METATYPE("QPoint", QMetaType::QPoint), + QT_ADD_STATIC_METATYPE("QPointF", QMetaType::QPointF), + QT_ADD_STATIC_METATYPE("QRegExp", QMetaType::QRegExp), + QT_ADD_STATIC_METATYPE("QVariantHash", QMetaType::QVariantHash), /* All GUI types */ - {"QColorGroup", 63}, - {"QFont", QMetaType::QFont}, - {"QPixmap", QMetaType::QPixmap}, - {"QBrush", QMetaType::QBrush}, - {"QColor", QMetaType::QColor}, - {"QPalette", QMetaType::QPalette}, - {"QIcon", QMetaType::QIcon}, - {"QImage", QMetaType::QImage}, - {"QPolygon", QMetaType::QPolygon}, - {"QRegion", QMetaType::QRegion}, - {"QBitmap", QMetaType::QBitmap}, - {"QCursor", QMetaType::QCursor}, - {"QSizePolicy", QMetaType::QSizePolicy}, - {"QKeySequence", QMetaType::QKeySequence}, - {"QPen", QMetaType::QPen}, - {"QTextLength", QMetaType::QTextLength}, - {"QTextFormat", QMetaType::QTextFormat}, - {"QMatrix", QMetaType::QMatrix}, - {"QTransform", QMetaType::QTransform}, - {"QMatrix4x4", QMetaType::QMatrix4x4}, - {"QVector2D", QMetaType::QVector2D}, - {"QVector3D", QMetaType::QVector3D}, - {"QVector4D", QMetaType::QVector4D}, - {"QQuaternion", QMetaType::QQuaternion}, + QT_ADD_STATIC_METATYPE("QColorGroup", 63), + QT_ADD_STATIC_METATYPE("QFont", QMetaType::QFont), + QT_ADD_STATIC_METATYPE("QPixmap", QMetaType::QPixmap), + QT_ADD_STATIC_METATYPE("QBrush", QMetaType::QBrush), + QT_ADD_STATIC_METATYPE("QColor", QMetaType::QColor), + QT_ADD_STATIC_METATYPE("QPalette", QMetaType::QPalette), + QT_ADD_STATIC_METATYPE("QIcon", QMetaType::QIcon), + QT_ADD_STATIC_METATYPE("QImage", QMetaType::QImage), + QT_ADD_STATIC_METATYPE("QPolygon", QMetaType::QPolygon), + QT_ADD_STATIC_METATYPE("QRegion", QMetaType::QRegion), + QT_ADD_STATIC_METATYPE("QBitmap", QMetaType::QBitmap), + QT_ADD_STATIC_METATYPE("QCursor", QMetaType::QCursor), + QT_ADD_STATIC_METATYPE("QSizePolicy", QMetaType::QSizePolicy), + QT_ADD_STATIC_METATYPE("QKeySequence", QMetaType::QKeySequence), + QT_ADD_STATIC_METATYPE("QPen", QMetaType::QPen), + QT_ADD_STATIC_METATYPE("QTextLength", QMetaType::QTextLength), + QT_ADD_STATIC_METATYPE("QTextFormat", QMetaType::QTextFormat), + QT_ADD_STATIC_METATYPE("QMatrix", QMetaType::QMatrix), + QT_ADD_STATIC_METATYPE("QTransform", QMetaType::QTransform), + QT_ADD_STATIC_METATYPE("QMatrix4x4", QMetaType::QMatrix4x4), + QT_ADD_STATIC_METATYPE("QVector2D", QMetaType::QVector2D), + QT_ADD_STATIC_METATYPE("QVector3D", QMetaType::QVector3D), + QT_ADD_STATIC_METATYPE("QVector4D", QMetaType::QVector4D), + QT_ADD_STATIC_METATYPE("QQuaternion", QMetaType::QQuaternion), /* All Metatype builtins */ - {"void*", QMetaType::VoidStar}, - {"long", QMetaType::Long}, - {"short", QMetaType::Short}, - {"char", QMetaType::Char}, - {"ulong", QMetaType::ULong}, - {"ushort", QMetaType::UShort}, - {"uchar", QMetaType::UChar}, - {"float", QMetaType::Float}, - {"QObject*", QMetaType::QObjectStar}, - {"QWidget*", QMetaType::QWidgetStar}, + QT_ADD_STATIC_METATYPE("void*", QMetaType::VoidStar), + QT_ADD_STATIC_METATYPE("long", QMetaType::Long), + QT_ADD_STATIC_METATYPE("short", QMetaType::Short), + QT_ADD_STATIC_METATYPE("char", QMetaType::Char), + QT_ADD_STATIC_METATYPE("ulong", QMetaType::ULong), + QT_ADD_STATIC_METATYPE("ushort", QMetaType::UShort), + QT_ADD_STATIC_METATYPE("uchar", QMetaType::UChar), + QT_ADD_STATIC_METATYPE("float", QMetaType::Float), + QT_ADD_STATIC_METATYPE("QObject*", QMetaType::QObjectStar), + QT_ADD_STATIC_METATYPE("QWidget*", QMetaType::QWidgetStar), /* Type aliases - order doesn't matter */ - {"unsigned long", QMetaType::ULong}, - {"unsigned int", QMetaType::UInt}, - {"unsigned short", QMetaType::UShort}, - {"unsigned char", QMetaType::UChar}, - {"long long", QMetaType::LongLong}, - {"unsigned long long", QMetaType::ULongLong}, - {"qint8", QMetaType::Char}, - {"quint8", QMetaType::UChar}, - {"qint16", QMetaType::Short}, - {"quint16", QMetaType::UShort}, - {"qint32", QMetaType::Int}, - {"quint32", QMetaType::UInt}, - {"qint64", QMetaType::LongLong}, - {"quint64", QMetaType::ULongLong}, - {"QList", QMetaType::QVariantList}, - {"QMap", QMetaType::QVariantMap}, - {"QHash", QMetaType::QVariantHash}, + QT_ADD_STATIC_METATYPE("unsigned long", QMetaType::ULong), + QT_ADD_STATIC_METATYPE("unsigned int", QMetaType::UInt), + QT_ADD_STATIC_METATYPE("unsigned short", QMetaType::UShort), + QT_ADD_STATIC_METATYPE("unsigned char", QMetaType::UChar), + QT_ADD_STATIC_METATYPE("long long", QMetaType::LongLong), + QT_ADD_STATIC_METATYPE("unsigned long long", QMetaType::ULongLong), + QT_ADD_STATIC_METATYPE("qint8", QMetaType::Char), + QT_ADD_STATIC_METATYPE("quint8", QMetaType::UChar), + QT_ADD_STATIC_METATYPE("qint16", QMetaType::Short), + QT_ADD_STATIC_METATYPE("quint16", QMetaType::UShort), + QT_ADD_STATIC_METATYPE("qint32", QMetaType::Int), + QT_ADD_STATIC_METATYPE("quint32", QMetaType::UInt), + QT_ADD_STATIC_METATYPE("qint64", QMetaType::LongLong), + QT_ADD_STATIC_METATYPE("quint64", QMetaType::ULongLong), + QT_ADD_STATIC_METATYPE("QList", QMetaType::QVariantList), + QT_ADD_STATIC_METATYPE("QMap", QMetaType::QVariantMap), + QT_ADD_STATIC_METATYPE("QHash", QMetaType::QVariantHash), // let QMetaTypeId2 figure out the type at compile time - {"qreal", QMetaTypeId2::MetaType}, + QT_ADD_STATIC_METATYPE("qreal", QMetaTypeId2::MetaType), - {0, QMetaType::Void} + {0, 0, QMetaType::Void} }; struct QMetaTypeGuiHelper @@ -409,19 +412,24 @@ const char *QMetaType::typeName(int type) /*! \internal Same as QMetaType::type(), but doesn't lock the mutex. */ -static int qMetaTypeType_unlocked(const QByteArray &typeName) +static int qMetaTypeType_unlocked(const char *typeName) { + int length = qstrlen(typeName); int i = 0; - while (types[i].typeName && strcmp(typeName.constData(), types[i].typeName)) + while (types[i].typeName && ((length != types[i].typeNameLength) + || strcmp(typeName, types[i].typeName))) { ++i; + } if (!types[i].type) { const QVector * const ct = customTypes(); if (!ct) return 0; for (int v = 0; v < ct->count(); ++v) { - if (ct->at(v).typeName == typeName) + if ((length == ct->at(v).typeName.size()) + && !strcmp(typeName, ct->at(v).typeName.constData())) { return v + QMetaType::User; + } } } return types[i].type; @@ -447,7 +455,7 @@ int QMetaType::registerType(const char *typeName, Destructor destructor, #endif QWriteLocker locker(customTypesLock()); - int idx = qMetaTypeType_unlocked(normalizedTypeName); + int idx = qMetaTypeType_unlocked(normalizedTypeName.constData()); if (!idx) { QCustomTypeInfo inf; @@ -514,14 +522,15 @@ bool QMetaType::isRegistered(int type) */ int QMetaType::type(const char *typeName) { -#ifdef QT_NO_QOBJECT - const NS(QByteArray) normalizedTypeName = typeName; -#else - const NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); -#endif - QReadLocker locker(customTypesLock()); - return qMetaTypeType_unlocked(normalizedTypeName); + int type = qMetaTypeType_unlocked(typeName); +#ifndef QT_NO_QOBJECT + if (!type) { + const NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); + type = qMetaTypeType_unlocked(normalizedTypeName.constData()); + } +#endif + return type; } #ifndef QT_NO_DATASTREAM -- cgit v0.12 From f36a907c40ebe6e22af141946ab8ef405ce3efb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 26 Feb 2010 08:20:58 +0100 Subject: Fix deadlock in QFSEventsFileSystemWatcherEngine. Task: QTBUG-8522 6130b2137 makes stop() synchronize and wait for the worker thread to reach the end of run(). stop() was however called from the worker thread itself in updateFiles(), leading to a deadlock. Add the stopFSStream and CFRunLoopStop calls directly to updateFiles(), don't wait on waitForStop. --- src/corelib/io/qfilesystemwatcher_fsevents.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.cpp b/src/corelib/io/qfilesystemwatcher_fsevents.cpp index 54ae24e..efbc290 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.cpp +++ b/src/corelib/io/qfilesystemwatcher_fsevents.cpp @@ -445,7 +445,16 @@ void QFSEventsFileSystemWatcherEngine::updateFiles() updateHash(dirPathInfoHash); if (filePathInfoHash.isEmpty() && dirPathInfoHash.isEmpty()) { // Everything disappeared before we got to start, don't bother. - stop(); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + // Code duplicated from stop(), with the exception that we + // don't wait on waitForStop here. Doing this will lead to + // a deadlock since this function is called from the worker + // thread. (waitForStop.wakeAll() is only called from the + // end of run()). + stopFSStream(fsStream); + if (threadsRunLoop) + CFRunLoopStop(threadsRunLoop); +#endif cleanupFSStream(fsStream); } waitCondition.wakeAll(); -- cgit v0.12 From f3eab3dd1bc982ad5847fdff67a59e2edfa20b54 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 26 Feb 2010 15:21:35 +0100 Subject: Don't lock the QMetaType custom types mutex unnecessarily Check the built-in types first, and only lock the mutex if the type is not found there. This makes the QMetaType::typeBuiltin benchmark ~5x faster. Reviewed-by: Harald Fernengel --- src/corelib/kernel/qmetatype.cpp | 72 +++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index bfc3e28..f104a26 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -410,29 +410,35 @@ const char *QMetaType::typeName(int type) } /*! \internal - Same as QMetaType::type(), but doesn't lock the mutex. + Similar to QMetaType::type(), but only looks in the static set of types. */ -static int qMetaTypeType_unlocked(const char *typeName) +static inline int qMetaTypeStaticType(const char *typeName, int length) { - int length = qstrlen(typeName); int i = 0; while (types[i].typeName && ((length != types[i].typeNameLength) || strcmp(typeName, types[i].typeName))) { ++i; } - if (!types[i].type) { - const QVector * const ct = customTypes(); - if (!ct) - return 0; + return types[i].type; +} - for (int v = 0; v < ct->count(); ++v) { - if ((length == ct->at(v).typeName.size()) - && !strcmp(typeName, ct->at(v).typeName.constData())) { - return v + QMetaType::User; - } +/*! \internal + Similar to QMetaType::type(), but only looks in the custom set of + types, and doesn't lock the mutex. +*/ +static int qMetaTypeCustomType_unlocked(const char *typeName, int length) +{ + const QVector * const ct = customTypes(); + if (!ct) + return 0; + + for (int v = 0; v < ct->count(); ++v) { + if ((length == ct->at(v).typeName.size()) + && !strcmp(typeName, ct->at(v).typeName.constData())) { + return v + QMetaType::User; } } - return types[i].type; + return 0; } /*! \internal @@ -454,16 +460,21 @@ int QMetaType::registerType(const char *typeName, Destructor destructor, NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); #endif - QWriteLocker locker(customTypesLock()); - int idx = qMetaTypeType_unlocked(normalizedTypeName.constData()); + int idx = qMetaTypeStaticType(normalizedTypeName.constData(), + normalizedTypeName.size()); if (!idx) { - QCustomTypeInfo inf; - inf.typeName = normalizedTypeName; - inf.constr = constructor; - inf.destr = destructor; - idx = ct->size() + User; - ct->append(inf); + QWriteLocker locker(customTypesLock()); + idx = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(), + normalizedTypeName.size()); + if (!idx) { + QCustomTypeInfo inf; + inf.typeName = normalizedTypeName; + inf.constr = constructor; + inf.destr = destructor; + idx = ct->size() + User; + ct->append(inf); + } } return idx; } @@ -522,12 +533,21 @@ bool QMetaType::isRegistered(int type) */ int QMetaType::type(const char *typeName) { - QReadLocker locker(customTypesLock()); - int type = qMetaTypeType_unlocked(typeName); -#ifndef QT_NO_QOBJECT + int length = qstrlen(typeName); + int type = qMetaTypeStaticType(typeName, length); if (!type) { - const NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); - type = qMetaTypeType_unlocked(normalizedTypeName.constData()); + QReadLocker locker(customTypesLock()); + type = qMetaTypeCustomType_unlocked(typeName, length); +#ifndef QT_NO_QOBJECT + if (!type) { + const NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); + type = qMetaTypeStaticType(normalizedTypeName.constData(), + normalizedTypeName.size()); + if (!type) { + type = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(), + normalizedTypeName.size()); + } + } } #endif return type; -- cgit v0.12 From a262cb0abec91ccce2502547fc376364e9d804da Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 26 Feb 2010 15:49:51 +0100 Subject: Bump iteration count to make QMetaType::type() benchmark results more stable With the recent optimizations it's just too fast now. ;) --- tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp index c3324df..36399af 100644 --- a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -96,7 +96,7 @@ void tst_QMetaType::typeBuiltin() QFETCH(QByteArray, typeName); const char *nm = typeName.constData(); QBENCHMARK { - for (int i = 0; i < 50000; ++i) + for (int i = 0; i < 100000; ++i) QMetaType::type(nm); } } -- cgit v0.12 From 8fc7d3315b3317ce7a3bf2ac4f0b3636623e515e Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 24 Feb 2010 16:48:51 +0100 Subject: QUrl: document adding of hash function Reviewed-by: TrustMe --- src/corelib/io/qurl.cpp | 7 +++++++ src/corelib/io/qurl.h | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 0290fb8..32f7ac2 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -167,6 +167,13 @@ regardless of the Qt::FormattingOptions used. */ +/*! + \fn uint qHash(const QUrl &url) + \since 4.7 + \relates QUrl + + Computes a hash key from the normalized version of \a url. + */ #include "qplatformdefs.h" #include "qurl.h" #include "private/qunicodetables_p.h" diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 906979c..6f8331a 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -270,9 +270,9 @@ public: inline DataPtr &data_ptr() { return d; } }; -inline uint qHash(const QUrl &uri) +inline uint qHash(const QUrl &url) { - return qHash(uri.toEncoded(QUrl::FormattingOption(0x100))); + return qHash(url.toEncoded(QUrl::FormattingOption(0x100))); } Q_DECLARE_TYPEINFO(QUrl, Q_MOVABLE_TYPE); -- cgit v0.12 From 70e260932f0659eb930969881366ce7cb6472756 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 26 Feb 2010 18:15:05 +0100 Subject: Unbreak compilation of bootstrapped Qt tools after f3eab3d. Bad brace positioning related to #ifdef QT_NO_QOBJECT Reviewed-by: Trust Me --- src/corelib/kernel/qmetatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index f104a26..fba8dd9 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -548,8 +548,8 @@ int QMetaType::type(const char *typeName) normalizedTypeName.size()); } } - } #endif + } return type; } -- cgit v0.12 From 2f51b3c71068be522af06652d64b5673c7685a33 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 26 Feb 2010 18:17:02 +0100 Subject: Fix compilation on solaris-g++-x86-64: emmintrin.h is not available. We have a test to verify if this file is available, but the test requires qmake to be built first. So don't enable the SSE2 intrinsics for the Latin-1 transformations in the bootstrapped tools. Reviewed-by: Trust Me --- src/corelib/tools/qsimd_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 556db14..369fab7 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -61,7 +61,7 @@ QT_MODULE(Core) #endif // SSE intrinsics -#if defined(__SSE2__) +#if defined(__SSE2__) && !defined(QT_BOOTSTRAPPED) #if defined(QT_LINUXBASE) /// this is an evil hack - the posix_memalign declaration in LSB /// is wrong - see http://bugs.linuxbase.org/show_bug.cgi?id=2431 -- cgit v0.12 From 1873a4b70dbc8a867ccc5b3cc0a2d9d85b208591 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 27 Feb 2010 14:52:11 +0100 Subject: Fix compilation with Sun CC: const in POD parameters makes a difference The compiler should have caught this error, but instead it accepted the QDisableNetworkReply constructor without the const. And that led to a linker error. Reviewed-by: Trust Me --- src/network/access/qnetworkreplyimpl_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index ec413cc..b4fbd1e 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -199,7 +199,7 @@ class QDisabledNetworkReply : public QNetworkReply public: QDisabledNetworkReply(QObject *parent, const QNetworkRequest &req, - const QNetworkAccessManager::Operation op); + QNetworkAccessManager::Operation op); ~QDisabledNetworkReply(); void abort() { } -- cgit v0.12 From 57ce77e953b618739f6f1aec67f8e0de97e05b08 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 27 Feb 2010 14:54:17 +0100 Subject: Fix compilation with Sun CC: __FUNCTION__ is not valid Use the alternative from qglobal.h, that exists for this reason. Reviewed-by: Trust Me --- src/plugins/bearer/qnetworksession_impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp index f41fdba..05ce62f 100644 --- a/src/plugins/bearer/qnetworksession_impl.cpp +++ b/src/plugins/bearer/qnetworksession_impl.cpp @@ -201,22 +201,22 @@ void QNetworkSessionPrivateImpl::stop() void QNetworkSessionPrivateImpl::migrate() { - qWarning("This platform does not support roaming (%s).", __FUNCTION__); + qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO); } void QNetworkSessionPrivateImpl::accept() { - qWarning("This platform does not support roaming (%s).", __FUNCTION__); + qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO); } void QNetworkSessionPrivateImpl::ignore() { - qWarning("This platform does not support roaming (%s).", __FUNCTION__); + qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO); } void QNetworkSessionPrivateImpl::reject() { - qWarning("This platform does not support roaming (%s).", __FUNCTION__); + qWarning("This platform does not support roaming (%s).", Q_FUNC_INFO); } QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const -- cgit v0.12 From 0f83dd85ad1113468fa6b23b05dc703a3303bdd6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 27 Feb 2010 17:07:14 +0100 Subject: Autotest: no need to call exitLoop twice, from two threads. This caused the test to be unreliable -- the event loop in the main thread would exit before the thread finished running. Now we're sure that it's only exiting becuase the thread finished running. --- tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp b/tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp index 54426ce..a55a427 100644 --- a/tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp +++ b/tests/auto/qdbuspendingcall/tst_qdbuspendingcall.cpp @@ -128,8 +128,6 @@ void tst_QDBusPendingCall::finished(QDBusPendingCallWatcher *call) watchArgument = call; if (QThread::currentThread() == thread()) QTestEventLoop::instance().exitLoop(); - else - QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection); } void tst_QDBusPendingCall::callback(const QStringList &list) @@ -427,7 +425,7 @@ void tst_QDBusPendingCall::watcher_waitForFinished_threaded() } thread(this); QTestEventLoop::instance().connect(&thread, SIGNAL(finished()), SLOT(exitLoop())); thread.start(); - QTestEventLoop::instance().enterLoop(1000); + QTestEventLoop::instance().enterLoop(10); QVERIFY(!thread.isRunning()); QVERIFY(!QTestEventLoop::instance().timeout()); } -- cgit v0.12