QmlDesigner: Don't export members which are not used outside

Change-Id: I2eb756484a13ce81fd55e7b991d3a509045974e8
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marco Bubke
2021-12-16 11:39:52 +01:00
parent d55b50eabb
commit 3fd3cc307e
2 changed files with 34 additions and 35 deletions

View File

@@ -171,10 +171,7 @@ QmlBuildSystem::QmlBuildSystem(Target *target)
updateDeploymentData(); updateDeploymentData();
} }
QmlBuildSystem::~QmlBuildSystem() QmlBuildSystem::~QmlBuildSystem() = default;
{
delete m_projectItem.data();
}
void QmlBuildSystem::triggerParsing() void QmlBuildSystem::triggerParsing()
{ {
@@ -202,29 +199,32 @@ void QmlBuildSystem::parseProject(RefreshOptions options)
{ {
if (options & Files) { if (options & Files) {
if (options & ProjectFile) if (options & ProjectFile)
delete m_projectItem.data(); m_projectItem.reset();
if (!m_projectItem) { if (!m_projectItem) {
QString errorMessage; QString errorMessage;
m_projectItem = QmlProjectFileFormat::parseProjectFile(projectFilePath(), &errorMessage); m_projectItem.reset(
QmlProjectFileFormat::parseProjectFile(projectFilePath(), &errorMessage));
if (m_projectItem) { if (m_projectItem) {
connect(m_projectItem.data(), &QmlProjectItem::qmlFilesChanged, connect(m_projectItem.get(),
this, &QmlBuildSystem::refreshFiles); &QmlProjectItem::qmlFilesChanged,
this,
&QmlBuildSystem::refreshFiles);
} else { } else {
MessageManager::writeFlashing(tr("Error while loading project file %1.") MessageManager::writeFlashing(
.arg(projectFilePath().toUserOutput())); tr("Error while loading project file %1.").arg(projectFilePath().toUserOutput()));
MessageManager::writeSilently(errorMessage); MessageManager::writeSilently(errorMessage);
} }
} }
if (m_projectItem) { if (m_projectItem) {
m_projectItem.data()->setSourceDirectory(canonicalProjectDir().toString()); m_projectItem->setSourceDirectory(canonicalProjectDir().toString());
if (m_projectItem->targetDirectory().isEmpty()) if (m_projectItem->targetDirectory().isEmpty())
m_projectItem->setTargetDirectory(canonicalProjectDir().toString()); m_projectItem->setTargetDirectory(canonicalProjectDir().toString());
if (auto modelManager = QmlJS::ModelManagerInterface::instance()) if (auto modelManager = QmlJS::ModelManagerInterface::instance())
modelManager->updateSourceFiles(m_projectItem.data()->files(), true); modelManager->updateSourceFiles(m_projectItem->files(), true);
QString mainFilePath = m_projectItem.data()->mainFile(); QString mainFilePath = m_projectItem->mainFile();
if (!mainFilePath.isEmpty()) { if (!mainFilePath.isEmpty()) {
mainFilePath mainFilePath
= QDir(canonicalProjectDir().toString()).absoluteFilePath(mainFilePath); = QDir(canonicalProjectDir().toString()).absoluteFilePath(mainFilePath);
@@ -271,7 +271,7 @@ void QmlBuildSystem::refresh(RefreshOptions options)
QString QmlBuildSystem::mainFile() const QString QmlBuildSystem::mainFile() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->mainFile(); return m_projectItem->mainFile();
return QString(); return QString();
} }
@@ -283,21 +283,21 @@ Utils::FilePath QmlBuildSystem::mainFilePath() const
bool QmlBuildSystem::qtForMCUs() const bool QmlBuildSystem::qtForMCUs() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->qtForMCUs(); return m_projectItem->qtForMCUs();
return false; return false;
} }
bool QmlBuildSystem::qt6Project() const bool QmlBuildSystem::qt6Project() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->qt6Project(); return m_projectItem->qt6Project();
return false; return false;
} }
void QmlBuildSystem::setMainFile(const QString &mainFilePath) void QmlBuildSystem::setMainFile(const QString &mainFilePath)
{ {
if (m_projectItem) if (m_projectItem)
m_projectItem.data()->setMainFile(mainFilePath); m_projectItem->setMainFile(mainFilePath);
} }
Utils::FilePath QmlBuildSystem::targetDirectory() const Utils::FilePath QmlBuildSystem::targetDirectory() const
@@ -322,48 +322,48 @@ Utils::FilePath QmlBuildSystem::targetFile(const Utils::FilePath &sourceFile) co
Utils::EnvironmentItems QmlBuildSystem::environment() const Utils::EnvironmentItems QmlBuildSystem::environment() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->environment(); return m_projectItem->environment();
return {}; return {};
} }
QStringList QmlBuildSystem::customImportPaths() const QStringList QmlBuildSystem::customImportPaths() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->importPaths(); return m_projectItem->importPaths();
return {}; return {};
} }
QStringList QmlBuildSystem::customFileSelectors() const QStringList QmlBuildSystem::customFileSelectors() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->fileSelectors(); return m_projectItem->fileSelectors();
return {}; return {};
} }
QStringList QmlBuildSystem::supportedLanguages() const QStringList QmlBuildSystem::supportedLanguages() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->supportedLanguages(); return m_projectItem->supportedLanguages();
return {}; return {};
} }
void QmlBuildSystem::setSupportedLanguages(QStringList languages) void QmlBuildSystem::setSupportedLanguages(QStringList languages)
{ {
if (m_projectItem) if (m_projectItem)
m_projectItem.data()->setSupportedLanguages(languages); m_projectItem->setSupportedLanguages(languages);
} }
QString QmlBuildSystem::primaryLanguage() const QString QmlBuildSystem::primaryLanguage() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->primaryLanguage(); return m_projectItem->primaryLanguage();
return {}; return {};
} }
void QmlBuildSystem::setPrimaryLanguage(QString language) void QmlBuildSystem::setPrimaryLanguage(QString language)
{ {
if (m_projectItem) if (m_projectItem)
m_projectItem.data()->setPrimaryLanguage(language); m_projectItem->setPrimaryLanguage(language);
} }
void QmlBuildSystem::refreshProjectFile() void QmlBuildSystem::refreshProjectFile()
@@ -581,14 +581,14 @@ QmlProject *QmlBuildSystem::qmlProject() const
bool QmlBuildSystem::forceFreeType() const bool QmlBuildSystem::forceFreeType() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->forceFreeType(); return m_projectItem->forceFreeType();
return false; return false;
} }
bool QmlBuildSystem::widgetApp() const bool QmlBuildSystem::widgetApp() const
{ {
if (m_projectItem) if (m_projectItem)
return m_projectItem.data()->widgetApp(); return m_projectItem->widgetApp();
return false; return false;
} }
@@ -599,7 +599,7 @@ bool QmlBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FilePat
FilePaths toAdd; FilePaths toAdd;
for (const FilePath &filePath : filePaths) { for (const FilePath &filePath : filePaths) {
if (!m_projectItem.data()->matchesFile(filePath.toString())) if (!m_projectItem->matchesFile(filePath.toString()))
toAdd << filePaths; toAdd << filePaths;
} }
return toAdd.isEmpty(); return toAdd.isEmpty();

View File

@@ -112,10 +112,9 @@ public:
// plain format // plain format
void parseProject(RefreshOptions options); void parseProject(RefreshOptions options);
QPointer<QmlProjectItem> m_projectItem;
Utils::FilePath m_canonicalProjectDir;
private: private:
std::unique_ptr<QmlProjectItem> m_projectItem;
Utils::FilePath m_canonicalProjectDir;
bool m_blockFilesUpdate = false; bool m_blockFilesUpdate = false;
friend class FilesUpdateBlocker; friend class FilesUpdateBlocker;
}; };