Patch #2889 2009-12-29 21:58

techy

Check if the selected item is valid (debug17)
Download
2889-Check_if_the_s.patch (1.9 KB)
Category
Plugin::Bugfix
Status
Out of date
Close date
2012-12-17 19:28
Assigned to
mortenmacfly
Index: /home/techy/Downloads/codeblocks/trunk/src/plugins/debuggergdb/debuggertree.cpp
===================================================================
--- /home/techy/Downloads/codeblocks/trunk/src/plugins/debuggergdb/debuggertree.cpp    (revision 5987)
+++ /home/techy/Downloads/codeblocks/trunk/src/plugins/debuggergdb/debuggertree.cpp    (working copy)
@@ -589,24 +589,29 @@
     wxMenu menu(wxEmptyString);
 
     // if we right-clicked on a pointer, add a "dereference pointer" entry
-    wxString itemtext = m_pTree->GetItemText(id);
-    if (itemtext.Find(_T('*')) != wxNOT_FOUND)
+    if (id.IsOk())
     {
-        menu.Append(idDereferenceValue, wxString::Format(_("Dereference pointer '%s'"), itemtext.BeforeFirst(_T('=')).c_str()));
-        menu.AppendSeparator();
+        wxString itemtext = m_pTree->GetItemText(id);
+        if (itemtext.Find(_T('*')) != wxNOT_FOUND)
+        {
+            menu.Append(idDereferenceValue, wxString::Format(_("Dereference pointer '%s'"), itemtext.BeforeFirst(_T('=')).c_str()));
+            menu.AppendSeparator();
+        }
     }
-
+    
     // add watch always visible
     menu.Append(idAddWatch, _("&Add watch"));
     menu.Append(idWatchThis, _("Watch '*&this'"));
 
     // we have to have a valid id for the following to be enabled
-    WatchTreeData* data = dynamic_cast<WatchTreeData*>(m_pTree->GetItemData(id));
-    if (id.IsOk() && // valid item
-        data && data->m_pWatch) // *is* a watch
+    if (id.IsOk()) // valid item
     {
-        menu.Append(idEditWatch, _("&Edit watch"));
-        menu.Append(idDeleteWatch, _("&Delete watch"));
+        WatchTreeData* data = dynamic_cast<WatchTreeData*>(m_pTree->GetItemData(id));
+        if (data && data->m_pWatch) // *is* a watch
+        {
+            menu.Append(idEditWatch, _("&Edit watch"));
+            menu.Append(idDeleteWatch, _("&Delete watch"));
+        }
     }
     menu.AppendSeparator();
     menu.Append(idChangeValue, _("&Change value..."));
techy 2009-12-29 21:59

There's a problem when right-clicking empty watches window...

mortenmacfly 2012-12-16 14:49

Does this still apply?

techy 2012-12-17 14:00

I stopped using CodeBlocks quite some time ago so unfortunately I have no idea...