diff --git a/main.cpp b/main.cpp index d3c6a2e..9da947a 100644 --- a/main.cpp +++ b/main.cpp @@ -36,26 +36,29 @@ #include #include +#ifndef ALWAYS_DEBUG_OUTPUT void noMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { Q_UNUSED(type); Q_UNUSED(context); Q_UNUSED(msg); } +#endif int main(int argc, char *argv[]) { QApplication app(argc, argv); - QString argFile = ""; + + const auto cmdArgs = app.arguments(); #ifndef ALWAYS_DEBUG_OUTPUT - if (app.arguments().contains("--debug") == false) + if (cmdArgs.contains("--debug") == false) qInstallMessageHandler(noMessageOutput); #endif #ifdef Q_OS_MACOS // If not running with root privileges, relaunch executable with sudo. - if (getuid() != 0 && app.arguments().contains("--elevated") == false) + if (getuid() != 0 && cmdArgs.contains("--elevated") == false) { const auto sudoPrompt = QLatin1String{"%1 requires admin permissions."}.arg(app.applicationDisplayName()); const QLatin1String appleScript{"do shell script \"sudo %1\" with prompt \"%2\" with administrator privileges"}; @@ -77,7 +80,7 @@ int main(int argc, char *argv[]) qDebug() << "App data: Version:" << BUILD_VERSION ", Build date: " BUILD_DATE; - if (app.arguments().contains("--no-proxy") == false) { + if (cmdArgs.contains("--no-proxy") == false) { QNetworkProxyQuery npq(QUrl("http://releases.libreelec.tv/")); QList listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq); if (listOfProxies.size()) { @@ -89,9 +92,10 @@ int main(int argc, char *argv[]) Privileges privileges = Privileges(); privileges.Whoami(); + QString argFile; // skip program filename - for (int i=1; i