From cbc2aae63a0af11a31f23f2b6493d855f29bd112 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sun, 3 Mar 2002 21:19:40 +0000 Subject: [PATCH] Cleaned up debugProgram(): now handles the recent exe menu. --- kdbg/dbgmainwnd.cpp | 45 ++++++++++++++++++++++++++++++++------------- kdbg/mainwndbase.cpp | 16 ---------------- kdbg/mainwndbase.h | 2 -- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/kdbg/dbgmainwnd.cpp b/kdbg/dbgmainwnd.cpp index 26fd934..9bb2014 100644 --- a/kdbg/dbgmainwnd.cpp +++ b/kdbg/dbgmainwnd.cpp @@ -6,6 +6,7 @@ #include #include /* i18n */ #include +#include #include #include #include @@ -680,7 +681,35 @@ TTYWindow* DebuggerMainWnd::ttyWindow() bool DebuggerMainWnd::debugProgram(const QString& exe) { - return DebuggerMainWndBase::debugProgram(exe, this); + // check the file name + QFileInfo fi(exe); + + bool success = fi.isFile(); + if (!success) + { + QString msg = i18n("`%1' is not a file or does not exist"); + KMessageBox::sorry(this, msg.arg(exe)); + } + else + { + success = DebuggerMainWndBase::debugProgram(fi.absFilePath(), this); + } + + if (success) + { + addRecentExec(fi.absFilePath()); + + // keep the directory + m_lastDirectory = fi.dirPath(true); + m_filesWindow->setExtraDirectory(m_lastDirectory); + } + else + { + removeRecentExec(fi.absFilePath()); + } + fillRecentExecMenu(); + + return true; } void DebuggerMainWnd::slotNewStatusMsg() @@ -767,12 +796,7 @@ void DebuggerMainWnd::slotRecentExec(int item) { if (item >= 0 && item < int(m_recentExecList.count())) { QString exe = m_recentExecList.at(item); - if (debugProgramInteractive(exe, this)) { - addRecentExec(exe); - } else { - removeRecentExec(exe); - } - fillRecentExecMenu(); + debugProgram(exe); } } @@ -876,12 +900,7 @@ void DebuggerMainWnd::slotFileExe() if (executable.isEmpty()) return; - if (debugProgramInteractive(executable, this)) { - addRecentExec(executable); - } - // this may have changed m_lastDirectory - m_filesWindow->setExtraDirectory(m_lastDirectory); - fillRecentExecMenu(); + debugProgram(executable); } } diff --git a/kdbg/mainwndbase.cpp b/kdbg/mainwndbase.cpp index 3dcbd0a..e331f60 100644 --- a/kdbg/mainwndbase.cpp +++ b/kdbg/mainwndbase.cpp @@ -705,21 +705,5 @@ void DebuggerMainWndBase::removeRecentExec(const QString& executable) } } -bool DebuggerMainWndBase::debugProgramInteractive(const QString& executable, - QWidget* parent) -{ - // check the file name - QFileInfo fi(executable); - m_lastDirectory = fi.dirPath(true); - - if (!fi.isFile()) { - QString msg = i18n("`%1' is not a file or does not exist"); - KMessageBox::sorry(parent, msg.arg(executable)); - return false; - } - - return debugProgram(executable, parent); -} - #include "mainwndbase.moc" diff --git a/kdbg/mainwndbase.h b/kdbg/mainwndbase.h index bb781e8..8ec51a7 100644 --- a/kdbg/mainwndbase.h +++ b/kdbg/mainwndbase.h @@ -85,8 +85,6 @@ public: void addRecentExec(const QString& executable); /** remove recent executable */ void removeRecentExec(const QString& executable); - /** start a new session; error popups appear on errors */ - bool debugProgramInteractive(const QString& executable, QWidget* parent); protected: // settings -- 2.11.4.GIT