+#if ENABLE_STACKTRACE
+ QString temp_path = QStandardPaths::standardLocations(
+ QStandardPaths::TempLocation).at(0);
+ stacktrace_filename = temp_path + "/pv_stacktrace.dmp";
+ qDebug() << "Stack trace file is" << stacktrace_filename;
+
+ ::signal(SIGSEGV, &signal_handler);
+ ::signal(SIGABRT, &signal_handler);
+
+ if (QFileInfo::exists(stacktrace_filename))
+ process_stacktrace(temp_path);
+#endif
+
+#ifdef ANDROID
+ context->set_resource_reader(&asset_reader);
+#endif
+ do {
+
+#ifdef ENABLE_DECODE
+ // Initialise libsigrokdecode
+ if (srd_init(nullptr) != SRD_OK) {
+ qDebug() << "ERROR: libsigrokdecode init failed.";
+ break;
+ }
+
+ // Load the protocol decoders
+ srd_decoder_load_all();
+#endif
+
+#ifndef ENABLE_STACKTRACE
+ try {
+#endif
+
+ // Create the device manager, initialise the drivers
+ pv::DeviceManager device_manager(context, driver, do_scan);
+
+ // Initialise the main window
+ pv::MainWindow w(device_manager);
+ w.show();
+
+ if (restore_sessions)
+ w.restore_sessions();
+
+ if (open_files.empty())
+ w.add_default_session();
+ else
+ for (string open_file : open_files)
+ w.add_session_with_file(open_file, open_file_format);
+
+#ifdef ENABLE_SIGNALS
+ if (SignalHandler::prepare_signals()) {
+ SignalHandler *const handler = new SignalHandler(&w);
+ QObject::connect(handler, SIGNAL(int_received()),
+ &w, SLOT(close()));
+ QObject::connect(handler, SIGNAL(term_received()),
+ &w, SLOT(close()));
+ } else
+ qWarning() << "Could not prepare signal handler.";
+#endif
+
+ // Run the application
+ ret = a.exec();
+
+#ifndef ENABLE_STACKTRACE
+ } catch (exception& e) {
+ qDebug() << "Exception:" << e.what();
+ }
+#endif