diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp index 21060c6ae71..16a5a35a18e 100644 --- a/src/plugins/resourceeditor/resourceeditorplugin.cpp +++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp @@ -229,7 +229,8 @@ void ResourceEditorPlugin::onRefresh() void ResourceEditorPlugin::addPrefixContextMenu() { - auto topLevel = static_cast(ProjectTree::currentNode()); + auto topLevel = dynamic_cast(ProjectTree::currentNode()); + QTC_ASSERT(topLevel, return); PrefixLangDialog dialog(tr("Add Prefix"), QString(), QString(), Core::ICore::mainWindow()); if (dialog.exec() != QDialog::Accepted) return; @@ -241,7 +242,8 @@ void ResourceEditorPlugin::addPrefixContextMenu() void ResourceEditorPlugin::removePrefixContextMenu() { - ResourceFolderNode *rfn = static_cast(ProjectTree::currentNode()); + auto rfn = dynamic_cast(ProjectTree::currentNode()); + QTC_ASSERT(rfn, return); if (QMessageBox::question(Core::ICore::mainWindow(), tr("Remove Prefix"), tr("Remove prefix %1 and all its files?").arg(rfn->displayName())) @@ -253,7 +255,8 @@ void ResourceEditorPlugin::removePrefixContextMenu() void ResourceEditorPlugin::removeNonExisting() { - ResourceTopLevelNode *topLevel = static_cast(ProjectTree::currentNode()); + auto topLevel = dynamic_cast(ProjectTree::currentNode()); + QTC_ASSERT(topLevel, return); topLevel->removeNonExistingFiles(); } @@ -264,7 +267,8 @@ void ResourceEditorPlugin::renameFileContextMenu() void ResourceEditorPlugin::removeFileContextMenu() { - ResourceFolderNode *rfn = static_cast(ProjectTree::currentNode()); + auto rfn = dynamic_cast(ProjectTree::currentNode()); + QTC_ASSERT(rfn, return); QString path = rfn->filePath().toString(); FolderNode *parent = rfn->parentFolderNode(); if (!parent->removeFiles(QStringList() << path)) @@ -280,19 +284,22 @@ void ResourceEditorPlugin::openEditorContextMenu() void ResourceEditorPlugin::copyPathContextMenu() { - ResourceFileNode *node = static_cast(ProjectTree::currentNode()); + auto node = dynamic_cast(ProjectTree::currentNode()); + QTC_ASSERT(node, return); QApplication::clipboard()->setText(QLatin1String(resourcePrefix) + node->qrcPath()); } void ResourceEditorPlugin::copyUrlContextMenu() { - ResourceFileNode *node = static_cast(ProjectTree::currentNode()); + auto node = dynamic_cast(ProjectTree::currentNode()); + QTC_ASSERT(node, return); QApplication::clipboard()->setText(QLatin1String(urlPrefix) + node->qrcPath()); } void ResourceEditorPlugin::renamePrefixContextMenu() { - ResourceFolderNode *node = static_cast(ProjectTree::currentNode()); + auto node = dynamic_cast(ProjectTree::currentNode()); + QTC_ASSERT(node, return); PrefixLangDialog dialog(tr("Rename Prefix"), node->prefix(), node->lang(), Core::ICore::mainWindow()); if (dialog.exec() != QDialog::Accepted) @@ -350,7 +357,8 @@ void ResourceEditorPlugin::updateContextActions() m_copyUrl->setEnabled(isResourceFile); m_copyUrl->setVisible(isResourceFile); if (isResourceFile) { - ResourceFileNode *fileNode = static_cast(node); + auto fileNode = dynamic_cast(node); + QTC_ASSERT(fileNode, return); QString qrcPath = fileNode->qrcPath(); m_copyPath->setParameter(QLatin1String(resourcePrefix) + qrcPath); m_copyUrl->setParameter(QLatin1String(urlPrefix) + qrcPath); diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp index 63a534c4d6e..2c37480812e 100644 --- a/src/plugins/resourceeditor/resourcenode.cpp +++ b/src/plugins/resourceeditor/resourcenode.cpp @@ -304,10 +304,10 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInfor // The ResourceFolderNode '/' defers to us, as otherwise // two nodes would be responsible for '/' // Thus also return a high priority for it - if (ResourceFolderNode *rfn = dynamic_cast(context)) + if (auto rfn = dynamic_cast(context)) if (rfn->prefix() == QLatin1String("/") && rfn->parentFolderNode() == this) p = 120; - if (SimpleResourceFolderNode *rfn = dynamic_cast(context)) + if (auto rfn = dynamic_cast(context)) if (rfn->prefix() == QLatin1String("/") && rfn->resourceNode() == this) p = 120; } @@ -456,7 +456,7 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceFolderNode::addNewInforma if (context == this) p = 120; - if (SimpleResourceFolderNode *sfn = dynamic_cast(context)) { + if (auto sfn = dynamic_cast(context)) { if (sfn->prefixNode() == this) p = 120; }