From a282ff9218eb3a80d6238e675fc7dbb9d929d32e Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 31 May 2001 23:02:35 +0000 Subject: [PATCH] fix crashes --- pandatool/src/pstatserver/pStatThreadData.cxx | 20 +++++++++---------- pandatool/src/pstatserver/pStatView.cxx | 10 ++++++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/pandatool/src/pstatserver/pStatThreadData.cxx b/pandatool/src/pstatserver/pStatThreadData.cxx index 91cd019bd4..f469c81567 100644 --- a/pandatool/src/pstatserver/pStatThreadData.cxx +++ b/pandatool/src/pstatserver/pStatThreadData.cxx @@ -126,8 +126,6 @@ get_frame(int frame_number) const { } } - PStatFrameData * const *array = &_frames[0]; - if (rel_frame >= 0 && rel_frame < num_frames) { nassertr(_frames[rel_frame] != (PStatFrameData *)NULL, _null_frame); nassertr(_frames[rel_frame]->get_start() >= 0.0, _null_frame); @@ -256,17 +254,19 @@ get_frame_rate(float time) const { int then_i = now_i; int last_good_i = now_i; - PStatFrameData * const *array = &_frames[0]; - nassertr(then_i < 0 || _frames[then_i] != (PStatFrameData *)NULL, 0.0); - while (then_i > 0 && _frames[then_i]->get_start() > then) { - last_good_i = then_i; - then_i--; - while (then_i > 0 && _frames[then_i] == (PStatFrameData *)NULL) { - then_i--; + while (then_i >= 0) { + const PStatFrameData *frame = _frames[then_i]; + if (frame != (PStatFrameData *)NULL) { + if (frame->get_start() > then) { + last_good_i = then_i; + } else { + break; + } } - nassertr(then_i < 0 || _frames[then_i] != (PStatFrameData *)NULL, 0.0); + then_i--; } + nassertr(last_good_i >= 0, 0.0); nassertr(_frames[last_good_i] != (PStatFrameData *)NULL, 0.0); diff --git a/pandatool/src/pstatserver/pStatView.cxx b/pandatool/src/pstatserver/pStatView.cxx index 91bd1ba1eb..f512206c47 100644 --- a/pandatool/src/pstatserver/pStatView.cxx +++ b/pandatool/src/pstatserver/pStatView.cxx @@ -349,8 +349,14 @@ update_time_data(const PStatFrameData &frame_data) { if (_client_data->get_child_distance(_constraint, collector_index) >= 0) { // Here's a data point we care about: anything at constraint // level or below. - samples[collector_index].data_point(frame_data.get_time(i), is_start, started); - got_samples.insert(collector_index); + if (is_start == samples[collector_index]._is_started) { + nout << "Unexpected data point for " + << _client_data->get_collector_fullname(collector_index) + << "\n"; + } else { + samples[collector_index].data_point(frame_data.get_time(i), is_start, started); + got_samples.insert(collector_index); + } } } }