Browse Source

pstats: Fix some issues with updates of flame graph

Upon reading data from datagram, the bars would animate from zero width, which looks odd when opening an existing session.

Also, fix the scale area not updating properly in GTK version.
rdb 3 years ago
parent
commit
7691d3f67b

+ 3 - 0
pandatool/src/gtk-stats/gtkStatsFlameGraph.cxx

@@ -199,6 +199,9 @@ normal_guide_bars() {
   }
 
   _guide_bars_changed = true;
+
+  nassertv_always(_scale_area != nullptr);
+  gtk_widget_queue_draw(_scale_area);
 }
 
 /**

+ 0 - 5
pandatool/src/gtk-stats/gtkStatsGraph.cxx

@@ -33,11 +33,6 @@ GtkStatsGraph::
 GtkStatsGraph(GtkStatsMonitor *monitor, bool has_label_stack) :
   _monitor(monitor)
 {
-  _parent_window = nullptr;
-  _window = nullptr;
-  _graph_window = nullptr;
-  _scale_area = nullptr;
-
   GtkWidget *parent_window = monitor->get_window();
 
   GdkWindow *window = gtk_widget_get_window(parent_window);

+ 4 - 4
pandatool/src/gtk-stats/gtkStatsGraph.h

@@ -96,14 +96,14 @@ protected:
   TextColors _text_colors;
 
   GtkStatsMonitor *_monitor;
-  GtkWidget *_parent_window;
-  GtkWidget *_window;
+  GtkWidget *_parent_window = nullptr;
+  GtkWidget *_window = nullptr;
   GtkWidget *_graph_frame;
-  GtkWidget *_graph_window;
+  GtkWidget *_graph_window = nullptr;
   GtkWidget *_graph_hbox;
   GtkWidget *_graph_vbox;
   GtkWidget *_hpaned;
-  GtkWidget *_scale_area;
+  GtkWidget *_scale_area = nullptr;
   GtkStatsLabelStack _label_stack;
 
   GdkCursor *_hand_cursor;

+ 9 - 2
pandatool/src/pstatserver/pStatFlameGraph.cxx

@@ -47,7 +47,6 @@ PStatFlameGraph(PStatMonitor *monitor,
   }
 
   _guide_bar_units = GBU_ms | GBU_hz | GBU_show_units;
-  normal_guide_bars();
 
   monitor->_flame_graphs.insert(this);
 }
@@ -213,8 +212,16 @@ read_datagram(DatagramIterator &scan) {
   PStatGraph::read_datagram(scan);
 
   _current_frame = -1;
-  normal_guide_bars();
+  _stack.clear();
   update();
+  if (_average_mode) {
+    _time_width = _stack.get_net_value(false);
+    if (_time_width == 0.0) {
+      _time_width = 1.0 / pstats_target_frame_rate;
+    }
+    normal_guide_bars();
+    force_redraw();
+  }
 }
 
 /**