本文整理汇总了C++中QWeakPointer::toStrongRef方法的典型用法代码示例。如果您正苦于以下问题:C++ QWeakPointer::toStrongRef方法的具体用法?C++ QWeakPointer::toStrongRef怎么用?C++ QWeakPointer::toStrongRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWeakPointer
的用法示例。
在下文中一共展示了QWeakPointer::toStrongRef方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
{
//qDebug();
// See if there is still an existing framebuffer to this WId.
if (m_frameBuffers.contains(id)) {
QWeakPointer<FrameBuffer> weakFrameBuffer = m_frameBuffers.value(id);
if (weakFrameBuffer) {
//qDebug() << "Found cached frame buffer.";
return weakFrameBuffer.toStrongRef();
} else {
//qDebug() << "Found deleted cached frame buffer. Don't use.";
m_frameBuffers.remove(id);
}
}
// We don't already have that frame buffer.
QMap<QString, FrameBufferPlugin *>::const_iterator iter = m_plugins.constBegin();
while (iter != m_plugins.constEnd()) {
if (iter.key() == KrfbConfig::preferredFrameBufferPlugin()) {
qDebug() << "Using FrameBuffer:" << KrfbConfig::preferredFrameBufferPlugin();
QSharedPointer<FrameBuffer> frameBuffer(iter.value()->frameBuffer(id));
if (frameBuffer) {
m_frameBuffers.insert(id, frameBuffer.toWeakRef());
return frameBuffer;
}
}
++iter;
}
// No valid framebuffer plugin found.
qDebug() << "No valid framebuffer found. returning null.";
return QSharedPointer<FrameBuffer>();
}
示例2: run
void GeometryReader::run() {
DependencyManager::get<StatTracker>()->decrementStat("PendingProcessing");
CounterStat counter("Processing");
PROFILE_RANGE_EX(resource_parse_geometry, "GeometryReader::run", 0xFF00FF00, 0, { { "url", _url.toString() } });
auto originalPriority = QThread::currentThread()->priority();
if (originalPriority == QThread::InheritPriority) {
originalPriority = QThread::NormalPriority;
}
QThread::currentThread()->setPriority(QThread::LowPriority);
Finally setPriorityBackToNormal([originalPriority]() {
QThread::currentThread()->setPriority(originalPriority);
});
if (!_resource.data()) {
return;
}
try {
if (_data.isEmpty()) {
throw QString("reply is NULL");
}
// Ensure the resource has not been deleted
auto resource = _resource.toStrongRef();
if (!resource) {
qCWarning(modelnetworking) << "Abandoning load of" << _url << "; could not get strong ref";
return;
}
if (_url.path().isEmpty()) {
throw QString("url is invalid");
}
HFMModel::Pointer hfmModel;
QVariantHash serializerMapping = _mapping.second;
serializerMapping["combineParts"] = _combineParts;
serializerMapping["deduplicateIndices"] = true;
if (_url.path().toLower().endsWith(".gz")) {
QByteArray uncompressedData;
if (!gunzip(_data, uncompressedData)) {
throw QString("failed to decompress .gz model");
}
// Strip the compression extension from the path, so the loader can infer the file type from what remains.
// This is okay because we don't expect the serializer to be able to read the contents of a compressed model file.
auto strippedUrl = _url;
strippedUrl.setPath(_url.path().left(_url.path().size() - 3));
hfmModel = _modelLoader.load(uncompressedData, serializerMapping, strippedUrl, "");
} else {
hfmModel = _modelLoader.load(_data, serializerMapping, _url, _webMediaType.toStdString());
}
if (!hfmModel) {
throw QString("unsupported format");
}
if (hfmModel->meshes.empty() || hfmModel->joints.empty()) {
throw QString("empty geometry, possibly due to an unsupported model version");
}
// Add scripts to hfmModel
if (!serializerMapping.value(SCRIPT_FIELD).isNull()) {
QVariantList scripts = serializerMapping.values(SCRIPT_FIELD);
for (auto &script : scripts) {
hfmModel->scripts.push_back(script.toString());
}
}
// Do processing on the model
baker::Baker modelBaker(hfmModel, _mapping.second, _mapping.first);
modelBaker.run();
auto processedHFMModel = modelBaker.getHFMModel();
auto materialMapping = modelBaker.getMaterialMapping();
QMetaObject::invokeMethod(resource.data(), "setGeometryDefinition",
Q_ARG(HFMModel::Pointer, processedHFMModel), Q_ARG(MaterialMapping, materialMapping));
} catch (const std::exception&) {
auto resource = _resource.toStrongRef();
if (resource) {
QMetaObject::invokeMethod(resource.data(), "finishedLoading",
Q_ARG(bool, false));
}
} catch (QString& e) {
qCWarning(modelnetworking) << "Exception while loading model --" << e;
auto resource = _resource.toStrongRef();
if (resource) {
QMetaObject::invokeMethod(resource.data(), "finishedLoading",
Q_ARG(bool, false));
}
}
}
示例3: sharedFrom
QSharedPointer<QObject> sharedFrom(const QObject *object)
{
QWeakPointer<QObject> weak = WeakPointers()->value(object);
return weak.toStrongRef();
}
示例4: QDialog
AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& manager, QWidget *parent) :
QDialog(parent),
ui(new Ui::AutomatedRssDownloader),
m_manager(manager), m_editedRule(0)
{
ui->setupUi(this);
// Icons
ui->removeRuleBtn->setIcon(IconProvider::instance()->getIcon("list-remove"));
ui->addRuleBtn->setIcon(IconProvider::instance()->getIcon("list-add"));
// Ui Settings
ui->listRules->setSortingEnabled(true);
ui->listRules->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui->treeMatchingArticles->setSortingEnabled(true);
ui->hsplitter->setCollapsible(0, false);
ui->hsplitter->setCollapsible(1, false);
ui->hsplitter->setCollapsible(2, true); // Only the preview list is collapsible
bool ok; Q_UNUSED(ok);
ok = connect(ui->checkRegex, SIGNAL(toggled(bool)), SLOT(updateFieldsToolTips(bool)));
Q_ASSERT(ok);
ok = connect(ui->listRules, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayRulesListMenu(const QPoint&)));
Q_ASSERT(ok);
m_ruleList = manager.toStrongRef()->downloadRules();
m_editableRuleList = new RssDownloadRuleList; // Read rule list from disk
initLabelCombobox();
loadFeedList();
loadSettings();
ok = connect(ui->listRules, SIGNAL(itemSelectionChanged()), SLOT(updateRuleDefinitionBox()));
Q_ASSERT(ok);
ok = connect(ui->listRules, SIGNAL(itemSelectionChanged()), SLOT(updateFeedList()));
Q_ASSERT(ok);
ok = connect(ui->listFeeds, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(handleFeedCheckStateChange(QListWidgetItem*)));
Q_ASSERT(ok);
// Update matching articles when necessary
ok = connect(ui->lineContains, SIGNAL(textEdited(QString)), SLOT(updateMatchingArticles()));
Q_ASSERT(ok);
ok = connect(ui->lineContains, SIGNAL(textEdited(QString)), SLOT(updateMustLineValidity()));
Q_ASSERT(ok);
ok = connect(ui->lineNotContains, SIGNAL(textEdited(QString)), SLOT(updateMatchingArticles()));
Q_ASSERT(ok);
ok = connect(ui->lineNotContains, SIGNAL(textEdited(QString)), SLOT(updateMustNotLineValidity()));
Q_ASSERT(ok);
ok = connect(ui->checkRegex, SIGNAL(stateChanged(int)), SLOT(updateMatchingArticles()));
Q_ASSERT(ok);
ok = connect(ui->checkRegex, SIGNAL(stateChanged(int)), SLOT(updateMustLineValidity()));
Q_ASSERT(ok);
ok = connect(ui->checkRegex, SIGNAL(stateChanged(int)), SLOT(updateMustNotLineValidity()));
Q_ASSERT(ok);
ok = connect(this, SIGNAL(finished(int)), SLOT(on_finished(int)));
Q_ASSERT(ok);
editHotkey = new QShortcut(QKeySequence("F2"), ui->listRules, 0, 0, Qt::WidgetShortcut);
ok = connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedRule()));
Q_ASSERT(ok);
ok = connect(ui->listRules, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedRule()));
Q_ASSERT(ok);
deleteHotkey = new QShortcut(QKeySequence(QKeySequence::Delete), ui->listRules, 0, 0, Qt::WidgetShortcut);
ok = connect(deleteHotkey, SIGNAL(activated()), SLOT(on_removeRuleBtn_clicked()));
Q_ASSERT(ok);
updateRuleDefinitionBox();
updateFeedList();
}