Skip to content

Commit

Permalink
fix: AppId fetch error when fallback to applicationName
Browse files Browse the repository at this point in the history
  We shouldn't store appId fallback to applicationName.
  • Loading branch information
18202781743 committed Apr 20, 2023
1 parent d5c4002 commit 2378742
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/dsgapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@ static inline QByteArray getSelfAppId() {
QByteArray selfId = qgetenv("DSG_APP_ID");
if (!selfId.isEmpty())
return selfId;
selfId = DSGApplication::getId(QCoreApplication::applicationPid());
if (selfId.isEmpty() && !qEnvironmentVariableIsSet("DTK_DISABLED_FALLBACK_APPID")) {
selfId = QCoreApplication::applicationName().toLocal8Bit();
}
Q_ASSERT(!selfId.isEmpty());
if (selfId.isEmpty()) {
qt_assert("The application ID is empty", __FILE__, __LINE__);
}
return selfId;
return DSGApplication::getId(QCoreApplication::applicationPid());
}

QByteArray DSGApplication::id()
{
static QByteArray selfId = getSelfAppId();
return selfId;
if (!selfId.isEmpty())
return selfId;
QByteArray result = selfId;
if (!qEnvironmentVariableIsSet("DTK_DISABLED_FALLBACK_APPID")) {
result = QCoreApplication::applicationName().toLocal8Bit();
}
Q_ASSERT(!result.isEmpty());
if (result.isEmpty()) {
qt_assert("The application ID is empty", __FILE__, __LINE__);
}

return result;
}

QByteArray DSGApplication::getId(qint64)
Expand Down

0 comments on commit 2378742

Please sign in to comment.