@@ -229,6 +229,22 @@ void PythonDebugger::ClearActiveMarkFromAllEditors()
229229 }
230230}
231231
232+ void RemoveMissingChildren (cb::shared_ptr<cbWatch> parent, const std::set<wxString> &knownsyms)
233+ {
234+ for (int i=0 ; i<parent->GetChildCount (); ++i)
235+ {
236+ cb::shared_ptr<cbWatch> p (parent->GetChild (i));
237+ wxString s;
238+ p->GetSymbol (s);
239+ if (knownsyms.find (s)==knownsyms.end ())
240+ {
241+ parent->RemoveChild (i);
242+ --i;
243+ continue ;
244+ }
245+ }
246+ }
247+
232248void PythonDebugger::OnTimer (wxTimerEvent& event)
233249{
234250 bool debugoutputmode=false ;
@@ -273,7 +289,7 @@ void PythonDebugger::OnTimer(wxTimerEvent& event)
273289 exprresult.Replace (_T (" \n " ),_T (" \\ n" ),true );
274290 wxString symbol=exprresult.BeforeFirst (_T (' \001 ' )).Trim (false );
275291 exprresult=exprresult.AfterFirst (_T (' \001 ' ));
276- wxString type=exprresult.BeforeFirst (_T (' \001 ' ));
292+ wxString type=exprresult.BeforeFirst (_T (' \001 ' )). Trim (). Trim ( false ) ;
277293 wxString value=exprresult.AfterFirst (_T (' \001 ' ));
278294 for (size_t i=0 ;i<m_watchlist.size ();++i)
279295 {
@@ -307,7 +323,7 @@ void PythonDebugger::OnTimer(wxTimerEvent& event)
307323 parentsymbol=parentsymbol.BeforeLast (_T (' \n ' ));
308324
309325 // Find the parent watch and remove it's children
310- PythonWatch::Pointer parentwatch;
326+ PythonWatch::Pointer parentwatch, pw ;
311327 PythonWatchesContainer::iterator it;
312328 for (it=m_watchlist.begin ();it!=m_watchlist.end ();it++)
313329 {
@@ -331,20 +347,42 @@ void PythonDebugger::OnTimer(wxTimerEvent& event)
331347
332348 // Now add the newly updated children
333349 std::set<wxString> foundsyms;
350+ foundsyms.insert (_T (" *Modules:" ));
351+ foundsyms.insert (_T (" *Classes:" ));
352+ foundsyms.insert (_T (" *Functions:" ));
334353 while (exprresult.Len ()>0 )
335354 {
336355 wxString symbol=exprresult.BeforeFirst (_T (' \001 ' )).Trim (false );
337356 exprresult=exprresult.AfterFirst (_T (' \001 ' ));
338- wxString type=exprresult.BeforeFirst (_T (' \001 ' ));
357+ wxString type=exprresult.BeforeFirst (_T (' \001 ' )). Trim ( false ). Trim () ;
339358 exprresult=exprresult.AfterFirst (_T (' \001 ' ));
340359 wxString value=exprresult.BeforeFirst (_T (' \001 ' ));
341360 exprresult=exprresult.AfterFirst (_T (' \001 ' ));
342361 foundsyms.insert (symbol);
343362 cb::shared_ptr<cbWatch> p = parentwatch->FindChild (symbol);
363+ pw = parentwatch;
364+ if (parentwatch == m_locals_watch)
365+ {
366+ if (!p && type == _ (" <type 'module'>" ))
367+ {
368+ p = m_modules_watch->FindChild (symbol);
369+ pw = m_modules_watch;
370+ }
371+ if (!p && type == _ (" <type 'classobj'>" ))
372+ {
373+ p = m_classes_watch->FindChild (symbol);
374+ pw = m_classes_watch;
375+ }
376+ if (!p && type == _ (" <type 'function'>" ))
377+ {
378+ p = m_functions_watch->FindChild (symbol);
379+ pw = m_functions_watch;
380+ }
381+ }
344382 if (!p)
345383 {
346384 p = cb::shared_ptr<cbWatch>(new PythonWatch (symbol));
347- cbWatch::AddChild (parentwatch ,p);
385+ cbWatch::AddChild (pw ,p);
348386 }
349387 wxString oldval,oldtype;
350388 p->GetValue (oldval);
@@ -353,16 +391,12 @@ void PythonDebugger::OnTimer(wxTimerEvent& event)
353391 p->SetType (type);
354392 p->SetValue (value);
355393 }
356- for (int i=0 ; i<parentwatch->GetChildCount (); ++i)
394+ RemoveMissingChildren (parentwatch, foundsyms);
395+ if (parentwatch == m_locals_watch)
357396 {
358- cb::shared_ptr<cbWatch> p (parentwatch->GetChild (i));
359- wxString s;
360- p->GetSymbol (s);
361- if (foundsyms.find (s)==foundsyms.end ())
362- {
363- parentwatch->RemoveChild (i);
364- --i;
365- }
397+ RemoveMissingChildren (m_functions_watch, foundsyms);
398+ RemoveMissingChildren (m_classes_watch, foundsyms);
399+ RemoveMissingChildren (m_modules_watch, foundsyms);
366400 }
367401 DebuggerManager &dbg_manager = *Manager::Get ()->GetDebuggerManager ();
368402 dbg_manager.GetWatchesDialog ()->UpdateWatches ();
@@ -996,11 +1030,23 @@ void PythonDebugger::OnAttachReal()
9961030 Manager::Get ()->RegisterEventSink (cbEVT_EDITOR_TOOLTIP, new cbEventFunctor<PythonDebugger, CodeBlocksEvent>(this , &PythonDebugger::OnValueTooltip));
9971031
9981032 m_locals_watch = PythonWatch::Pointer (new PythonWatch (_T (" *Locals:" )));
999- // cbWatch::AddChild(m_locals_watch,PythonWatch::Pointer(new PythonWatch(_("#child"))));
1000- m_locals_watch->Expand (true );
10011033 m_locals_watch->MarkAsChanged (false );
10021034 Manager::Get ()->GetDebuggerManager ()->GetWatchesDialog ()->AddSpecialWatch (m_locals_watch,true );
10031035
1036+ m_functions_watch = PythonWatch::Pointer (new PythonWatch (_T (" *Functions:" )));
1037+ m_functions_watch->MarkAsChanged (false );
1038+ cbWatch::AddChild (m_locals_watch,m_functions_watch);
1039+
1040+ m_classes_watch = PythonWatch::Pointer (new PythonWatch (_T (" *Classes:" )));
1041+ m_classes_watch->MarkAsChanged (false );
1042+ cbWatch::AddChild (m_locals_watch,m_classes_watch);
1043+
1044+ m_modules_watch = PythonWatch::Pointer (new PythonWatch (_T (" *Modules:" )));
1045+ m_modules_watch->MarkAsChanged (false );
1046+ cbWatch::AddChild (m_locals_watch,m_modules_watch);
1047+
1048+ m_locals_watch->Expand (true );
1049+ Manager::Get ()->GetDebuggerManager ()->GetWatchesDialog ()->UpdateWatches ();
10041050}
10051051
10061052void PythonDebugger::OnReleaseReal (bool appShutDown)
@@ -1021,6 +1067,8 @@ void PythonDebugger::OnReleaseReal(bool appShutDown)
10211067// dbg_manager.UnregisterDebugger(this);
10221068 Manager::Get ()->GetDebuggerManager ()->GetWatchesDialog ()->RemoveWatch (m_locals_watch);
10231069 m_locals_watch = PythonWatch::Pointer ();
1070+ m_functions_watch = PythonWatch::Pointer ();
1071+ m_classes_watch = PythonWatch::Pointer ();
10241072}
10251073
10261074void PythonDebugger::SetWatchTooltip (const wxString &tip, int definition_length)
0 commit comments