void QNetworkConfigurationManagerPrivate::deleteConfiguration(QString& iap_id) { /* Called when IAPs are deleted in db, in this case we do not scan * or read all the IAPs from db because it might take too much power * (multiple applications would need to scan and read all IAPs from db) */ if (accessPointConfigurations.contains(iap_id)) { QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.take(iap_id); if (priv.data()) { priv->isValid = false; #ifdef BEARER_MANAGEMENT_DEBUG qDebug() << "IAP" << iap_id << "was removed from storage."; #endif QNetworkConfiguration item; item.d = priv; emit configurationRemoved(item); } else qWarning("Configuration not found for IAP %s", iap_id.toAscii().data()); } else { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("IAP: %s, already missing from the known list", iap_id.toAscii().data()); #endif } }
void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input) { QExplicitlySharedDataPointer<WebContentsAdapter> newWebContents = WebContentsAdapter::createFromSerializedNavigationHistory(input, this); if (newWebContents) { adapter = newWebContents.data(); adapter->initialize(this); } }
void tst_QExplicitlySharedDataPointer::reset() const { /* Do reset on a single ref count. */ { QExplicitlySharedDataPointer<MyClass> pointer(new MyClass()); QVERIFY(pointer.data() != 0); pointer.reset(); QCOMPARE(pointer.data(), static_cast<MyClass *>(0)); } /* Do reset on a default constructed object. */ { QExplicitlySharedDataPointer<MyClass> pointer; QCOMPARE(pointer.data(), static_cast<MyClass *>(0)); pointer.reset(); QCOMPARE(pointer.data(), static_cast<MyClass *>(0)); } }
void QNetworkConfigurationManagerPrivate::configurationRemoved(const QString &id) { if (!accessPointConfigurations.contains(id)) return; QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = accessPointConfigurations.take(id); configurationEngine.remove(id); ptr.data()->isValid = false; if (!firstUpdate) { QNetworkConfiguration item; item.d = ptr; emit configurationRemoved(item); } if (ptr.data()->state == QNetworkConfiguration::Active) { --onlineConfigurations; if (!firstUpdate && onlineConfigurations == 0) emit onlineStateChanged(false); } }
void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration() { if (!snapConfigurations.contains(QLatin1String("Internet Service Network"))) { QNetworkConfigurationPrivate *serviceNetwork = new QNetworkConfigurationPrivate; serviceNetwork->name = tr("Internet"); serviceNetwork->isValid = true; serviceNetwork->id = QLatin1String("Internet Service Network"); serviceNetwork->state = QNetworkConfiguration::Defined; serviceNetwork->type = QNetworkConfiguration::ServiceNetwork; QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(serviceNetwork); snapConfigurations.insert(serviceNetwork->id, ptr); if (!firstUpdate) { QNetworkConfiguration item; item.d = ptr; emit configurationAdded(item); } } QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = snapConfigurations.value(QLatin1String("Internet Service Network")); QList<QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > serviceNetworkMembers; QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> >::const_iterator i = accessPointConfigurations.constBegin(); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined; while (i != accessPointConfigurations.constEnd()) { QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> child = i.value(); if (child.data()->internet && ((child.data()->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined)) { serviceNetworkMembers.append(child); state |= child.data()->state; } ++i; } if (ptr.data()->state != state || ptr.data()->serviceNetworkMembers != serviceNetworkMembers) { ptr.data()->state = state; ptr.data()->serviceNetworkMembers = serviceNetworkMembers; QNetworkConfiguration item; item.d = ptr; emit configurationChanged(item); } }
void tst_QExplicitlySharedDataPointer::data() const { /* Check default value. */ { QExplicitlySharedDataPointer<const MyClass> pointer; QCOMPARE(pointer.data(), static_cast<const MyClass *>(0)); } /* On const pointer. Must not mutate the pointer. */ { const QExplicitlySharedDataPointer<const MyClass> pointer(new MyClass()); pointer.data(); /* Check that this cast is possible. */ static_cast<const MyClass *>(pointer.data()); } /* On mutatable pointer. Must not mutate the pointer. */ { QExplicitlySharedDataPointer<const MyClass> pointer(new MyClass()); pointer.data(); /* Check that this cast is possible. */ static_cast<const MyClass *>(pointer.data()); } /* Must not mutate the pointer. */ { const QExplicitlySharedDataPointer<MyClass> pointer(new MyClass()); pointer.data(); /* Check that these casts are possible. */ static_cast<MyClass *>(pointer.data()); static_cast<const MyClass *>(pointer.data()); } /* Must not mutate the pointer. */ { QExplicitlySharedDataPointer<MyClass> pointer(new MyClass()); pointer.data(); /* Check that these casts are possible. */ static_cast<MyClass *>(pointer.data()); static_cast<const MyClass *>(pointer.data()); } }
void QNetworkConfigurationManagerPrivate::addConfiguration(QString& iap_id) { // Note: When new IAP is created, this function gets called multiple times // in a row. // For example: Empty type & name for WLAN was stored into newly // created IAP data in gconf when this function gets // called for the first time. // WLAN type & name are updated into IAP data in gconf // as soon as WLAN connection is up and running. // => And this function gets called again. if (!accessPointConfigurations.contains(iap_id)) { Maemo::IAPConf saved_iap(iap_id); QString iap_type = saved_iap.value("type").toString(); QString iap_name = saved_iap.value("name").toString(); QByteArray ssid = saved_iap.value("wlan_ssid").toByteArray(); if (!iap_type.isEmpty() && !iap_name.isEmpty()) { // Check if new IAP is actually Undefined WLAN configuration // Note: SSID is used as an iap id for Undefined WLAN configurations // => configuration must be searched using SSID if (!ssid.isEmpty() && accessPointConfigurations.contains(ssid)) { QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = accessPointConfigurations.take(ssid); if (ptr.data()) { ptr->id = iap_id; ptr->iap_type = iap_type; ptr->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString()); ptr->network_id = ssid; ptr->service_id = saved_iap.value("service_id").toString(); ptr->service_type = saved_iap.value("service_type").toString(); if (m_onlineIapId == iap_id) { ptr->state = QNetworkConfiguration::Active; } else { ptr->state = QNetworkConfiguration::Defined; } accessPointConfigurations.insert(iap_id, ptr); configurationChanged(ptr.data()); } } else { QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); cpPriv->name = saved_iap.value("name").toString(); if (cpPriv->name.isEmpty()) cpPriv->name = iap_id; cpPriv->isValid = true; cpPriv->id = iap_id; cpPriv->iap_type = iap_type; cpPriv->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString()); cpPriv->service_id = saved_iap.value("service_id").toString(); cpPriv->service_type = saved_iap.value("service_type").toString(); if (iap_type.startsWith(QLatin1String("WLAN"))) { QByteArray ssid = saved_iap.value("wlan_ssid").toByteArray(); if (ssid.isEmpty()) { qWarning() << "Cannot get ssid for" << iap_id; } cpPriv->network_id = ssid; } cpPriv->type = QNetworkConfiguration::InternetAccessPoint; if (m_onlineIapId == iap_id) { cpPriv->state = QNetworkConfiguration::Active; } else { cpPriv->state = QNetworkConfiguration::Defined; } cpPriv->manager = this; QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(cpPriv); accessPointConfigurations.insert(iap_id, ptr); #ifdef BEARER_MANAGEMENT_DEBUG qDebug("IAP: %s, name: %s, added to known list", iap_id.toAscii().data(), cpPriv->name.toAscii().data()); #endif QNetworkConfiguration item; item.d = ptr; emit configurationAdded(item); } } else { qWarning("IAP %s does not have \"type\" or \"name\" fields defined, skipping this IAP.", iap_id.toAscii().data()); } } else { #ifdef BEARER_MANAGEMENT_DEBUG qDebug() << "IAP" << iap_id << "already in db."; #endif /* Check if the data in db changed and update configuration accordingly */ QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = accessPointConfigurations.value(iap_id); if (ptr.data()) { Maemo::IAPConf changed_iap(iap_id); QString iap_type = changed_iap.value("type").toString(); bool update_needed = false; /* if IAP type or ssid changed, we need to change the state */ ptr->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString()); ptr->service_id = changed_iap.value("service_id").toString(); ptr->service_type = changed_iap.value("service_type").toString(); if (!iap_type.isEmpty()) { ptr->name = changed_iap.value("name").toString(); if (ptr->name.isEmpty()) ptr->name = iap_id; ptr->isValid = true; if (ptr->iap_type != iap_type) { ptr->iap_type = iap_type; update_needed = true; } if (iap_type.startsWith(QLatin1String("WLAN"))) { QByteArray ssid = changed_iap.value("wlan_ssid").toByteArray(); if (ssid.isEmpty()) { qWarning() << "Cannot get ssid for" << iap_id; } if (ptr->network_id != ssid) { ptr->network_id = ssid; update_needed = true; } } } if (update_needed) { ptr->type = QNetworkConfiguration::InternetAccessPoint; if (m_onlineIapId == iap_id) { if (ptr->state < QNetworkConfiguration::Active) { ptr->state = QNetworkConfiguration::Active; configurationChanged(ptr.data()); } } else if (ptr->state < QNetworkConfiguration::Defined) { ptr->state = QNetworkConfiguration::Defined; configurationChanged(ptr.data()); } } } else { qWarning("Cannot find IAP %s from current configuration although it should be there.", iap_id.toAscii().data()); } } }
void QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt &i) { if (!compiledData) return; QML_MEMORY_SCOPE_URL(compiledData->url()); QExplicitlySharedDataPointer<QQmlIncubatorPrivate> protectThis(this); QRecursionWatcher<QQmlIncubatorPrivate, &QQmlIncubatorPrivate::recursion> watcher(this); QQmlEngine *engine = compiledData->engine; QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(engine); if (!vmeGuard.isOK()) { QQmlError error; error.setUrl(compiledData->url()); error.setDescription(QQmlComponent::tr("Object destroyed during incubation")); errors << error; progress = QQmlIncubatorPrivate::Completed; goto finishIncubate; } vmeGuard.clear(); if (progress == QQmlIncubatorPrivate::Execute) { enginePriv->referenceScarceResources(); QObject *tresult = 0; tresult = creator->create(subComponentToCreate, /*parent*/0, &i); if (!tresult) errors = creator->errors; enginePriv->dereferenceScarceResources(); if (watcher.hasRecursed()) return; result = tresult; if (errors.isEmpty() && result == 0) goto finishIncubate; if (result) { QQmlData *ddata = QQmlData::get(result); Q_ASSERT(ddata); //see QQmlComponent::beginCreate for explanation of indestructible ddata->indestructible = true; ddata->explicitIndestructibleSet = true; ddata->rootObjectInCreation = false; if (q) q->setInitialState(result); } if (watcher.hasRecursed()) return; if (errors.isEmpty()) progress = QQmlIncubatorPrivate::Completing; else progress = QQmlIncubatorPrivate::Completed; changeStatus(calculateStatus()); if (watcher.hasRecursed()) return; if (i.shouldInterrupt()) goto finishIncubate; } if (progress == QQmlIncubatorPrivate::Completing) { do { if (watcher.hasRecursed()) return; QQmlContextData *ctxt = 0; ctxt = creator->finalize(i); if (ctxt) { rootContext = ctxt; progress = QQmlIncubatorPrivate::Completed; goto finishIncubate; } } while (!i.shouldInterrupt()); } finishIncubate: if (progress == QQmlIncubatorPrivate::Completed && waitingFor.isEmpty()) { QExplicitlySharedDataPointer<QQmlIncubatorPrivate> isWaiting = waitingOnMe; clear(); if (isWaiting) { QRecursionWatcher<QQmlIncubatorPrivate, &QQmlIncubatorPrivate::recursion> watcher(isWaiting.data()); changeStatus(calculateStatus()); if (!watcher.hasRecursed()) isWaiting->incubate(i); } else { changeStatus(calculateStatus()); } enginePriv->inProgressCreations--; if (0 == enginePriv->inProgressCreations) { while (enginePriv->erroredBindings) { enginePriv->warning(enginePriv->erroredBindings); enginePriv->erroredBindings->removeError(); } } } else if (!creator.isNull()) { vmeGuard.guard(creator.data()); } }
void CallbackDirectory::registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<BoolCallback> &callback) { m_callbackMap.insert(requestId, CallbackSharedDataPointer(callback.data())); }
void StaticContext::wrapExpressionWith(const SourceLocationReflection *const existingNode, const QExplicitlySharedDataPointer<Expression> &newNode) { addLocation(newNode.data(), locationFor(existingNode)); }
void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigurationPrivate *cpPriv) { if (!accessPointConfigurations.contains(cpPriv->id)) return; QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr = accessPointConfigurations.value(cpPriv->id); if (ptr.data()->isValid != cpPriv->isValid || ptr.data()->name != cpPriv->name || ptr.data()->id != cpPriv->id || ptr.data()->state != cpPriv->state || ptr.data()->type != cpPriv->type || ptr.data()->roamingSupported != cpPriv->roamingSupported || ptr.data()->purpose != cpPriv->purpose || ptr.data()->bearer != cpPriv->bearer || ptr.data()->internet != cpPriv->internet) { const QNetworkConfiguration::StateFlags oldState = ptr.data()->state; ptr.data()->isValid = cpPriv->isValid; ptr.data()->name = cpPriv->name; ptr.data()->id = cpPriv->id; ptr.data()->state = cpPriv->state; ptr.data()->type = cpPriv->type; ptr.data()->roamingSupported = cpPriv->roamingSupported; ptr.data()->purpose = cpPriv->purpose; ptr.data()->internet = cpPriv->internet; ptr.data()->bearer = cpPriv->bearer; if (!firstUpdate) { QNetworkConfiguration item; item.d = ptr; emit configurationChanged(item); } if (ptr.data()->state == QNetworkConfiguration::Active && oldState != ptr.data()->state) { // configuration went online ++onlineConfigurations; if (!firstUpdate && onlineConfigurations == 1) emit onlineStateChanged(true); } else if (ptr.data()->state != QNetworkConfiguration::Active && oldState == QNetworkConfiguration::Active) { // configuration went offline --onlineConfigurations; if (!firstUpdate && onlineConfigurations == 0) emit onlineStateChanged(false); } } }
void KstViewFitsDialog::fitChanged(const QString& strFit) { KstCPluginList fits; KstCPluginPtr plugin; double* params = 0L; double* covars = 0L; double chi2Nu = 0.0; int numParams = 0; int numCovars = 0; int i; fits = kstObjectSubList<KstDataObject,KstCPlugin>(KST::dataObjectList); plugin = *(fits.findTag(strFit)); if (plugin) { KstScalarPtr scalarChi2Nu; KstVectorPtr vectorParam; plugin->readLock(); const KstScalarMap& scalars = plugin->outputScalars(); scalarChi2Nu = scalars["chi^2/nu"]; if (scalarChi2Nu) { scalarChi2Nu->readLock(); chi2Nu = scalarChi2Nu->value(); scalarChi2Nu->unlock(); } const KstVectorMap& vectors = plugin->outputVectors(); vectorParam = vectors["Parameters"]; if (vectorParam) { KstVectorPtr vectorCovar; vectorParam->readLock(); vectorCovar = vectors["Covariance"]; if (vectorCovar) { vectorCovar->readLock(); numParams = vectorParam->length(); numCovars = vectorCovar->length(); if (numParams > 0 && numCovars > 0) { params = new double[numParams]; covars = new double[numCovars]; for (i = 0; i < numParams; i++) { params[i] = vectorParam->value(i); } for (i = 0; i < numCovars; i++) { covars[i] = vectorCovar->value(i); } } vectorCovar->unlock(); } vectorParam->unlock(); } plugin->unlock(); } _tableFits->setParameters(params, numParams, covars, numCovars, chi2Nu); if (numParams > 0) { _tableFits->horizontalHeaderItem(0)->setText(QObject::tr("Value")); _tableFits->horizontalHeaderItem(1)->setText(QObject::tr("Covariance:")); _tableFits->verticalHeaderItem(numParams+0)->setText("---"); _tableFits->verticalHeaderItem(numParams+1)->setText(QObject::tr("Chi^2/Nu")); if (plugin) { QExplicitlySharedDataPointer<Plugin> pluginBase; plugin->readLock(); pluginBase = plugin->plugin(); if (pluginBase) { textLabelFit->setText(pluginBase->data()._readableName); for (i = 0; i < numParams; i++) { QString parameterName = pluginBase->parameterName(i); _tableFits->horizontalHeaderItem(i+2)->setText(parameterName); _tableFits->verticalHeaderItem(i)->setText(parameterName); } } plugin->unlock(); } } _tableFits->update(); }