Skip to content

Commit 04f9af4

Browse files
committed
updates.
Signed-off-by: andreidanila1 <andrei.danila@analog.com>
1 parent d7c86d4 commit 04f9af4

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

core/include/core/application_restarter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class SCOPY_CORE_EXPORT ApplicationRestarter
4444
#endif
4545

4646
private:
47+
#ifdef __linux__
4748
static QStringList buildSudoEnvArgs();
49+
#endif
4850

4951
static ApplicationRestarter *pinstance_;
5052
QString m_executable;

core/src/application_restarter.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ void ApplicationRestarter::triggerRestart()
7272
qApp->exit();
7373
}
7474

75-
QStringList ApplicationRestarter::buildSudoEnvArgs()
76-
{
77-
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
78-
const QStringList envKeys = env.keys();
79-
QStringList envArgs;
80-
81-
for(const QString &key : envKeys) {
82-
envArgs << QString("%1=%2").arg(key, env.value(key));
83-
}
84-
85-
return envArgs;
86-
}
87-
8875
#ifdef __linux__
8976
void ApplicationRestarter::triggerRestartWithSudo()
9077
{
@@ -93,13 +80,17 @@ void ApplicationRestarter::triggerRestartWithSudo()
9380
}
9481

9582
ApplicationRestarter *instance = GetInstance();
83+
if(!instance) {
84+
return;
85+
}
86+
9687
QString executable;
9788

9889
#ifdef __appimage__
9990
executable = qEnvironmentVariable("APPIMAGE");
10091
if(executable.isEmpty()) {
101-
qWarning() << "APPIMAGE environment variable not set";
102-
return;
92+
qWarning() << "APPIMAGE environment variable not set, falling back to executable path";
93+
executable = QFileInfo(instance->m_executable).absoluteFilePath();
10394
}
10495
#else
10596
executable = QFileInfo(instance->m_executable).absoluteFilePath();
@@ -117,4 +108,17 @@ void ApplicationRestarter::triggerRestartWithSudo()
117108
instance->m_restart = false;
118109
qApp->exit();
119110
}
111+
112+
QStringList ApplicationRestarter::buildSudoEnvArgs()
113+
{
114+
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
115+
const QStringList envKeys = env.keys();
116+
QStringList envArgs;
117+
118+
for(const QString &key : envKeys) {
119+
envArgs << QString("%1=%2").arg(key, env.value(key));
120+
}
121+
122+
return envArgs;
123+
}
120124
#endif

0 commit comments

Comments
 (0)