From d981cfb2802e33b2fc34f96f8b1aceb48986f352 Mon Sep 17 00:00:00 2001 From: Simon Garrelou Date: Thu, 30 Jun 2022 14:38:41 +0200 Subject: [PATCH] Check m_cursor before using it (fix #3) --- ttddbg/src/ttddbg_debugger_manager.cc | 7 ++++--- ttddbg/src/ttddbg_position_chooser.cc | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ttddbg/src/ttddbg_debugger_manager.cc b/ttddbg/src/ttddbg_debugger_manager.cc index 52009f5..5a549ad 100644 --- a/ttddbg/src/ttddbg_debugger_manager.cc +++ b/ttddbg/src/ttddbg_debugger_manager.cc @@ -498,9 +498,10 @@ namespace ttddbg /**********************************************************************/ void DebuggerManager::populatePositionChooser() { - // TODO: use m_engine methods to add timeline positions for each: - // - Thread creation / exit - // - Module load / unload + if (m_cursor == NULL) { + warning("The Timeline is only available while debugging."); + return; + } if (m_positionChooser->get_count() > 0) { // If the position count is > 0 even before populating, it means that diff --git a/ttddbg/src/ttddbg_position_chooser.cc b/ttddbg/src/ttddbg_position_chooser.cc index 98912e3..3e9f20b 100644 --- a/ttddbg/src/ttddbg_position_chooser.cc +++ b/ttddbg/src/ttddbg_position_chooser.cc @@ -86,6 +86,11 @@ namespace ttddbg { /**********************************************************************/ chooser_t::cbret_t PositionChooser::ins(ssize_t n) { + if (m_cursor == NULL) { + warning("Cannot insert a new position when not in debug mode"); + return NOTHING_CHANGED; + } + qstring res; bool ok = ask_str(&res, 0, "Name of the new position");