From 1ea768b11222caefc4eb9bb7a2a872628f13ef8d Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Sun, 2 Feb 2025 13:48:46 -0600 Subject: [PATCH] Fixed bug with ordering of message tabs. --- src/SeerConsoleWidget.cpp | 4 ++-- src/SeerGdbWidget.cpp | 37 +++++++++++++++++++++++++++++++------ src/SeerGdbWidget.h | 5 +++++ src/SeerUtl.cpp | 13 +++++++++++++ src/SeerUtl.h | 5 +---- 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/SeerConsoleWidget.cpp b/src/SeerConsoleWidget.cpp index 28dba2b..c759827 100644 --- a/src/SeerConsoleWidget.cpp +++ b/src/SeerConsoleWidget.cpp @@ -359,7 +359,7 @@ void SeerConsoleWidget::deleteConsole () { void SeerConsoleWidget::connectConsole () { if (isConsoleConnected()) { - qDebug() << "Console is already connected!"; + //qDebug() << "Console is already connected!"; return; } @@ -376,7 +376,7 @@ void SeerConsoleWidget::connectConsole () { void SeerConsoleWidget::disconnectConsole () { if (isConsoleConnected() == false) { - qDebug() << "Console is already disconnected!"; + //qDebug() << "Console is already disconnected!"; return; } diff --git a/src/SeerGdbWidget.cpp b/src/SeerGdbWidget.cpp index fa50a8b..14522b4 100644 --- a/src/SeerGdbWidget.cpp +++ b/src/SeerGdbWidget.cpp @@ -70,6 +70,7 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) { _rememberManualCommandCount = 10; _currentFrame = -1; + setIsQuitting(false); setNewExecutableFlag(true); setupUi(this); @@ -141,6 +142,9 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) { // Restore tab ordering. readLogsSettings(); + // Handle the app's 'quit' event, in case we want to do things before exiting. + QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &SeerGdbWidget::handleAboutToQuit); + // Connect things. QObject::connect(logsTabWidget->tabBar(), &QTabBar::tabMoved, this, &SeerGdbWidget::handleLogsTabMoved); QObject::connect(logsTabWidget->tabBar(), &QTabBar::currentChanged, this, &SeerGdbWidget::handleLogsTabChanged); @@ -363,6 +367,7 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) { // Restore window settings. readSettings(); + } SeerGdbWidget::~SeerGdbWidget () { @@ -693,6 +698,11 @@ void SeerGdbWidget::handleLogsTabMoved (int from, int to) { Q_UNUSED(from); Q_UNUSED(to); + // Don't handle anything here if Seer is exiting. + if (isQuitting()) { + return; + } + writeLogsSettings(); } @@ -700,6 +710,11 @@ void SeerGdbWidget::handleLogsTabChanged (int index) { Q_UNUSED(index); + // Don't handle anything here if Seer is exiting. + if (isQuitting()) { + return; + } + writeLogsSettings(); } @@ -725,8 +740,8 @@ void SeerGdbWidget::writeLogsSettings () { QString current = logsTabWidget->tabBar()->tabText(logsTabWidget->tabBar()->currentIndex()); - qDebug() << "Tabs" << tabs; - qDebug() << "Current" << current; + //qDebug() << "Tabs" << tabs; + //qDebug() << "Current" << current; QSettings settings; @@ -2001,8 +2016,6 @@ void SeerGdbWidget::handleGdbBreakpointCommand (QString breakpoint, QString comm return; } - qDebug().noquote() << "XXX: " << breakpoint << command; - handleGdbCommand("-break-commands " + breakpoint + " \"" + command + "\""); handleGdbGenericpointList(); } @@ -2859,6 +2872,12 @@ void SeerGdbWidget::handleConsoleModeChanged () { } } +void SeerGdbWidget::handleAboutToQuit () { + + // Detect if we're exiting Seer. + setIsQuitting(true); +} + void SeerGdbWidget::writeSettings () { //qDebug() << "Write Settings"; @@ -3070,6 +3089,14 @@ void SeerGdbWidget::readSettings () { } settings.endGroup(); } +bool SeerGdbWidget::isQuitting () const { + return _isQuitting; +} + +void SeerGdbWidget::setIsQuitting (bool f) { + _isQuitting = f; +} + bool SeerGdbWidget::isGdbRuning () const { if (_gdbProcess->state() == QProcess::NotRunning) { @@ -3237,8 +3264,6 @@ void SeerGdbWidget::createConsole () { setConsoleMode(consoleMode()); setConsoleScrollLines(consoleScrollLines()); - - writeLogsSettings(); } } diff --git a/src/SeerGdbWidget.h b/src/SeerGdbWidget.h index 8096c0b..4bd5976 100644 --- a/src/SeerGdbWidget.h +++ b/src/SeerGdbWidget.h @@ -334,6 +334,7 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm { void handleGdbProcessErrored (QProcess::ProcessError errorStatus); void handleConsoleModeChanged (); + void handleAboutToQuit (); signals: void stoppingPointReached (); @@ -346,6 +347,9 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm { void readLogsSettings (); private: + bool isQuitting () const; + void setIsQuitting (bool f); + bool isGdbRuning () const; bool startGdb (); bool startGdbRR (); @@ -357,6 +361,7 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm { SeerConsoleWidget* console (); void sendGdbInterrupt (int signal); + bool _isQuitting; QString _gdbProgram; QString _gdbArguments; QString _gdbProgramOverride; diff --git a/src/SeerUtl.cpp b/src/SeerUtl.cpp index 07be08b..3c2a4ed 100644 --- a/src/SeerUtl.cpp +++ b/src/SeerUtl.cpp @@ -6,6 +6,13 @@ #include #include +// Comment out for now. I don't want to include boost because +// that would impact people try to compile Seer. Qt6 offer +// a 'stacktrace' function. OpenSuse may be slow in adoption. +// For now, comment it out and use when needed. +// #include + +#include #include // @@ -1258,5 +1265,11 @@ namespace Seer { return result; } + + void printStackTrace () { + // Capture and print the stack trace using Boost.Stacktrace. + // See comments at top. + // std::cout << "Stack trace:\n" << boost::stacktrace::stacktrace() << std::endl; + } } diff --git a/src/SeerUtl.h b/src/SeerUtl.h index dffb28f..7323360 100644 --- a/src/SeerUtl.h +++ b/src/SeerUtl.h @@ -31,9 +31,7 @@ namespace Seer { QString elideText (const QString& str, Qt::TextElideMode mode, int length); QStringList split (const QString& str); QString unescape (const QString& str); - int createID (); - unsigned char ebcdicToAscii (unsigned char byte); unsigned char ucharToAscii (unsigned char byte); QString ucharToHex (const QVector& bytes, int from, int count); @@ -47,9 +45,8 @@ namespace Seer { QString ucharToLong (const QVector& bytes, int from, int count); QString ucharToFloat (const QVector& bytes, int from, int count); QString ucharToDouble (const QVector& bytes, int from, int count); - int typeBytes (const QString& type); - bool readFile (const QString& filename, QStringList& lines); + void printStackTrace (); }