Skip to content

Commit

Permalink
Delay window initialization until after CLI arg handling
Browse files Browse the repository at this point in the history
This way we can run `--help` before loading config contents
or running code that might crash.
  • Loading branch information
milianw committed Aug 30, 2023
1 parent 956c938 commit 25e880c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ int main(int argc, char** argv)

initRCCIconTheme();
#endif
QGuiApplication::setWindowIcon(QIcon(QStringLiteral(":/images/icons/512-hotspot_app_icon.png")));

auto* guiApp = qobject_cast<QApplication*>(app.get());
MainWindow* window = nullptr;
if (guiApp) {
setupDockWidgets();
window = new MainWindow();
}

QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("Linux perf GUI for performance analysis."));
Expand Down Expand Up @@ -203,6 +195,14 @@ int main(int argc, char** argv)
return 1;
}

auto* guiApp = qobject_cast<QApplication*>(app.get());
MainWindow* window = nullptr;
if (guiApp) {
QGuiApplication::setWindowIcon(QIcon(QStringLiteral(":/images/icons/512-hotspot_app_icon.png")));
setupDockWidgets();
window = new MainWindow();
}

const auto originalArguments = QCoreApplication::arguments();
// remove leading executable name and trailing positional arguments
const auto minimalArguments = originalArguments.mid(1, originalArguments.size() - 1 - files.size());
Expand Down

0 comments on commit 25e880c

Please sign in to comment.