@@ -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__
8976void 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