From 516e590392ed1f4ead816731bfd95fc3c4690b9f Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Fri, 23 May 2014 18:33:45 +0200 Subject: [PATCH] Also handle case with no filename provided --- src/main.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main.cxx b/src/main.cxx index 74d1325..80e06ce 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -18,6 +18,8 @@ using std::cerr; int main(int argc, char** argv) { + QApplication app(argc, argv); + log4cxx::BasicConfigurator::configure(); log4cxx::LoggerPtr _logger(log4cxx::Logger::getLogger("main")); @@ -28,7 +30,7 @@ int main(int argc, char** argv) parser.addVersionOption(); parser.addPositionalArgument("filename", QCoreApplication::translate("main", "File to disassemble.")); - QApplication app(argc, argv); + parser.process(app); LOG4CXX_DEBUG(_logger, "Initializing LLVM"); @@ -39,8 +41,14 @@ int main(int argc, char** argv) LOG4CXX_DEBUG(_logger, "Initializing Qt"); - Mainwindow m(parser.positionalArguments().at(0).toStdString()); - m.show(); + std::string filename; + if (parser.positionalArguments().isEmpty()) { + filename = ""; + } else { + filename = parser.positionalArguments().at(0).toStdString(); + } - return app.exec(); + Mainwindow m(filename); + m.show(); + return app.exec(); } -- 2.39.5