From 24e74a97e482b31a3faf4b53b2b4312a4449fa17 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 29 Apr 2006 04:20:16 +0000 Subject: [PATCH] prevent crash on starting pstats --- pandatool/src/pstatserver/pStatClientData.cxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pandatool/src/pstatserver/pStatClientData.cxx b/pandatool/src/pstatserver/pStatClientData.cxx index 48e8f3855b..39fa292455 100644 --- a/pandatool/src/pstatserver/pStatClientData.cxx +++ b/pandatool/src/pstatserver/pStatClientData.cxx @@ -169,13 +169,15 @@ set_collector_has_level(int index, int thread_index, bool flag) { if (_collectors[index]._is_level.get_bit(thread_index) != flag) { any_changed = true; _collectors[index]._is_level.set_bit_to(thread_index, flag); + } - // Turning this on for a given collector also implicitly turns all - // of its ancestors. - if (flag) { - PStatCollectorDef *def = _collectors[index]._def; - if (def->_parent_index != 0) { - set_collector_has_level(def->_parent_index, thread_index, flag); + // Turning this on for a given collector also implicitly turns all + // of its ancestors. + if (flag) { + PStatCollectorDef *def = _collectors[index]._def; + if (def != (PStatCollectorDef *)NULL && def->_parent_index != 0) { + if (set_collector_has_level(def->_parent_index, thread_index, flag)) { + any_changed = true; } } } @@ -411,7 +413,7 @@ update_toplevel_collectors() { Collectors::const_iterator ci; for (ci = _collectors.begin(); ci != _collectors.end(); ++ci) { PStatCollectorDef *def = (*ci)._def; - if (def->_parent_index == 0) { + if (def != (PStatCollectorDef *)NULL && def->_parent_index == 0) { _toplevel_collectors.push_back(def->_index); } }