make `isGreenEdition` constexpr on Unix (#392)

This commit is contained in:
Cyano Hao 2024-04-24 12:00:26 +08:00 committed by GitHub
parent 4797e53b61
commit 5e9d9504d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -335,10 +335,9 @@ int getNewFileNumber()
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
static bool gIsGreenEdition = true; static bool gIsGreenEdition = true;
static bool gIsGreenEditionInited = false; static bool gIsGreenEditionInited = false;
#endif
bool isGreenEdition() bool isGreenEdition()
{ {
#ifdef Q_OS_WIN
if (!gIsGreenEditionInited) { if (!gIsGreenEditionInited) {
QString appPath = QApplication::instance()->applicationDirPath(); QString appPath = QApplication::instance()->applicationDirPath();
appPath = excludeTrailingPathDelimiter(localizePath(appPath)); appPath = excludeTrailingPathDelimiter(localizePath(appPath));
@ -364,10 +363,8 @@ bool isGreenEdition()
gIsGreenEditionInited = true; gIsGreenEditionInited = true;
} }
return gIsGreenEdition; return gIsGreenEdition;
#else
return false;
#endif
} }
#endif
QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const QStringList& arguments, QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const QStringList& arguments,
const QByteArray &inputContent, bool inheritEnvironment, const QByteArray &inputContent, bool inheritEnvironment,

View File

@ -155,7 +155,11 @@ void executeFile(const QString& fileName,
const QString& workingDir, const QString& workingDir,
const QString& tempFile); const QString& tempFile);
#ifdef Q_OS_WIN
bool isGreenEdition(); bool isGreenEdition();
#else
constexpr bool isGreenEdition() { return false; }
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
bool readRegistry(HKEY key, const QString& subKey, const QString& name, QString& value); bool readRegistry(HKEY key, const QString& subKey, const QString& name, QString& value);