From: Alexey Chernobaev Date: Tue, 3 Apr 2018 15:28:40 +0000 (+0300) Subject: - 'quick_exit' called on closing the application to avoid possible crashes in case... X-Git-Tag: submit/tizen/20180620.112952^2^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b53c5efec2b56a35586c75b699c7b09b8d3927f;p=sdk%2Ftools%2Fheaptrack.git - 'quick_exit' called on closing the application to avoid possible crashes in case some background operations (e.g. parsing a source file) are still in progress while the main window has already been destroyed; - shorten debuggee name on the Summary page (remove characters starting from __AUL_SDK__) --- diff --git a/src/analyze/gui/mainwindow.cpp b/src/analyze/gui/mainwindow.cpp index 4f8fcde..b8e9bda 100644 --- a/src/analyze/gui/mainwindow.cpp +++ b/src/analyze/gui/mainwindow.cpp @@ -19,6 +19,7 @@ #include "mainwindow.h" #include +#include #ifdef NO_K_LIB #include "noklib.h" @@ -340,7 +341,13 @@ MainWindow::MainWindow(QWidget* parent) const double peakTimeS = 0.001 * data.peakTime; { QTextStream stream(&textLeft); - const auto debuggee = insertWordWrapMarkers(data.debuggee); + QString debuggee = data.debuggee; + int i = debuggee.indexOf(" __AUL_SDK__"); + if (i >= 0) + { + debuggee.resize(i); // Tizen: remove part which is not human-readable + } + debuggee = insertWordWrapMarkers(debuggee); stream << "
" << (data.fromAttached ? i18n("
debuggee:
%1 (attached)
", @@ -640,11 +647,7 @@ MainWindow::~MainWindow() { #ifdef NO_K_LIB qApp->removeEventFilter(this); -#else - auto state = saveState(MAINWINDOW_VERSION); - auto group = m_config->group(Config::Groups::MainWindow); - group.writeEntry(Config::Entries::State, state); -#endif // NO_K_LIB +#endif } void MainWindow::loadFile(const QString& file, const QString& diffBase) @@ -758,20 +761,35 @@ void MainWindow::setupStacks() m_ui->stacksDock->setVisible(false); } -#ifdef NO_K_LIB void MainWindow::closeEvent(QCloseEvent *event) { +#ifdef NO_K_LIB QMainWindow::closeEvent(event); - QSettings settings(QSettings::UserScope, AboutData::Organization, AboutData::applicationName()); - settings.setValue("mainWindowGeometry", saveGeometry()); - settings.setValue("mainWindowState", saveState()); + { + QSettings settings(QSettings::UserScope, AboutData::Organization, AboutData::applicationName()); + settings.setValue("mainWindowGeometry", saveGeometry()); + settings.setValue("mainWindowState", saveState()); #ifdef QWT_FOUND - settings.beginGroup("Charts"); - settings.setValue("Options", ChartOptions::GlobalOptions); - settings.endGroup(); + settings.beginGroup("Charts"); + settings.setValue("Options", ChartOptions::GlobalOptions); + settings.endGroup(); #endif // QWT_FOUND + } +#else + { + auto state = saveState(MAINWINDOW_VERSION); + auto group = m_config->group(Config::Groups::MainWindow); + group.writeEntry(Config::Entries::State, state); + } +#endif // !NO_K_LIB + // the simplest and safest way to close this application (without deep redesing) is to terminate it, + // otherwise a crash is possible if the main window is being closed (and destroyed) while some background + // operations (e.g. parsing a source file) are still in progress; it happens because the code running + // in other threads may emit signals to already destroyed objects + quick_exit(0); // faster alternative to 'exit' } +#ifdef NO_K_LIB bool MainWindow::eventFilter(QObject* object, QEvent* event) { // could process arrow keys (left/right) for flamegraph (to implement back/forward) only from here diff --git a/src/analyze/gui/mainwindow.h b/src/analyze/gui/mainwindow.h index 5cd2254..2fad52f 100644 --- a/src/analyze/gui/mainwindow.h +++ b/src/analyze/gui/mainwindow.h @@ -51,9 +51,9 @@ public slots: signals: void clearData(); -#ifdef NO_K_LIB protected: virtual void closeEvent(QCloseEvent *event) override; +#ifdef NO_K_LIB virtual bool eventFilter(QObject* object, QEvent* event) override; public slots: void selectOpenFile();