Skip to content

Commit

Permalink
Fix #12389 (GUI: premiumaddon is not executed properly anymore)
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Jan 30, 2024
1 parent cecbe18 commit 3faa7c3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gui/projectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,9 @@ void ProjectFile::SafeChecks::saveToXml(QXmlStreamWriter &xmlWriter) const

QString ProjectFile::getAddonFilePath(QString filesDir, const QString &addon)
{
if (QFile(addon).exists())
return addon;

if (!filesDir.endsWith("/"))
filesDir += "/";

Expand Down
19 changes: 19 additions & 0 deletions gui/test/projectfile/testprojectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <QList>
#include <QStringList>
#include <QTemporaryDir>
#include <QtTest>

// Mock...
Expand Down Expand Up @@ -116,4 +117,22 @@ void TestProjectFile::loadSimpleNoroot() const
QCOMPARE(defines[0], QString("FOO"));
}

void TestProjectFile::getAddonFilePath() const
{
QTemporaryDir tempdir;
QVERIFY(tempdir.isValid());
const QString filepath(tempdir.path() + "/addon.py");

QFile file(filepath);
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
file.write("");
file.close();

// Relative path to addon
QCOMPARE(ProjectFile::getAddonFilePath(tempdir.path(), "addon"), filepath);

// Absolute path to addon
QCOMPARE(ProjectFile::getAddonFilePath("/not/exist", filepath), filepath);
}

QTEST_MAIN(TestProjectFile)
2 changes: 2 additions & 0 deletions gui/test/projectfile/testprojectfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ private slots:
void loadSimple() const;
void loadSimpleWithIgnore() const;
void loadSimpleNoroot() const;

void getAddonFilePath() const;
};

0 comments on commit 3faa7c3

Please sign in to comment.