From 5c8017e0880cc5f71854ebb71a38b944e58260b1 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Wed, 26 May 2010 03:32:11 +0900 Subject: Fix QT_NO_TEXTDATE --- src/declarative/qml/qdeclarativecompiler.cpp | 4 ++++ src/declarative/qml/qdeclarativeengine.cpp | 4 ++++ src/declarative/qml/qdeclarativeengine_p.h | 3 ++- src/declarative/qml/qdeclarativestringconverters.cpp | 4 ++++ src/declarative/qml/qdeclarativestringconverters_p.h | 2 ++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index b5bf972..b74d640 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 0a75532..452ed3d 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -225,10 +225,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)); @@ -1092,6 +1094,7 @@ QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngi return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QVector3D(x, y, z))); } +#ifndef QT_NO_TEXTDATE QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine) { int argCount = ctxt->argumentCount(); @@ -1154,6 +1157,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr } return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); } +#endif // QT_NO_TEXTDATE QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine) { diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 0b1c17d..296885f 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(e)->p->q_func(); } static QDeclarativeEnginePrivate *get(QDeclarativeEngine *e) { return e->d_func(); } 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); -- cgit v0.12 From ad8047dbca22e2c3c8af3ec60ba97939abf91315 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 26 May 2010 16:38:41 +0200 Subject: Doc: Corrected the documentation about the compression threshold. Reviewed-by: Trust Me --- doc/src/development/rcc.qdoc | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/doc/src/development/rcc.qdoc b/doc/src/development/rcc.qdoc index 1541e11..999408b 100644 --- a/doc/src/development/rcc.qdoc +++ b/doc/src/development/rcc.qdoc @@ -60,28 +60,30 @@ \row \o \c{-o} \o \c{file} \o Write output to \c{file} rather than to stdout. \row \o \c{-name} \o \c{name} \o Create an external initialization - function with \c{name}. - - \row \o \c{-threshold} \o \c{level} \o Specifies a threshold \c{level} (in - bytes) to use when deciding whether - to compress a file. If the file is - smaller than the threshold \c{level}, - it is not compressed. The default - threshold level is 70 bytes. - + function with \c{name}. + + \row \o \c{-threshold} \o \c{level} \o Specifies a threshold \c{level} (as a + percentage) to use when deciding whether to compress + a file. If the reduction in the file size is greater than + the threshold \c{level}, it is compressed; otherwise, + the uncompressed data is stored instead. The default + threshold level is 70%, meaning that compressed files + which are 30% or less of their original size are + stored as compressed data. + \row \o \c{-compress} \o \c{level} \o Compress input files to the given - compression \c{level}, which is an - integer in the range 1 to 9. Level 1 - does the least compression but is - fastest. Level 9 does the most - compression but is slowest. To turn - off compression, use \c{-no-compress}. - The default value for \c{level} is -1, - which means use zlib's default - compression level. + compression \c{level}, which is an + integer in the range 1 to 9. Level 1 + does the least compression but is + fastest. Level 9 does the most + compression but is slowest. To turn + off compression, use \c{-no-compress}. + The default value for \c{level} is -1, + which means use zlib's default + compression level. \row \o \c{-root} \o \c{path} \o Prefix the resource access path with \c{path}. - The default is no prefix. + The default is no prefix. \row \o \c{-no-compress} \o \o Disable compression. -- cgit v0.12 From 745e276f6802f0f7fb2d548d04bf120c5516d7c6 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 26 May 2010 14:24:26 +1000 Subject: Fix locking after merge from Qt Mobility. Simplify locking by using inline getter functions. Task-number: QTBUG-10296 --- .../bearer/symbian/qnetworksession_impl.cpp | 102 ++++++--------------- src/plugins/bearer/symbian/symbianengine.cpp | 70 ++++++++------ src/plugins/bearer/symbian/symbianengine.h | 18 +++- 3 files changed, 88 insertions(+), 102 deletions(-) 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..ed6aee6 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -338,34 +338,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(); emit configurationAdded(ptr); locker.relock(); + 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; @@ -418,9 +419,10 @@ void SymbianEngine::updateConfigurationsL() 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; } @@ -639,12 +641,14 @@ 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() @@ -681,8 +685,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); @@ -736,6 +741,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); @@ -772,10 +779,15 @@ void SymbianEngine::updateStatesToSnaps() 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; iserviceNetworkMembers.count(); i++) { + QMutexLocker configLocker(&ptr->serviceNetworkMembers[i]->mutex); + if ((ptr->serviceNetworkMembers[i]->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { active = true; @@ -991,9 +1003,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 +1020,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 +1040,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 +1055,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; @@ -1135,10 +1153,9 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo updateStatesToSnaps(); } - QMutexLocker configLocker(&ptr->mutex); - emit this->configurationStateChanged(toSymbianConfig(ptr)->numericId, - toSymbianConfig(ptr)->connectionId, - QNetworkSession::Disconnected); + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + toSymbianConfig(ptr)->connectionIdentifier(), + QNetworkSession::Disconnected); } } break; @@ -1170,8 +1187,7 @@ QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aCon 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; diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 7d565db..841d79d 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; -- cgit v0.12 From 2666e68f49c4a8185de796438fd3f672fcec0365 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 28 May 2010 09:30:54 +1000 Subject: Fix up cancelling of active object. Task-number: QTBUG-10296 --- src/plugins/bearer/symbian/symbianengine.cpp | 78 ++++++++++++---------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index ed6aee6..bc93d0e 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -899,15 +899,7 @@ void SymbianEngine::stopCommsDatabaseNotifications() 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(); } } @@ -922,46 +914,44 @@ 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(); + } + waitRandomTime(); + } else { + waitRandomTime(); + 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) { -- cgit v0.12 From feb9949a11abbf244e0bfcdc128981596758de40 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 28 May 2010 10:07:00 +1000 Subject: Fix multithreaded use of bearer management on Symbian. Move more initialization code into initialize() function. The constructor for the SymbianEngine class can be called from any thread. Move all initialization into initialize() function which is guarinteed to be run in the main thread. This is required as some Symbian resources are not shared between thread in the same process. The implementation of the defaultConfiguration() function could only be called from the main thread. Cache a copy of the default network configuration when the configurations are updated and just return this when the defaultConfiguration() function is called. Only lock the engine mutex from external entry points. Remove need for locking in waitRandomTime() function. Prevents dead lock due to nested event loop. Task-number: QTBUG-10296 --- src/plugins/bearer/symbian/symbianengine.cpp | 126 +++++++++++---------------- src/plugins/bearer/symbian/symbianengine.h | 6 +- 2 files changed, 52 insertions(+), 80 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index bc93d0e..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 knownConfigs = accessPointConfigurations.keys(); QList 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); } @@ -340,9 +335,9 @@ void SymbianEngine::updateConfigurationsL() QNetworkConfigurationPrivatePointer ptr(cpPriv); accessPointConfigurations.insert(ptr->id, ptr); - locker.unlock(); + mutex.unlock(); emit configurationAdded(ptr); - locker.relock(); + mutex.lock(); QMutexLocker configLocker(&privSNAP->mutex); privSNAP->serviceNetworkMembers.append(ptr); @@ -411,9 +406,9 @@ 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()) { @@ -434,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); @@ -528,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; @@ -540,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 name; @@ -604,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() @@ -624,8 +610,6 @@ QStringList SymbianEngine::accessPointConfigurationIdentifiers() QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL() { - QMutexLocker locker(&mutex); - QNetworkConfigurationPrivatePointer ptr; #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -653,8 +637,6 @@ QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL() void SymbianEngine::updateActiveAccessPoints() { - QMutexLocker locker(&mutex); - bool online = false; QList inactiveConfigs = accessPointConfigurations.keys(); @@ -707,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); } @@ -728,8 +708,6 @@ void SymbianEngine::updateAvailableAccessPoints() void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo) { - QMutexLocker locker(&mutex); - iUpdateGoingOn = false; if (scanSuccessful) { QList unavailableConfigs = accessPointConfigurations.keys(); @@ -764,16 +742,14 @@ 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; @@ -810,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 { @@ -835,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 { @@ -861,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 { @@ -881,8 +851,6 @@ bool SymbianEngine::changeConfigurationStateAtMaxTo(QNetworkConfigurationPrivate void SymbianEngine::startCommsDatabaseNotifications() { - QMutexLocker locker(&mutex); - if (!iWaitingCommsDatabaseNotifications) { iWaitingCommsDatabaseNotifications = ETrue; if (!IsActive()) { @@ -895,8 +863,6 @@ void SymbianEngine::startCommsDatabaseNotifications() void SymbianEngine::stopCommsDatabaseNotifications() { - QMutexLocker locker(&mutex); - if (iWaitingCommsDatabaseNotifications) { iWaitingCommsDatabaseNotifications = EFalse; Cancel(); @@ -938,9 +904,13 @@ void SymbianEngine::RunL() if (error == KErrNone) { updateStatesToSnaps(); } + locker.unlock(); waitRandomTime(); + locker.relock(); } else { + locker.unlock(); waitRandomTime(); + locker.relock(); TRAPD(error, updateConfigurationsL()); if (error == KErrNone) { updateStatesToSnaps(); @@ -1129,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 @@ -1143,9 +1115,11 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo updateStatesToSnaps(); } + locker.unlock(); emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), toSymbianConfig(ptr)->connectionIdentifier(), QNetworkSession::Disconnected); + locker.relock(); } } break; @@ -1157,21 +1131,17 @@ 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::const_iterator i = accessPointConfigurations.constBegin(); @@ -1224,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 841d79d..18fd249 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -212,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; -- cgit v0.12 From e5cc765d2fa1ff68f1592ad475d6b8f4e5a6f667 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 31 May 2010 14:45:43 +1000 Subject: Document issues with rectangle border width of 1 where clipping is used --- doc/src/declarative/pics/rect-border-width.png | Bin 0 -> 356 bytes doc/src/snippets/declarative/rect-border-width.qml | 19 +++++++++++++++++++ .../graphicsitems/qdeclarativerectangle.cpp | 16 ++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 doc/src/declarative/pics/rect-border-width.png create mode 100644 doc/src/snippets/declarative/rect-border-width.qml diff --git a/doc/src/declarative/pics/rect-border-width.png b/doc/src/declarative/pics/rect-border-width.png new file mode 100644 index 0000000..c3c6c2c Binary files /dev/null and b/doc/src/declarative/pics/rect-border-width.png differ diff --git a/doc/src/snippets/declarative/rect-border-width.qml b/doc/src/snippets/declarative/rect-border-width.qml new file mode 100644 index 0000000..27a241d --- /dev/null +++ b/doc/src/snippets/declarative/rect-border-width.qml @@ -0,0 +1,19 @@ +import Qt 4.7 + +//![0] +Rectangle { + width: 100; height: 100 + color: "yellow" + + Rectangle { + anchor.fill: parent + anchors.margins: 10 + clip: true + + Rectangle { + anchors.fill: parent + border.width: 1 + } + } +} +//![0] 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() { -- cgit v0.12 From 4759e47a2444d481156ad1a789e5affbc92e1b58 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 31 May 2010 16:59:48 +1000 Subject: Various doc fixes and improvements --- doc/src/declarative/basictypes.qdoc | 67 +++++++++++++++++---- doc/src/declarative/globalobject.qdoc | 2 +- doc/src/declarative/pics/repeater-modeldata.png | Bin 0 -> 2600 bytes doc/src/declarative/qml-intro.qdoc | 26 ++++---- .../snippets/declarative/repeater-modeldata.qml | 52 ++++++++++++++++ examples/declarative/sqllocalstorage/hello.qml | 2 +- .../tutorials/extending/chapter1-basics/app.qml | 1 + .../tutorials/extending/chapter2-methods/app.qml | 1 + .../tutorials/extending/chapter3-bindings/app.qml | 1 + .../extending/chapter4-customPropertyTypes/app.qml | 1 + .../graphicsitems/qdeclarativerepeater.cpp | 14 +++-- src/declarative/qml/qdeclarativeengine.cpp | 34 ++++++++--- 12 files changed, 159 insertions(+), 42 deletions(-) create mode 100644 doc/src/declarative/pics/repeater-modeldata.png create mode 100644 doc/src/snippets/declarative/repeater-modeldata.qml diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index 8db1c35..43ae214 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -46,9 +46,9 @@ QML has a set of primitive types, as listed below, that are used throughout the \l {QML Elements}. - The simpler types in this list can also be used for defining a new - \c property in a component. See \l{Extending types from QML} for the - list of types that can be used for custom properties. + Some of these types can also be used for defining + \c property values in QML. See \l{Extending types from QML} for the + list of types that can be used for \c property values. \annotatedlist qmlbasictypes */ @@ -171,6 +171,13 @@ Rectangle { color: "#800000FF" } \endqml + Or with the \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()} functions: + + \qml + Rectangle { color: Qt.rgba(255, 0, 0, 1) } + \endqml + \sa {QML Basic Types} */ @@ -184,9 +191,17 @@ Example: \qml - Widget { pos: "0,20" } + MyItem { position: "0,20" } \endqml + Or with the \l{Qt::point()}{Qt.point()} function: + + \qml + MyItem { position: Qt.point(0, 20) } + \endqml + + A point object has \c x and \c y attributes that contain the \c x and \c y values. + \sa {QML Basic Types} */ @@ -200,9 +215,17 @@ Example: \qml - Widget { size: "150x50" } + LayoutItem { preferredSize: "150x50" } + \endqml + + Or with the \l{Qt::size()}{Qt.size()} function: + + \qml + MyItem { position: Qt.size(150, 50) } \endqml + A size object has \c width and \c height attributes that contain the \c width and \c height values. + \sa {QML Basic Types} */ @@ -216,9 +239,18 @@ Example: \qml - Widget { geometry: "50,50,100x100" } + MyItem { geometry: "50,50,100x100" } \endqml + Or with the \l{Qt::rect()}{Qt.rect()} function: + + \qml + MyItem { position: Qt.rect(50, 50, 100, 100) } + \endqml + + A rect object has \c x, \c, y, \c width and \c height attributes that contain the + \c x, \c y, \c width and \c height values. + \sa {QML Basic Types} */ @@ -232,9 +264,12 @@ Example: \qml - DatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" } + MyDatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" } \endqml + To read a date value returned from a C++ extension class, use + \l{Qt::formatDate()}{Qt.formatDate()} and \l{Qt::formatDateTime()}{Qt.formatDateTime()}. + \sa {QML Basic Types} */ @@ -248,9 +283,12 @@ Example: \qml - TimePicker { time: "14:22:15" } + MyTimePicker { time: "14:22:15" } \endqml + To read a time value returned from a C++ extension class, use + \l{Qt::formatTime()}{Qt.formatTime()} and \l{Qt::formatDateTime()}{Qt.formatDateTime()}. + \sa {QML Basic Types} */ @@ -297,9 +335,9 @@ Actions are used like this: \qml - MouseArea { onClicked: MyItem.myaction.trigger() } - State { name: "enabled"; when: MyItem.myaction.enabled == true } - Text { text: MyItem.someaction.text } + MouseArea { onClicked: myaction.trigger() } + State { name: "enabled"; when: myaction.enabled == true } + Text { text: someaction.text } \endqml \sa {QML Basic Types} @@ -327,7 +365,7 @@ ] } \endqml - \c Child1, \c Child2 and \c Child3 will all be added to the children list + \c child1, \c child2 and \c child3 will all be added to the children list in the order in which they appear. \sa {QML Basic Types} @@ -345,7 +383,7 @@ Rotation { angle: 60; axis: "0,1,0" } \endqml - or with the \c{Qt.vector3d()} helper function: + or with the \c{Qt.vector3d()} function: \qml Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) } @@ -357,5 +395,8 @@ Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 } \endqml + A vector3d object has \c x, \c, y, and \c z attributes that contain the + \c x, \c y, \c z values. + \sa {QML Basic Types} */ diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index 7d4f9b9..3121e95 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -49,7 +49,7 @@ Contains all the properties of the JavaScript global object, plus: \section1 Qt Object -The \l{qml-qt.html}{Qt object} provides useful enums and functions from Qt, for use in all QML +The \l{Qt}{Qt object} provides useful enums and functions from Qt, for use in all QML files. \section1 XMLHttpRequest diff --git a/doc/src/declarative/pics/repeater-modeldata.png b/doc/src/declarative/pics/repeater-modeldata.png new file mode 100644 index 0000000..817f35b Binary files /dev/null and b/doc/src/declarative/pics/repeater-modeldata.png differ diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc index 64a4949..848e094 100644 --- a/doc/src/declarative/qml-intro.qdoc +++ b/doc/src/declarative/qml-intro.qdoc @@ -864,49 +864,49 @@ paused, and reaching the end of the media. They allow the developer to connect, some QML that will handle this event. -\section1 Analyzing An Example: Dial +\section1 Analyzing An Example: Dial Control -In the Qt \e {examples/declarative/toys} folder you will find a folder -\e {dial} which contains the \e dial example. +In the Qt \e {examples/declarative/ui-components} folder you will find a folder +\e {dialcontrol} which contains the \e dialcontrol example. \image qml-dial.png "QML Dial example with Slider" In essence this small application has a sliding bar that you can slide using a mouse, and a graphical dial that responds to the position of the slider. -The code for the example is in two parts: Dial.qml and dial-example.qml. +The code for the example is in two parts: Dial.qml and dialcontrol.qml. -\e {Dial.qml} can be found in the \e content sub-directory. It defines a Dial +\e {Dial.qml} can be found in the \e content sub-directory. It defines a \c Dial component similar to an odometer. Eventually, the example will hook up a slider component so that moving the slider will change the position of a needle on the dial. -The code for the Dial, identified by the name of the file, contains four images +The code for the \c Dial, identified by the name of the file, contains four images in overlapping order: the background (numbers and divisions), the shadow of the needle, the needle itself, and finally the 'glass' overlay (containing transparent layers). -The needle_shadow.png image has a Rotation assigned to the \e transform +The \c needle_shadow.png image has a \l Rotation assigned to the \e transform attribute of the \l Image. The rotation is set to match the angle of the needle image angle value \e {needleRotation.angle}. Both the needle and the needle_shadow have the same default \e x and \e y values but the rotation origin for the needle is slightly different so that a shadow will be evident as the needle moves. -\snippet ../../examples/declarative/toys/dial/content/Dial.qml needle_shadow +\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml needle_shadow And the needle -\snippet ../../examples/declarative/toys/dial/content/Dial.qml needle +\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml needle The final image is the overlay which simply has a position defined. -\snippet ../../examples/declarative/toys/dial/content/Dial.qml overlay +\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml overlay -\e {dial-example.qml} in the \e {examples/declarative/toys/dial} directory is the +\e {dialcontrol.qml} in the \e {examples/declarative/ui-components/dialcontrol} directory is the main file of the example. It defines the visual environment that the Dial will fit into. Because the \e Dial component and the images live in the \e -content sub-directory we will have to import this into \e dial-example. So the +content sub-directory we will have to import this into \e dialcontrol.qml. So the start of the file looks like \code @@ -919,7 +919,7 @@ a gray color. Inside this rectangle is our component \e Dial and a \l Rectangle. Inside the rectangle called 'container' is another rectangle with the interesting name 'slider'. -\snippet ../../examples/declarative/toys/dial/dial-example.qml 0 +\snippet ../../examples/declarative/ui-components/dialcontrol/dialcontrol.qml 0 The Dial component, named 'dial, is \e anchored to the center of the main rectangle. The \c value attribute of 'dial' is set to a value based on the diff --git a/doc/src/snippets/declarative/repeater-modeldata.qml b/doc/src/snippets/declarative/repeater-modeldata.qml new file mode 100644 index 0000000..3b4cc6d --- /dev/null +++ b/doc/src/snippets/declarative/repeater-modeldata.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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 QtDeclarative module 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$ +** +****************************************************************************/ + +import Qt 4.7 + +//! [0] +Column { + Repeater { + model: ["apples", "oranges", "pears"] + Text { text: "Data: " + modelData } + } +} +//! [0] + diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml index 0913d42..421a74c 100644 --- a/examples/declarative/sqllocalstorage/hello.qml +++ b/examples/declarative/sqllocalstorage/hello.qml @@ -68,4 +68,4 @@ Text { Component.onCompleted: findGreetings() } - +//![0] diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml index 7de32f2..9af155c 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml +++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml @@ -55,3 +55,4 @@ Rectangle { text: aMusician.name + " plays the " + aMusician.instrument } } +//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml index 495413f..02d33c2 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml +++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml @@ -57,3 +57,4 @@ Rectangle { onClicked: aMusician.perform() } } +//![0] diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml index 46408cb..8bf6ecf 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml +++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml @@ -69,3 +69,4 @@ Rectangle { } } } +//![0] diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml index 09662d6..d76f801 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -51,3 +51,4 @@ Item { Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type) } +//![0] 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/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 8679e76..d8c842b 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 */ @@ -1034,7 +1046,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 @@ -1360,7 +1372,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr /*! \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 +1400,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 +1428,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) { -- cgit v0.12 From 90abe364b7e9b0aa201a3e0ed0b043643519e21b Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 26 May 2010 13:09:49 +0200 Subject: Make test work with shadow builds again. Broken by 0cdf33e9acb00b8f3654e8268253a3fb7c5db92c, which assumes the binary and sources are in the same directory. The fix reverts the code back to how it was in 4.5 (where it still works with shadow builds). Reviewed-by: Denis Dzyubenko --- tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp index dac631b..1f65ae7 100644 --- a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp @@ -56,7 +56,7 @@ #elif defined(Q_OS_WINCE) #define LACKEYDIR SRCDIR #else -#define LACKEYDIR SRCDIR "../lackey" +#define LACKEYDIR "../lackey" #endif Q_DECLARE_METATYPE(QSharedMemory::SharedMemoryError) @@ -421,7 +421,7 @@ void tst_QSharedMemory::readOnly() QString program = LACKEYDIR "/lackey"; QStringList arguments; rememberKey("readonly_segfault"); - arguments << LACKEYDIR "/scripts/readonly_segfault.js"; + arguments << SRCDIR "../lackey/scripts/readonly_segfault.js"; // ### on windows disable the popup somehow QProcess p; @@ -734,7 +734,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() rememberKey("market"); - QStringList arguments = QStringList() << LACKEYDIR "/scripts/producer.js"; + QStringList arguments = QStringList() << SRCDIR "../lackey/scripts/producer.js"; QProcess producer; producer.setProcessChannelMode(QProcess::ForwardedChannels); producer.start( LACKEYDIR "/lackey", arguments); @@ -744,7 +744,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() QList consumers; unsigned int failedProcesses = 0; for (int i = 0; i < processes; ++i) { - QStringList arguments = QStringList() << LACKEYDIR "/scripts/consumer.js"; + QStringList arguments = QStringList() << SRCDIR "../lackey/scripts/consumer.js"; QProcess *p = new QProcess; p->setProcessChannelMode(QProcess::ForwardedChannels); #ifdef Q_OS_WINCE -- cgit v0.12 From 9b4ff3deb28b3d642dc4480207f2f23841cf26e9 Mon Sep 17 00:00:00 2001 From: Mirko Damiani Date: Mon, 8 Feb 2010 16:09:24 +0100 Subject: Added native key support to QSharedMemory API. Methods setNativeKey() and nativeKey() were added to QSharedMemory API. Shared memory's native key is returned by nativeKey() and it is set with either setKey() or setNativeKey(). setKey() leads to a native key that is platform independent while setNativeKey() directly sets the native key without any mangling. When using setNativeKey(), key() returns a null string and shared memory's system semaphore is not set. This means that is up to the user to define a such protection mechanism (i.e. lock() can't be used on native keys). QSharedMemory tests were updated. Merge-request: 1497 Reviewed-by: Benjamin Poulain Reviewed-by: Andreas Aardal Hanssen --- src/corelib/kernel/qsharedmemory.cpp | 120 +++++++++++++++------ src/corelib/kernel/qsharedmemory.h | 2 + src/corelib/kernel/qsharedmemory_p.h | 1 + src/corelib/kernel/qsharedmemory_symbian.cpp | 11 +- src/corelib/kernel/qsharedmemory_unix.cpp | 15 ++- src/corelib/kernel/qsharedmemory_win.cpp | 13 +-- .../auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp | 26 +++-- 7 files changed, 123 insertions(+), 65 deletions(-) diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index fe93ebc..d5f4052 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -142,9 +142,12 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, remain. Do not mix using QtSharedMemory and QSharedMemory. Port everything to QSharedMemory. - \warning QSharedMemory changes the key in a Qt-specific way. - It is therefore currently not possible to use the shared memory of - non-Qt applications with QSharedMemory. + \warning QSharedMemory changes the key in a Qt-specific way, unless otherwise + specified. Interoperation with non-Qt applications is achieved by first creating + a default shared memory with QSharedMemory() and then setting a native key with + setNativeKey(). When using native keys, shared memory is not protected against + multiple accesses on it (e.g. unable to lock()) and a user-defined mechanism + should be used to achieve a such protection. */ /*! @@ -153,8 +156,8 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, Constructs a shared memory object with the given \a parent. The shared memory object's key is not set by the constructor, so the shared memory object does not have an underlying shared memory - segment attached. The key must be set with setKey() before create() - or attach() can be used. + segment attached. The key must be set with setKey() or setNativeKey() + before create() or attach() can be used. \sa setKey() */ @@ -191,24 +194,52 @@ QSharedMemory::~QSharedMemory() } /*! - Sets a new \a key for this shared memory object. If \a key and the - current key are the same, the function returns without doing - anything. If the shared memory object is attached to an underlying - shared memory segment, it will \l {detach()} {detach} from it before - setting the new key. This function does not do an attach(). - - \sa key() isAttached() - */ + Sets a new \a key for this shared memory object. + The \a key is first converted to a unicode string accepted by all supported platforms, + (see nativeKey()). If \a key and the current key are the same, the function returns + without doing anything. If the shared memory object is attached to an underlying + shared memory segment, it will \l {detach()} {detach} from it before setting the new key. + This function does not do an attach(). + + \sa key() nativeKey() isAttached() +*/ void QSharedMemory::setKey(const QString &key) { Q_D(QSharedMemory); - if (key == d->key) + if (key == d->key && d->makePlatformSafeKey(key) == d->nativeKey) return; if (isAttached()) detach(); d->cleanHandle(); d->key = key; + d->nativeKey = d->makePlatformSafeKey(key); +} + +/*! + \since 4.7 + Sets a new native \a key for this shared memory object. + The specified \a key is used as-is, without any conversion. The \a key has to be + in a valid format for the current operating system (e.g. under Unix a valid \a key + corresponds to a filename). Be aware that the application might not be portable. + This function returns without doing anything if the \a key equals the current + native key. If the shared memory object is attached to an underlying shared memory + segment, it will \l {detach()} {detach} from it before setting the new key. + This function does not do an attach(). + + \sa nativeKey() key() isAttached() +*/ +void QSharedMemory::setNativeKey(const QString &key) +{ + Q_D(QSharedMemory); + if (key == d->nativeKey && d->key.isNull()) + return; + + if (isAttached()) + detach(); + d->cleanHandle(); + d->key = QString(); + d->nativeKey = key; } bool QSharedMemoryPrivate::initKey() @@ -251,13 +282,14 @@ bool QSharedMemoryPrivate::initKey() } /*! - Returns the key assigned to this shared memory. The key is the - identifier used by the operating system to identify the shared - memory segment. When QSharedMemory is used for interprocess - communication, the key is how each process attaches to the shared - memory segment through which the IPC occurs. - - \sa setKey() + Returns the key assigned with setKey() to this shared memory. + The key is the identifier used by Qt applications to identify the shared + memory segment. The actual native key used by the operating system is returned + by nativeKey(). A null string is returned if the key was specified using setNativeKey(). + When QSharedMemory is used for interprocess communication, the key is how each + process attaches to the shared memory segment through which the IPC occurs. + + \sa setKey() setNativeKey() */ QString QSharedMemory::key() const { @@ -266,13 +298,31 @@ QString QSharedMemory::key() const } /*! - Creates a shared memory segment of \a size bytes with the key passed - to the constructor or set with setKey(), attaches to the new shared - memory segment with the given access \a mode, and returns \tt true. - If a shared memory segment identified by the key already exists, the - attach operation is not performed, and \tt false is returned. When - the return value is \tt false, call error() to determine which error - occurred. + \since 4.7 + Returns the native key assigned with setKey() or setNativeKey() to this shared memory. + The native key is the identifier used by the operating system to identify the + shared memory segment. When using setKey(), the native key is obtained by + converting the specified key into a format accepted by all supported platforms. + When using setNativeKey(), the native key actually corresponds to the specified key + without any conversion. When QSharedMemory is used for interprocess communication, + the key is how each process attaches to the shared memory segment through which + the IPC occurs. + + \sa setKey() setNativeKey() +*/ +QString QSharedMemory::nativeKey() const +{ + Q_D(const QSharedMemory); + return d->nativeKey; +} + +/*! + Creates a shared memory segment of \a size bytes with the key passed to the + constructor, set with setKey() or set with setNativeKey(), then attaches to + the new shared memory segment with the given access \a mode and returns + \tt true. If a shared memory segment identified by the key already exists, + the attach operation is not performed and \tt false is returned. When the + return value is \tt false, call error() to determine which error occurred. \sa error() */ @@ -294,7 +344,7 @@ bool QSharedMemory::create(int size, AccessMode mode) QString function = QLatin1String("QSharedMemory::create"); #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->tryLocker(&lock, function)) + if (!d->key.isNull() && !d->tryLocker(&lock, function)) return false; #endif @@ -338,7 +388,7 @@ int QSharedMemory::size() const /*! Attempts to attach the process to the shared memory segment identified by the key that was passed to the constructor or to a - call to setKey(). The access \a mode is \l {QSharedMemory::} + call to setKey() or setNativeKey(). The access \a mode is \l {QSharedMemory::} {ReadWrite} by default. It can also be \l {QSharedMemory::} {ReadOnly}. Returns true if the attach operation is successful. If false is returned, call error() to determine which error occurred. @@ -355,7 +405,7 @@ bool QSharedMemory::attach(AccessMode mode) return false; #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->tryLocker(&lock, QLatin1String("QSharedMemory::attach"))) + if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::attach"))) return false; #endif @@ -395,7 +445,7 @@ bool QSharedMemory::detach() #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->tryLocker(&lock, QLatin1String("QSharedMemory::detach"))) + if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::detach"))) return false; #endif @@ -451,9 +501,9 @@ const void *QSharedMemory::data() const by this process and returns true. If another process has locked the segment, this function blocks until the lock is released. Then it acquires the lock and returns true. If this function returns false, - it means either that you have ignored a false return from create() - or attach(), or that QSystemSemaphore::acquire() failed due to an - unknown system error. + it means that you have ignored a false return from create() or attach(), + that you have set the key with setNativeKey() or that + QSystemSemaphore::acquire() failed due to an unknown system error. \sa unlock(), data(), QSystemSemaphore::acquire() */ diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h index fba939c..5673f43 100644 --- a/src/corelib/kernel/qsharedmemory.h +++ b/src/corelib/kernel/qsharedmemory.h @@ -85,6 +85,8 @@ public: void setKey(const QString &key); QString key() const; + void setNativeKey(const QString &key); + QString nativeKey() const; bool create(int size, AccessMode mode = ReadWrite); int size() const; diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index a52f8b3..632a6e9 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -122,6 +122,7 @@ public: void *memory; int size; QString key; + QString nativeKey; QSharedMemory::SharedMemoryError error; QString errorString; #ifndef QT_NO_SYSTEMSEMAPHORE diff --git a/src/corelib/kernel/qsharedmemory_symbian.cpp b/src/corelib/kernel/qsharedmemory_symbian.cpp index 9b84eb56..091c2b5 100644 --- a/src/corelib/kernel/qsharedmemory_symbian.cpp +++ b/src/corelib/kernel/qsharedmemory_symbian.cpp @@ -107,16 +107,14 @@ bool QSharedMemoryPrivate::cleanHandle() bool QSharedMemoryPrivate::create(int size) { - // Get a windows acceptable key - QString safeKey = makePlatformSafeKey(key); QString function = QLatin1String("QSharedMemory::create"); - if (safeKey.isEmpty()) { + if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: key error").arg(function); return false; } - TPtrC ptr(qt_QString2TPtrC(safeKey)); + TPtrC ptr(qt_QString2TPtrC(nativeKey)); TInt err = chunk.CreateGlobal(ptr, size, size); @@ -136,14 +134,13 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode /* mode */) // Grab a pointer to the memory block if (!chunk.Handle()) { QString function = QLatin1String("QSharedMemory::handle"); - QString safeKey = makePlatformSafeKey(key); - if (safeKey.isEmpty()) { + if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: unable to make key").arg(function); return false; } - TPtrC ptr(qt_QString2TPtrC(safeKey)); + TPtrC ptr(qt_QString2TPtrC(nativeKey)); TInt err = KErrNoMemory; diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index a5f79c2..064979b 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -116,21 +116,20 @@ key_t QSharedMemoryPrivate::handle() return unix_key; // don't allow making handles on empty keys - if (key.isEmpty()) { + if (nativeKey.isEmpty()) { errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; return 0; } // ftok requires that an actual file exists somewhere - QString fileName = makePlatformSafeKey(key); - if (!QFile::exists(fileName)) { + if (!QFile::exists(nativeKey)) { errorString = QSharedMemory::tr("%1: UNIX key file doesn't exist").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::NotFound; return 0; } - unix_key = ftok(QFile::encodeName(fileName).constData(), 'Q'); + unix_key = ftok(QFile::encodeName(nativeKey).constData(), 'Q'); if (-1 == unix_key) { errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; @@ -181,7 +180,7 @@ bool QSharedMemoryPrivate::create(int size) { // build file if needed bool createdFile = false; - int built = createUnixKeyFile(makePlatformSafeKey(key)); + int built = createUnixKeyFile(nativeKey); if (built == -1) { errorString = QSharedMemory::tr("%1: unable to make key").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; @@ -194,7 +193,7 @@ bool QSharedMemoryPrivate::create(int size) // get handle if (!handle()) { if (createdFile) - QFile::remove(makePlatformSafeKey(key)); + QFile::remove(nativeKey); return false; } @@ -210,7 +209,7 @@ bool QSharedMemoryPrivate::create(int size) setErrorString(function); } if (createdFile && error != QSharedMemory::AlreadyExists) - QFile::remove(makePlatformSafeKey(key)); + QFile::remove(nativeKey); return false; } @@ -295,7 +294,7 @@ bool QSharedMemoryPrivate::detach() } // remove file - if (!QFile::remove(makePlatformSafeKey(key))) + if (!QFile::remove(nativeKey)) return false; } return true; diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp index 0f5fdc7..0cdb123 100644 --- a/src/corelib/kernel/qsharedmemory_win.cpp +++ b/src/corelib/kernel/qsharedmemory_win.cpp @@ -99,18 +99,17 @@ HANDLE QSharedMemoryPrivate::handle() { if (!hand) { QString function = QLatin1String("QSharedMemory::handle"); - QString safeKey = makePlatformSafeKey(key); - if (safeKey.isEmpty()) { + if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: unable to make key").arg(function); return false; } #ifndef Q_OS_WINCE - hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)safeKey.utf16()); + hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16()); #else // This works for opening a mapping too, but always opens it with read/write access in // attach as it seems. - hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)safeKey.utf16()); + hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)nativeKey.utf16()); #endif if (!hand) { setErrorString(function); @@ -133,17 +132,15 @@ bool QSharedMemoryPrivate::cleanHandle() bool QSharedMemoryPrivate::create(int size) { - // Get a windows acceptable key - QString safeKey = makePlatformSafeKey(key); QString function = QLatin1String("QSharedMemory::create"); - if (safeKey.isEmpty()) { + if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: key error").arg(function); return false; } // Create the file mapping. - hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)safeKey.utf16()); + hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)nativeKey.utf16()); setErrorString(function); // hand is valid when it already exists unlike unix so explicitly check diff --git a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp index 1f65ae7..dc071ab 100644 --- a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp @@ -225,11 +225,17 @@ void tst_QSharedMemory::key_data() { QTest::addColumn("constructorKey"); QTest::addColumn("setKey"); - - QTest::newRow("null, null") << QString() << QString(); - QTest::newRow("null, one") << QString() << QString("one"); - QTest::newRow("one, two") << QString("one") << QString("two"); - QTest::newRow("invalid") << QString("o/e") << QString("t/o"); + QTest::addColumn("setNativeKey"); + + QTest::newRow("null, null, null") << QString() << QString() << QString(); + QTest::newRow("one, null, null") << QString("one") << QString() << QString(); + QTest::newRow("null, one, null") << QString() << QString("one") << QString(); + QTest::newRow("null, null, one") << QString() << QString() << QString("one"); + QTest::newRow("one, two, null") << QString("one") << QString("two") << QString(); + QTest::newRow("one, null, two") << QString("one") << QString() << QString("two"); + QTest::newRow("null, one, two") << QString() << QString("one") << QString("two"); + QTest::newRow("one, two, three") << QString("one") << QString("two") << QString("three"); + QTest::newRow("invalid") << QString("o/e") << QString("t/o") << QString("|x"); } /*! @@ -239,11 +245,17 @@ void tst_QSharedMemory::key() { QFETCH(QString, constructorKey); QFETCH(QString, setKey); + QFETCH(QString, setNativeKey); QSharedMemory sm(constructorKey); QCOMPARE(sm.key(), constructorKey); + QCOMPARE(sm.nativeKey().isEmpty(), constructorKey.isEmpty()); sm.setKey(setKey); QCOMPARE(sm.key(), setKey); + QCOMPARE(sm.nativeKey().isEmpty(), setKey.isEmpty()); + sm.setNativeKey(setNativeKey); + QVERIFY(sm.key().isNull()); + QCOMPARE(sm.nativeKey(), setNativeKey); QCOMPARE(sm.isAttached(), false); QCOMPARE(sm.error(), QSharedMemory::NoError); @@ -262,7 +274,7 @@ void tst_QSharedMemory::create_data() QTest::addColumn("error"); QTest::newRow("null key") << QString() << 1024 - << false << QSharedMemory::LockError; + << false << QSharedMemory::KeyError; QTest::newRow("-1 size") << QString("negsize") << -1 << false << QSharedMemory::InvalidSize; QTest::newRow("nor size") << QString("norsize") << 1024 @@ -302,7 +314,7 @@ void tst_QSharedMemory::attach_data() QTest::addColumn("exists"); QTest::addColumn("error"); - QTest::newRow("null key") << QString() << false << QSharedMemory::LockError; + QTest::newRow("null key") << QString() << false << QSharedMemory::KeyError; QTest::newRow("doesn't exists") << QString("doesntexists") << false << QSharedMemory::NotFound; QTest::newRow("already exists") << QString(EXISTING_SHARE) << true << QSharedMemory::NoError; } -- cgit v0.12 From 26f3dbf0e20dbaf131bbbb35440b1ecb40b3f405 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 26 May 2010 14:00:15 +0200 Subject: Improved documentation for QSharedMemory's key/setKey functions. --- src/corelib/kernel/qsharedmemory.cpp | 64 +++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index d5f4052..0782ffe 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -194,11 +194,15 @@ QSharedMemory::~QSharedMemory() } /*! - Sets a new \a key for this shared memory object. - The \a key is first converted to a unicode string accepted by all supported platforms, - (see nativeKey()). If \a key and the current key are the same, the function returns - without doing anything. If the shared memory object is attached to an underlying - shared memory segment, it will \l {detach()} {detach} from it before setting the new key. + Sets the platform independent \a key for this shared memory object. If \a key + is the same as the current key, the function returns without doing anything. + + You can call key() to retrieve the platform independent key. Internally, + QSharedMemory converts this key into a platform specific key. If you instead + call nativeKey(), you will get the platform specific, converted key. + + If the shared memory object is attached to an underlying shared memory + segment, it will \l {detach()} {detach} from it before setting the new key. This function does not do an attach(). \sa key() nativeKey() isAttached() @@ -217,16 +221,22 @@ void QSharedMemory::setKey(const QString &key) } /*! - \since 4.7 - Sets a new native \a key for this shared memory object. - The specified \a key is used as-is, without any conversion. The \a key has to be - in a valid format for the current operating system (e.g. under Unix a valid \a key - corresponds to a filename). Be aware that the application might not be portable. - This function returns without doing anything if the \a key equals the current - native key. If the shared memory object is attached to an underlying shared memory + \since 4.8 + + Sets the native, platform specific, \a key for this shared memory object. If + \a key is the same as the current native key, the function returns without + doing anything. If all you want is to assign a key to a segment, you should + call setKey() instead. + + You can call nativeKey() to retrieve the native key. If a native key has been + assigned, calling key() will return a null string. + + If the shared memory object is attached to an underlying shared memory segment, it will \l {detach()} {detach} from it before setting the new key. This function does not do an attach(). + The application will not be portable if you set a native key. + \sa nativeKey() key() isAttached() */ void QSharedMemory::setNativeKey(const QString &key) @@ -282,12 +292,13 @@ bool QSharedMemoryPrivate::initKey() } /*! - Returns the key assigned with setKey() to this shared memory. - The key is the identifier used by Qt applications to identify the shared - memory segment. The actual native key used by the operating system is returned - by nativeKey(). A null string is returned if the key was specified using setNativeKey(). - When QSharedMemory is used for interprocess communication, the key is how each - process attaches to the shared memory segment through which the IPC occurs. + Returns the key assigned with setKey() to this shared memory, or a null key + if no key has been assigned, or if the segment is using a nativeKey(). The + key is the identifier used by Qt applications to identify the shared memory + segment. + + You can find the native, platform specific, key used by the operating system + by calling nativeKey(). \sa setKey() setNativeKey() */ @@ -298,15 +309,14 @@ QString QSharedMemory::key() const } /*! - \since 4.7 - Returns the native key assigned with setKey() or setNativeKey() to this shared memory. - The native key is the identifier used by the operating system to identify the - shared memory segment. When using setKey(), the native key is obtained by - converting the specified key into a format accepted by all supported platforms. - When using setNativeKey(), the native key actually corresponds to the specified key - without any conversion. When QSharedMemory is used for interprocess communication, - the key is how each process attaches to the shared memory segment through which - the IPC occurs. + \since 4.8 + + Returns the native, platform specific, key for this shared memory object. The + native key is the identifier used by the operating system to identify the + shared memory segment. + + You can use the native key to access shared memory segments that have not + been created by Qt, or to grant shared memory access to non-Qt applications. \sa setKey() setNativeKey() */ -- cgit v0.12 From fe08f4841cd9928e7c9ad0b797ede13f473b51b7 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 31 May 2010 09:21:04 +0200 Subject: Fix a simple mistake in QXmlStreamReader::atEnd() docs. Merge-request: 655 Reviewed-by: Andreas Aardal Hanssen --- src/corelib/xml/qxmlstream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() */ -- cgit v0.12 From 8c8f7639c1643473c5c10d4c5b9d3016c9cf070d Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 31 May 2010 10:10:57 +0200 Subject: Revert "Improved documentation for QSharedMemory's key/setKey functions." This reverts commit 26f3dbf0e20dbaf131bbbb35440b1ecb40b3f405. --- src/corelib/kernel/qsharedmemory.cpp | 64 +++++++++++++++--------------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index 0782ffe..d5f4052 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -194,15 +194,11 @@ QSharedMemory::~QSharedMemory() } /*! - Sets the platform independent \a key for this shared memory object. If \a key - is the same as the current key, the function returns without doing anything. - - You can call key() to retrieve the platform independent key. Internally, - QSharedMemory converts this key into a platform specific key. If you instead - call nativeKey(), you will get the platform specific, converted key. - - If the shared memory object is attached to an underlying shared memory - segment, it will \l {detach()} {detach} from it before setting the new key. + Sets a new \a key for this shared memory object. + The \a key is first converted to a unicode string accepted by all supported platforms, + (see nativeKey()). If \a key and the current key are the same, the function returns + without doing anything. If the shared memory object is attached to an underlying + shared memory segment, it will \l {detach()} {detach} from it before setting the new key. This function does not do an attach(). \sa key() nativeKey() isAttached() @@ -221,22 +217,16 @@ void QSharedMemory::setKey(const QString &key) } /*! - \since 4.8 - - Sets the native, platform specific, \a key for this shared memory object. If - \a key is the same as the current native key, the function returns without - doing anything. If all you want is to assign a key to a segment, you should - call setKey() instead. - - You can call nativeKey() to retrieve the native key. If a native key has been - assigned, calling key() will return a null string. - - If the shared memory object is attached to an underlying shared memory + \since 4.7 + Sets a new native \a key for this shared memory object. + The specified \a key is used as-is, without any conversion. The \a key has to be + in a valid format for the current operating system (e.g. under Unix a valid \a key + corresponds to a filename). Be aware that the application might not be portable. + This function returns without doing anything if the \a key equals the current + native key. If the shared memory object is attached to an underlying shared memory segment, it will \l {detach()} {detach} from it before setting the new key. This function does not do an attach(). - The application will not be portable if you set a native key. - \sa nativeKey() key() isAttached() */ void QSharedMemory::setNativeKey(const QString &key) @@ -292,13 +282,12 @@ bool QSharedMemoryPrivate::initKey() } /*! - Returns the key assigned with setKey() to this shared memory, or a null key - if no key has been assigned, or if the segment is using a nativeKey(). The - key is the identifier used by Qt applications to identify the shared memory - segment. - - You can find the native, platform specific, key used by the operating system - by calling nativeKey(). + Returns the key assigned with setKey() to this shared memory. + The key is the identifier used by Qt applications to identify the shared + memory segment. The actual native key used by the operating system is returned + by nativeKey(). A null string is returned if the key was specified using setNativeKey(). + When QSharedMemory is used for interprocess communication, the key is how each + process attaches to the shared memory segment through which the IPC occurs. \sa setKey() setNativeKey() */ @@ -309,14 +298,15 @@ QString QSharedMemory::key() const } /*! - \since 4.8 - - Returns the native, platform specific, key for this shared memory object. The - native key is the identifier used by the operating system to identify the - shared memory segment. - - You can use the native key to access shared memory segments that have not - been created by Qt, or to grant shared memory access to non-Qt applications. + \since 4.7 + Returns the native key assigned with setKey() or setNativeKey() to this shared memory. + The native key is the identifier used by the operating system to identify the + shared memory segment. When using setKey(), the native key is obtained by + converting the specified key into a format accepted by all supported platforms. + When using setNativeKey(), the native key actually corresponds to the specified key + without any conversion. When QSharedMemory is used for interprocess communication, + the key is how each process attaches to the shared memory segment through which + the IPC occurs. \sa setKey() setNativeKey() */ -- cgit v0.12 From 3026f8ce811e8cebc48e49f732344cc13e107cc6 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 31 May 2010 10:11:05 +0200 Subject: Revert "Added native key support to QSharedMemory API." This reverts commit 9b4ff3deb28b3d642dc4480207f2f23841cf26e9. --- src/corelib/kernel/qsharedmemory.cpp | 120 ++++++--------------- src/corelib/kernel/qsharedmemory.h | 2 - src/corelib/kernel/qsharedmemory_p.h | 1 - src/corelib/kernel/qsharedmemory_symbian.cpp | 11 +- src/corelib/kernel/qsharedmemory_unix.cpp | 15 +-- src/corelib/kernel/qsharedmemory_win.cpp | 13 ++- .../auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp | 26 ++--- 7 files changed, 65 insertions(+), 123 deletions(-) diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index d5f4052..fe93ebc 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -142,12 +142,9 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, remain. Do not mix using QtSharedMemory and QSharedMemory. Port everything to QSharedMemory. - \warning QSharedMemory changes the key in a Qt-specific way, unless otherwise - specified. Interoperation with non-Qt applications is achieved by first creating - a default shared memory with QSharedMemory() and then setting a native key with - setNativeKey(). When using native keys, shared memory is not protected against - multiple accesses on it (e.g. unable to lock()) and a user-defined mechanism - should be used to achieve a such protection. + \warning QSharedMemory changes the key in a Qt-specific way. + It is therefore currently not possible to use the shared memory of + non-Qt applications with QSharedMemory. */ /*! @@ -156,8 +153,8 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, Constructs a shared memory object with the given \a parent. The shared memory object's key is not set by the constructor, so the shared memory object does not have an underlying shared memory - segment attached. The key must be set with setKey() or setNativeKey() - before create() or attach() can be used. + segment attached. The key must be set with setKey() before create() + or attach() can be used. \sa setKey() */ @@ -194,52 +191,24 @@ QSharedMemory::~QSharedMemory() } /*! - Sets a new \a key for this shared memory object. - The \a key is first converted to a unicode string accepted by all supported platforms, - (see nativeKey()). If \a key and the current key are the same, the function returns - without doing anything. If the shared memory object is attached to an underlying - shared memory segment, it will \l {detach()} {detach} from it before setting the new key. - This function does not do an attach(). - - \sa key() nativeKey() isAttached() -*/ + Sets a new \a key for this shared memory object. If \a key and the + current key are the same, the function returns without doing + anything. If the shared memory object is attached to an underlying + shared memory segment, it will \l {detach()} {detach} from it before + setting the new key. This function does not do an attach(). + + \sa key() isAttached() + */ void QSharedMemory::setKey(const QString &key) { Q_D(QSharedMemory); - if (key == d->key && d->makePlatformSafeKey(key) == d->nativeKey) + if (key == d->key) return; if (isAttached()) detach(); d->cleanHandle(); d->key = key; - d->nativeKey = d->makePlatformSafeKey(key); -} - -/*! - \since 4.7 - Sets a new native \a key for this shared memory object. - The specified \a key is used as-is, without any conversion. The \a key has to be - in a valid format for the current operating system (e.g. under Unix a valid \a key - corresponds to a filename). Be aware that the application might not be portable. - This function returns without doing anything if the \a key equals the current - native key. If the shared memory object is attached to an underlying shared memory - segment, it will \l {detach()} {detach} from it before setting the new key. - This function does not do an attach(). - - \sa nativeKey() key() isAttached() -*/ -void QSharedMemory::setNativeKey(const QString &key) -{ - Q_D(QSharedMemory); - if (key == d->nativeKey && d->key.isNull()) - return; - - if (isAttached()) - detach(); - d->cleanHandle(); - d->key = QString(); - d->nativeKey = key; } bool QSharedMemoryPrivate::initKey() @@ -282,14 +251,13 @@ bool QSharedMemoryPrivate::initKey() } /*! - Returns the key assigned with setKey() to this shared memory. - The key is the identifier used by Qt applications to identify the shared - memory segment. The actual native key used by the operating system is returned - by nativeKey(). A null string is returned if the key was specified using setNativeKey(). - When QSharedMemory is used for interprocess communication, the key is how each - process attaches to the shared memory segment through which the IPC occurs. - - \sa setKey() setNativeKey() + Returns the key assigned to this shared memory. The key is the + identifier used by the operating system to identify the shared + memory segment. When QSharedMemory is used for interprocess + communication, the key is how each process attaches to the shared + memory segment through which the IPC occurs. + + \sa setKey() */ QString QSharedMemory::key() const { @@ -298,31 +266,13 @@ QString QSharedMemory::key() const } /*! - \since 4.7 - Returns the native key assigned with setKey() or setNativeKey() to this shared memory. - The native key is the identifier used by the operating system to identify the - shared memory segment. When using setKey(), the native key is obtained by - converting the specified key into a format accepted by all supported platforms. - When using setNativeKey(), the native key actually corresponds to the specified key - without any conversion. When QSharedMemory is used for interprocess communication, - the key is how each process attaches to the shared memory segment through which - the IPC occurs. - - \sa setKey() setNativeKey() -*/ -QString QSharedMemory::nativeKey() const -{ - Q_D(const QSharedMemory); - return d->nativeKey; -} - -/*! - Creates a shared memory segment of \a size bytes with the key passed to the - constructor, set with setKey() or set with setNativeKey(), then attaches to - the new shared memory segment with the given access \a mode and returns - \tt true. If a shared memory segment identified by the key already exists, - the attach operation is not performed and \tt false is returned. When the - return value is \tt false, call error() to determine which error occurred. + Creates a shared memory segment of \a size bytes with the key passed + to the constructor or set with setKey(), attaches to the new shared + memory segment with the given access \a mode, and returns \tt true. + If a shared memory segment identified by the key already exists, the + attach operation is not performed, and \tt false is returned. When + the return value is \tt false, call error() to determine which error + occurred. \sa error() */ @@ -344,7 +294,7 @@ bool QSharedMemory::create(int size, AccessMode mode) QString function = QLatin1String("QSharedMemory::create"); #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->key.isNull() && !d->tryLocker(&lock, function)) + if (!d->tryLocker(&lock, function)) return false; #endif @@ -388,7 +338,7 @@ int QSharedMemory::size() const /*! Attempts to attach the process to the shared memory segment identified by the key that was passed to the constructor or to a - call to setKey() or setNativeKey(). The access \a mode is \l {QSharedMemory::} + call to setKey(). The access \a mode is \l {QSharedMemory::} {ReadWrite} by default. It can also be \l {QSharedMemory::} {ReadOnly}. Returns true if the attach operation is successful. If false is returned, call error() to determine which error occurred. @@ -405,7 +355,7 @@ bool QSharedMemory::attach(AccessMode mode) return false; #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::attach"))) + if (!d->tryLocker(&lock, QLatin1String("QSharedMemory::attach"))) return false; #endif @@ -445,7 +395,7 @@ bool QSharedMemory::detach() #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::detach"))) + if (!d->tryLocker(&lock, QLatin1String("QSharedMemory::detach"))) return false; #endif @@ -501,9 +451,9 @@ const void *QSharedMemory::data() const by this process and returns true. If another process has locked the segment, this function blocks until the lock is released. Then it acquires the lock and returns true. If this function returns false, - it means that you have ignored a false return from create() or attach(), - that you have set the key with setNativeKey() or that - QSystemSemaphore::acquire() failed due to an unknown system error. + it means either that you have ignored a false return from create() + or attach(), or that QSystemSemaphore::acquire() failed due to an + unknown system error. \sa unlock(), data(), QSystemSemaphore::acquire() */ diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h index 5673f43..fba939c 100644 --- a/src/corelib/kernel/qsharedmemory.h +++ b/src/corelib/kernel/qsharedmemory.h @@ -85,8 +85,6 @@ public: void setKey(const QString &key); QString key() const; - void setNativeKey(const QString &key); - QString nativeKey() const; bool create(int size, AccessMode mode = ReadWrite); int size() const; diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index 632a6e9..a52f8b3 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -122,7 +122,6 @@ public: void *memory; int size; QString key; - QString nativeKey; QSharedMemory::SharedMemoryError error; QString errorString; #ifndef QT_NO_SYSTEMSEMAPHORE diff --git a/src/corelib/kernel/qsharedmemory_symbian.cpp b/src/corelib/kernel/qsharedmemory_symbian.cpp index 091c2b5..9b84eb56 100644 --- a/src/corelib/kernel/qsharedmemory_symbian.cpp +++ b/src/corelib/kernel/qsharedmemory_symbian.cpp @@ -107,14 +107,16 @@ bool QSharedMemoryPrivate::cleanHandle() bool QSharedMemoryPrivate::create(int size) { + // Get a windows acceptable key + QString safeKey = makePlatformSafeKey(key); QString function = QLatin1String("QSharedMemory::create"); - if (nativeKey.isEmpty()) { + if (safeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: key error").arg(function); return false; } - TPtrC ptr(qt_QString2TPtrC(nativeKey)); + TPtrC ptr(qt_QString2TPtrC(safeKey)); TInt err = chunk.CreateGlobal(ptr, size, size); @@ -134,13 +136,14 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode /* mode */) // Grab a pointer to the memory block if (!chunk.Handle()) { QString function = QLatin1String("QSharedMemory::handle"); - if (nativeKey.isEmpty()) { + QString safeKey = makePlatformSafeKey(key); + if (safeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: unable to make key").arg(function); return false; } - TPtrC ptr(qt_QString2TPtrC(nativeKey)); + TPtrC ptr(qt_QString2TPtrC(safeKey)); TInt err = KErrNoMemory; diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index 064979b..a5f79c2 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -116,20 +116,21 @@ key_t QSharedMemoryPrivate::handle() return unix_key; // don't allow making handles on empty keys - if (nativeKey.isEmpty()) { + if (key.isEmpty()) { errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; return 0; } // ftok requires that an actual file exists somewhere - if (!QFile::exists(nativeKey)) { + QString fileName = makePlatformSafeKey(key); + if (!QFile::exists(fileName)) { errorString = QSharedMemory::tr("%1: UNIX key file doesn't exist").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::NotFound; return 0; } - unix_key = ftok(QFile::encodeName(nativeKey).constData(), 'Q'); + unix_key = ftok(QFile::encodeName(fileName).constData(), 'Q'); if (-1 == unix_key) { errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; @@ -180,7 +181,7 @@ bool QSharedMemoryPrivate::create(int size) { // build file if needed bool createdFile = false; - int built = createUnixKeyFile(nativeKey); + int built = createUnixKeyFile(makePlatformSafeKey(key)); if (built == -1) { errorString = QSharedMemory::tr("%1: unable to make key").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; @@ -193,7 +194,7 @@ bool QSharedMemoryPrivate::create(int size) // get handle if (!handle()) { if (createdFile) - QFile::remove(nativeKey); + QFile::remove(makePlatformSafeKey(key)); return false; } @@ -209,7 +210,7 @@ bool QSharedMemoryPrivate::create(int size) setErrorString(function); } if (createdFile && error != QSharedMemory::AlreadyExists) - QFile::remove(nativeKey); + QFile::remove(makePlatformSafeKey(key)); return false; } @@ -294,7 +295,7 @@ bool QSharedMemoryPrivate::detach() } // remove file - if (!QFile::remove(nativeKey)) + if (!QFile::remove(makePlatformSafeKey(key))) return false; } return true; diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp index 0cdb123..0f5fdc7 100644 --- a/src/corelib/kernel/qsharedmemory_win.cpp +++ b/src/corelib/kernel/qsharedmemory_win.cpp @@ -99,17 +99,18 @@ HANDLE QSharedMemoryPrivate::handle() { if (!hand) { QString function = QLatin1String("QSharedMemory::handle"); - if (nativeKey.isEmpty()) { + QString safeKey = makePlatformSafeKey(key); + if (safeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: unable to make key").arg(function); return false; } #ifndef Q_OS_WINCE - hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16()); + hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)safeKey.utf16()); #else // This works for opening a mapping too, but always opens it with read/write access in // attach as it seems. - hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)nativeKey.utf16()); + hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)safeKey.utf16()); #endif if (!hand) { setErrorString(function); @@ -132,15 +133,17 @@ bool QSharedMemoryPrivate::cleanHandle() bool QSharedMemoryPrivate::create(int size) { + // Get a windows acceptable key + QString safeKey = makePlatformSafeKey(key); QString function = QLatin1String("QSharedMemory::create"); - if (nativeKey.isEmpty()) { + if (safeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: key error").arg(function); return false; } // Create the file mapping. - hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)nativeKey.utf16()); + hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)safeKey.utf16()); setErrorString(function); // hand is valid when it already exists unlike unix so explicitly check diff --git a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp index dc071ab..1f65ae7 100644 --- a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp @@ -225,17 +225,11 @@ void tst_QSharedMemory::key_data() { QTest::addColumn("constructorKey"); QTest::addColumn("setKey"); - QTest::addColumn("setNativeKey"); - - QTest::newRow("null, null, null") << QString() << QString() << QString(); - QTest::newRow("one, null, null") << QString("one") << QString() << QString(); - QTest::newRow("null, one, null") << QString() << QString("one") << QString(); - QTest::newRow("null, null, one") << QString() << QString() << QString("one"); - QTest::newRow("one, two, null") << QString("one") << QString("two") << QString(); - QTest::newRow("one, null, two") << QString("one") << QString() << QString("two"); - QTest::newRow("null, one, two") << QString() << QString("one") << QString("two"); - QTest::newRow("one, two, three") << QString("one") << QString("two") << QString("three"); - QTest::newRow("invalid") << QString("o/e") << QString("t/o") << QString("|x"); + + QTest::newRow("null, null") << QString() << QString(); + QTest::newRow("null, one") << QString() << QString("one"); + QTest::newRow("one, two") << QString("one") << QString("two"); + QTest::newRow("invalid") << QString("o/e") << QString("t/o"); } /*! @@ -245,17 +239,11 @@ void tst_QSharedMemory::key() { QFETCH(QString, constructorKey); QFETCH(QString, setKey); - QFETCH(QString, setNativeKey); QSharedMemory sm(constructorKey); QCOMPARE(sm.key(), constructorKey); - QCOMPARE(sm.nativeKey().isEmpty(), constructorKey.isEmpty()); sm.setKey(setKey); QCOMPARE(sm.key(), setKey); - QCOMPARE(sm.nativeKey().isEmpty(), setKey.isEmpty()); - sm.setNativeKey(setNativeKey); - QVERIFY(sm.key().isNull()); - QCOMPARE(sm.nativeKey(), setNativeKey); QCOMPARE(sm.isAttached(), false); QCOMPARE(sm.error(), QSharedMemory::NoError); @@ -274,7 +262,7 @@ void tst_QSharedMemory::create_data() QTest::addColumn("error"); QTest::newRow("null key") << QString() << 1024 - << false << QSharedMemory::KeyError; + << false << QSharedMemory::LockError; QTest::newRow("-1 size") << QString("negsize") << -1 << false << QSharedMemory::InvalidSize; QTest::newRow("nor size") << QString("norsize") << 1024 @@ -314,7 +302,7 @@ void tst_QSharedMemory::attach_data() QTest::addColumn("exists"); QTest::addColumn("error"); - QTest::newRow("null key") << QString() << false << QSharedMemory::KeyError; + QTest::newRow("null key") << QString() << false << QSharedMemory::LockError; QTest::newRow("doesn't exists") << QString("doesntexists") << false << QSharedMemory::NotFound; QTest::newRow("already exists") << QString(EXISTING_SHARE) << true << QSharedMemory::NoError; } -- cgit v0.12 From 63da3c8981a88261169b0d61636a739467634fa3 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 31 May 2010 10:44:07 +0200 Subject: Remove stray debug --- config.tests/unix/fvisibility.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.tests/unix/fvisibility.test b/config.tests/unix/fvisibility.test index 5bc4b93..27c6841 100755 --- a/config.tests/unix/fvisibility.test +++ b/config.tests/unix/fvisibility.test @@ -1,4 +1,4 @@ -#!/bin/sh -x +#!/bin/sh FVISIBILITY_SUPPORT=no COMPILER=$1 -- cgit v0.12 From 3860340918846b5b156ba8e018d12cfe90461208 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 31 May 2010 12:23:12 +0200 Subject: Fix QT_NO_DIRMODEL build error in QtDeclarative. Reviewed-by: Andreas Aardal Hanssen Merge-request: 652 Merge-request: 652 Reviewed-by: Andreas Aardal Hanssen --- src/imports/folderlistmodel/plugin.cpp | 2 ++ src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp | 4 ++++ src/imports/folderlistmodel/qdeclarativefolderlistmodel.h | 4 ++++ 3 files changed, 10 insertions(+) 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(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 #include +#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 #include +#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 -- cgit v0.12 From e845c0d7a8ed33f2aa2a3ae5ebce931ea2043037 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 31 May 2010 11:45:25 +0200 Subject: Fix compilation with stricts compilers. Base class is type-dependent. One must not use unqualified-id to access base member. Reveiwed-by: Roberto Raggi --- tools/porting/src/codemodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/porting/src/codemodel.h b/tools/porting/src/codemodel.h index cb3088f..04ad178 100644 --- a/tools/porting/src/codemodel.h +++ b/tools/porting/src/codemodel.h @@ -96,7 +96,7 @@ class Collection: public QMultiHash { public: void add(CollectedType *collectedItem) - { insert(collectedItem->name(), collectedItem); } + { this->insert(collectedItem->name(), collectedItem); } }; typedef Collection ScopeCollection; -- cgit v0.12 From aa0b5d35b29fd2f23223e5a4eca4b0d48c74cb2f Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 31 May 2010 13:09:37 +0200 Subject: Doc: replacing old image Task-number: QT-1520 --- .../assistant/doc/images/assistant-assistant.png | Bin 105954 -> 205326 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tools/assistant/tools/assistant/doc/images/assistant-assistant.png b/tools/assistant/tools/assistant/doc/images/assistant-assistant.png index b825de0..1ff5cc9 100644 Binary files a/tools/assistant/tools/assistant/doc/images/assistant-assistant.png and b/tools/assistant/tools/assistant/doc/images/assistant-assistant.png differ -- cgit v0.12 From 817469519a784b1cc84f89cb3cb84f7560874f8e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 31 May 2010 10:00:54 +0200 Subject: Fix unreasonably large width of QTextLayout::boundingRect() When no lineWidth is set on the QTextLine, the QScriptLine::width will be the maximum value that can be represented by QFixed, thus always overriding the width of the bounding rect. The lineWidth of the QTextLine should never be used as the width of the bounding rect, since it's not a calculated value. The real bounding rect is found by querying the natural text width. Task-number: QTBUG-11104 Reviewed-by: Rhys Weatherley --- src/gui/text/qtextlayout.cpp | 2 +- tests/auto/qtextlayout/tst_qtextlayout.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index ce7915d..a1a17af 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -858,7 +858,7 @@ 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)); + xmax = qMax(xmax, si.x+si.textWidth); // ### shouldn't the ascent be used in ymin??? ymax = qMax(ymax, si.y+si.height()); } diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index caf9bd3..b67dc30 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -110,6 +110,7 @@ private slots: void longText(); void widthOfTabs(); void columnWrapWithTabs(); + void boundingRectForUnsetLineWidth(); // QTextLine stuff void setNumColumnsWrapAtWordBoundaryOrAnywhere(); @@ -1307,6 +1308,17 @@ void tst_QTextLayout::columnWrapWithTabs() } +void tst_QTextLayout::boundingRectForUnsetLineWidth() +{ + QTextLayout layout("FOOBAR"); + + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + QCOMPARE(layout.boundingRect().width(), line.naturalTextWidth()); +} + void tst_QTextLayout::lineWidthFromBOM() { const QString string(QChar(0xfeff)); // BYTE ORDER MARK -- cgit v0.12 From b2244174dc4e1858954d7e21cf66bd010d7a8cb4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 31 May 2010 13:40:54 +0200 Subject: Revert behavior of QTextLayout::boundingRect() when line width is set In change 817469519a784b1cc84f89cb3cb84f7560874f8e, there was a behavioral change which can cause regressions, as the bounding rect of the QTextLayout would previously return the set line width when this was greater than the calculated natural text width. We revert to this behavior to avoid regressions and add an autotest for it. When the line width is not set (and si.width is equal to QFIXED_MAX), then we will still return the natural text width. Reviewed-by: Lars --- src/gui/text/qtextlayout.cpp | 3 ++- tests/auto/qtextlayout/tst_qtextlayout.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index a1a17af..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+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/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index b67dc30..1a5f493 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -111,6 +111,7 @@ private slots: void widthOfTabs(); void columnWrapWithTabs(); void boundingRectForUnsetLineWidth(); + void boundingRectForSetLineWidth(); // QTextLine stuff void setNumColumnsWrapAtWordBoundaryOrAnywhere(); @@ -1319,6 +1320,18 @@ void tst_QTextLayout::boundingRectForUnsetLineWidth() QCOMPARE(layout.boundingRect().width(), line.naturalTextWidth()); } +void tst_QTextLayout::boundingRectForSetLineWidth() +{ + QTextLayout layout("FOOBAR"); + + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(QFIXED_MAX - 1); + layout.endLayout(); + + QCOMPARE(layout.boundingRect().width(), qreal(QFIXED_MAX - 1)); +} + void tst_QTextLayout::lineWidthFromBOM() { const QString string(QChar(0xfeff)); // BYTE ORDER MARK -- cgit v0.12 From 098eec2b9ba7218f1b595743476b73b61069d701 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 31 May 2010 13:45:34 +0200 Subject: Doc: Adding note about QDrag::exec() Adding note to the QDrag::exec docs alerting the user about Windows speciffic behaviour. Task-number: QT-640 --- src/gui/kernel/qdrag.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index b57615c..2857bb5 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 while 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) -- cgit v0.12 From de904c51b140e11c801471871632d1d1b552e470 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Mon, 31 May 2010 13:58:08 +0200 Subject: Doc: correcting docs in QDrag::exec --- src/gui/kernel/qdrag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 2857bb5..77f8fc0 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -253,7 +253,7 @@ 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. However, QDrag::exec() on + 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. */ -- cgit v0.12 From c1760352caf33390592ccf5f8eb3401e10aea143 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 31 May 2010 14:37:30 +0200 Subject: Doc: Removed a misleading sentence about a class constructor. Reviewed-by: Trust Me Task-number: QTBUG-10479 --- doc/src/examples/pixelator.qdoc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/src/examples/pixelator.qdoc b/doc/src/examples/pixelator.qdoc index 09ae3e8..95099e1 100644 --- a/doc/src/examples/pixelator.qdoc +++ b/doc/src/examples/pixelator.qdoc @@ -80,8 +80,6 @@ functions to indicate the dimensions of the image and supply data to other components. - For convenience, the image to be used is passed in the constructor. - \section1 ImageModel Class Implementation The constructor is trivial: @@ -89,7 +87,7 @@ \snippet examples/itemviews/pixelator/imagemodel.cpp 0 The \c setImage() function sets the image that will be used by the model: - + \snippet examples/itemviews/pixelator/imagemodel.cpp 1 The QAbstractItemModel::reset() call tells the view(s) that the model @@ -233,7 +231,7 @@ This enables the items to be drawn without any gaps between them. Removing the headers also prevents the user from adjusting the sizes of individual rows and columns. - + We also set the minimum section size to 1 on the headers. If we didn't, the headers would default to a larger size, preventing us from displaying really small items (which can be specified -- cgit v0.12 From cbff8db322bf8e99cb3e062cc47fd2fc0db81ac2 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 31 May 2010 14:49:15 +0200 Subject: Fix QT_NO_VALIDATOR compilation. Merge-request: 648 Reviewed-by: Andreas Aardal Hanssen --- src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp | 4 ++++ src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 ++ src/declarative/graphicsitems/qdeclarativetextinput_p.h | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) 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("Qt",4,7,"PathPercent"); qmlRegisterType("Qt",4,7,"PathQuad"); qmlRegisterType("Qt",4,7,"PathView"); +#ifndef QT_NO_VALIDATOR qmlRegisterType("Qt",4,7,"IntValidator"); qmlRegisterType("Qt",4,7,"DoubleValidator"); qmlRegisterType("Qt",4,7,"RegExpValidator"); +#endif qmlRegisterType("Qt",4,7,"Rectangle"); qmlRegisterType("Qt",4,7,"Repeater"); qmlRegisterType("Qt",4,7,"Rotation"); @@ -138,7 +140,9 @@ void QDeclarativeItemModule::defineModule() qmlRegisterType(); qmlRegisterType(); qmlRegisterType(); +#ifndef QT_NO_VALIDATOR qmlRegisterType(); +#endif qmlRegisterType(); #ifndef QT_NO_ACTION qmlRegisterType(); diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 9c70ea9..305540f 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -648,6 +648,7 @@ void QDeclarativeTextInput::setAutoScroll(bool b) \sa acceptableInput, inputMask */ +#ifndef QT_NO_VALIDATOR QValidator* QDeclarativeTextInput::validator() const { Q_D(const QDeclarativeTextInput); @@ -669,6 +670,7 @@ void QDeclarativeTextInput::setValidator(QValidator* v) emit validatorChanged(); } +#endif // QT_NO_VALIDATOR /*! \qmlproperty string TextInput::inputMask diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index 438293a..3dba844 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) @@ -156,9 +158,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 -- cgit v0.12 From 77474ad850b91e1de080d2f8fb9a60af2f89668f Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 31 May 2010 15:11:57 +0200 Subject: Fix QT_NO_TEXTSTREAM compilation errors. Merge-request: 647 Reviewed-by: Andreas Aardal Hanssen --- src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp | 2 ++ src/declarative/graphicsitems/qdeclarativeitem.cpp | 2 ++ src/declarative/graphicsitems/qdeclarativeitem.h | 2 ++ src/declarative/qml/qdeclarativeinfo.h | 2 ++ src/declarative/qml/qdeclarativeinstruction.cpp | 5 +++++ src/declarative/util/qdeclarativestate.cpp | 2 ++ src/declarative/util/qdeclarativetransitionmanager.cpp | 2 ++ 7 files changed, 17 insertions(+) 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(o); } +#ifndef QT_NO_DEBUG_STREAM QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, QDeclarativeItem *item); +#endif QT_END_NAMESPACE 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(*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/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 & 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 & << "To:" << action.toValue; } } +#endif if (!transition) d->applyBindings(); } -- cgit v0.12 From 54f0a5691899c4b74c71c7718e8e451bdcdbda54 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 31 May 2010 15:44:57 +0200 Subject: Fix QT_NO_DOM Merge-request: 2395 Reviewed-by: Andreas Aardal Hanssen --- src/corelib/global/qfeatures.h | 10 +++++----- src/corelib/global/qfeatures.txt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) 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: ??? -- cgit v0.12 From 55d344acb767226bdf5e1629a44fd7d9a22e4906 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Mon, 31 May 2010 15:56:51 +0200 Subject: Fix QT_NO_TEXTHTMLPARSER Merge-request: 644 Reviewed-by: Andreas Aardal Hanssen --- src/declarative/graphicsitems/qdeclarativetext.cpp | 16 ++++++++++++++++ src/declarative/graphicsitems/qdeclarativetextedit.cpp | 10 ++++++++++ 2 files changed, 26 insertions(+) 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 9ccb8d2..997c666 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -120,9 +120,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(); } @@ -253,7 +255,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); } @@ -318,7 +324,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; -- cgit v0.12 From 51f56d93578be5021fe449da1165cf0c539343b9 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 31 May 2010 16:48:24 +0200 Subject: Updated WebKit to c58dc2f491a824ac56e31c440fcf7fe16dab09c4 Integrate https://trac.webkit.org/changeset/60435 - [Qt] Escape backslashes in the .pro files by Ossi. --- src/3rdparty/webkit/.tag | 2 +- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 10 ++++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- .../webkit/WebKit/qt/Api/DerivedSources.pro | 6 +++--- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 2 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 21 +++++++++++++++++++++ src/3rdparty/webkit/WebKit/qt/docs/docs.pri | 2 +- 8 files changed, 39 insertions(+), 8 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 + + 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 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}$${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 + + 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 + + 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 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 { -- cgit v0.12 From bd786961b0d65bdd1adb31eca0a050a4b9a1f39a Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 31 May 2010 17:02:49 +0200 Subject: Doc: Fixed an off-by-one error in an example. Reviewed-by: Trust Me Task-number: QTBUG-10854 --- examples/itemviews/fetchmore/filelistmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/itemviews/fetchmore/filelistmodel.cpp b/examples/itemviews/fetchmore/filelistmodel.cpp index 05ab45e..942150e 100644 --- a/examples/itemviews/fetchmore/filelistmodel.cpp +++ b/examples/itemviews/fetchmore/filelistmodel.cpp @@ -92,7 +92,7 @@ void FileListModel::fetchMore(const QModelIndex & /* index */) int remainder = fileList.size() - fileCount; int itemsToFetch = qMin(100, remainder); - beginInsertRows(QModelIndex(), fileCount, fileCount+itemsToFetch); + beginInsertRows(QModelIndex(), fileCount, fileCount+itemsToFetch-1); fileCount += itemsToFetch; -- cgit v0.12 From 1fede5dccd56541835046035bb2a8d28d4781e0f Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 31 May 2010 19:51:15 +0200 Subject: Fix Typo --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 935b431..2651ee5 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -570,7 +570,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.) -- cgit v0.12 From 6bd67cf30b1574a114d9852820fe0fb8d3d10c50 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 31 May 2010 20:04:44 +0200 Subject: Fix zoom bug in QML Web Browser demo Zooming out no longer zooms to smaller than the window size. --- demos/declarative/webbrowser/content/FlickableWebView.qml | 4 ++-- demos/declarative/webbrowser/webbrowser.qml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 34e8fff..3a1b515 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -96,8 +96,8 @@ Flickable { function doZoom(zoom,centerX,centerY) { if (centerX) { - var sc = zoom/contentsScale; - scaleAnim.to = zoom; + var sc = zoom*contentsScale; + scaleAnim.to = sc; flickVX.from = flickable.contentX flickVX.to = Math.max(0,Math.min(centerX-flickable.width/2,webView.width*sc-flickable.width)) finalX.value = flickVX.to diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 36e03bf..a923c92 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -47,7 +47,7 @@ import "content" Rectangle { id: webBrowser - property string urlString : "http://qt.nokia.com/" + property string urlString : "http://www.nokia.com/" width: 800; height: 600 color: "#343434" -- cgit v0.12 From fe77b0e466cf1a19663285d240a634e674e022f1 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 31 May 2010 20:42:41 +0200 Subject: Fix some bugs in the QML Web Browser buttons Now with fewer warnings! Also, the stop button works. --- demos/declarative/webbrowser/content/Button.qml | 2 +- demos/declarative/webbrowser/content/FlickableWebView.qml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/declarative/webbrowser/content/Button.qml b/demos/declarative/webbrowser/content/Button.qml index 976502c..4642cc7 100644 --- a/demos/declarative/webbrowser/content/Button.qml +++ b/demos/declarative/webbrowser/content/Button.qml @@ -49,7 +49,7 @@ Item { Image { id: icon; anchors.centerIn: parent - opacity: action.enabled ? 1.0 : 0.4 + opacity: if(action != undefined) {action.enabled ? 1.0 : 0.4} else 0 } MouseArea { diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 3a1b515..62da2ea 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -48,6 +48,7 @@ Flickable { property alias progress: webView.progress property alias url: webView.url property alias back: webView.back + property alias stop: webView.stop property alias reload: webView.reload property alias forward: webView.forward -- cgit v0.12 From 3842b53597526bcfc313f208ace808f3f20951ed Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 1 Jun 2010 10:17:02 +1000 Subject: Fix doc --- doc/src/snippets/declarative/rect-border-width.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/declarative/rect-border-width.qml b/doc/src/snippets/declarative/rect-border-width.qml index 27a241d..1c42226 100644 --- a/doc/src/snippets/declarative/rect-border-width.qml +++ b/doc/src/snippets/declarative/rect-border-width.qml @@ -6,7 +6,7 @@ Rectangle { color: "yellow" Rectangle { - anchor.fill: parent + anchors.fill: parent anchors.margins: 10 clip: true -- cgit v0.12 From bc1fb594d24b54b9c83994817348b0163ef1a9c5 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 1 Jun 2010 10:31:36 +1000 Subject: Fix example code and image --- doc/src/declarative/pics/repeater-modeldata.png | Bin 2600 -> 3394 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/src/declarative/pics/repeater-modeldata.png b/doc/src/declarative/pics/repeater-modeldata.png index 817f35b..6d8df0d 100644 Binary files a/doc/src/declarative/pics/repeater-modeldata.png and b/doc/src/declarative/pics/repeater-modeldata.png differ -- cgit v0.12 From ff93c3562f2b73abb69b1698f71fc9538ca5d999 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 1 Jun 2010 11:36:29 +1000 Subject: Fix positionAt when autoScroll is use. Task-number: QTBUG-11054 --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 25a2b49..3a1acc2 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -852,7 +852,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) -- cgit v0.12 From 5f6b50f99a6457c208c7f186db45a2dba690bace Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 1 Jun 2010 12:39:15 +1000 Subject: Test positionAt. Task-number: QTBUG-11127 Task-number: QTBUG-11054 --- .../tst_qdeclarativetextinput.cpp | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 54bb9c1..c943c89 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -63,6 +63,8 @@ private slots: void color(); void selection(); + void positionAt(); + void maxLength(); void masks(); void validators(); @@ -361,6 +363,47 @@ void tst_qdeclarativetextinput::selection() delete textinputObject; } +void tst_qdeclarativetextinput::positionAt() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); + QVERIFY(canvas->rootObject() != 0); + canvas->show(); + canvas->setFocus(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + + QDeclarativeTextInput *textinputObject = qobject_cast(canvas->rootObject()); + QVERIFY(textinputObject != 0); + + // Check autoscrolled... + QFontMetrics fm(textinputObject->font()); + + int pos = textinputObject->positionAt(textinputObject->width()/2); + int diff = abs(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2)); + + // some tollerance for different fonts. +#ifdef Q_OS_LINUX + QVERIFY(diff < 2); +#else + QVERIFY(diff < 5); +#endif + + // Check without autoscroll... + QEXPECT_FAIL("", "QTBUG-11127", Abort); + textinputObject->setAutoScroll(false); + pos = textinputObject->positionAt(textinputObject->width()/2); + diff = abs(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2); + + // some tollerance for different fonts. +#ifdef Q_OS_LINUX + QVERIFY(diff < 2); +#else + QVERIFY(diff < 5); +#endif + + delete canvas; +} + void tst_qdeclarativetextinput::maxLength() { //QString componentStr = "import Qt 4.7\nTextInput { maximumLength: 10; }"; -- cgit v0.12