Squish: Fix handling of object map

Fix resolving the path to the object map and if no
object map exists yet create it.
As on it fix a typo inside the writing of the file.

Change-Id: I832a2f71bbf5c5d4947e3edba8f79a00a3b6a536
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christian Stenger
2022-10-05 11:05:19 +02:00
parent 5c4441a760
commit 5f4612dd07
3 changed files with 11 additions and 9 deletions

View File

@@ -226,7 +226,7 @@ Core::IDocument::OpenResult ObjectsMapDocument::openImpl(QString *error,
bool ObjectsMapDocument::writeFile(const Utils::FilePath &fileName) const
{
if (fileName.endsWith("object.map")) {
if (fileName.endsWith("objects.map")) {
Utils::FileSaver saver(fileName);
return saver.write(contents()) && saver.finalize();
}

View File

@@ -465,7 +465,10 @@ void SquishFileHandler::openObjectsMap(const QString &suiteName)
const SuiteConf conf = SuiteConf::readSuiteConf(m_suites.value(suiteName));
const Utils::FilePath objectsMapPath = conf.objectMapPath();
if (objectsMapPath.exists()) {
QTC_ASSERT(!objectsMapPath.isEmpty(), return);
QTC_ASSERT(conf.ensureObjectMapExists(), return);
if (!Core::EditorManager::openEditor(objectsMapPath, Constants::OBJECTSMAP_EDITOR_ID)) {
QMessageBox::critical(Core::ICore::dialogParent(),
Tr::tr("Error"),
@@ -473,7 +476,6 @@ void SquishFileHandler::openObjectsMap(const QString &suiteName)
.arg(objectsMapPath.toUserOutput()));
}
}
}
void SquishFileHandler::onSessionLoaded()
{

View File

@@ -189,7 +189,7 @@ Utils::FilePath SuiteConf::objectMapPath() const
if (m_objectMapStyle == "script")
return suiteDir.resolvePath("shared/scripts/names" + scriptExtension());
return suiteDir.resolvePath(m_objectMap);
return suiteDir.resolvePath(m_objectMap.isEmpty() ? QString{"objects.map"} : m_objectMap);
}
QString SuiteConf::scriptExtension() const