Added missing lock around update_counter (somehow fixes #10)

This commit is contained in:
2026-03-19 13:54:03 +01:00
parent 3cd93f1c7e
commit 1d492e940a
+9 -29
View File
@@ -2278,42 +2278,35 @@ class MonitorWidgets:
self.display_autoscaling_checkbutton = self.xml_gui.get_object( "display_autoscaling_checkbutton" ) self.display_autoscaling_checkbutton = self.xml_gui.get_object( "display_autoscaling_checkbutton" )
self.display_statistics_checkbutton = self.xml_gui.get_object( "display_statistics_checkbutton" ) self.display_statistics_checkbutton = self.xml_gui.get_object( "display_statistics_checkbutton" )
# insert monitor
# Matplot (Display_Table, 1st Row) -------------------------------------------------------- # Matplot (Display_Table, 1st Row) --------------------------------------------------------
# Neue Abbildung erstellen # create new plot
self.matplot_figure = matplotlib.figure.Figure( ) self.matplot_figure = matplotlib.figure.Figure( )
# the plot area surrounded by axes # the plot area surrounded by axes
self.matplot_axes = self.matplot_figure.add_axes( [ 0.1, 0.15, 0.8, 0.7 ] ) self.matplot_axes = self.matplot_figure.add_axes( [ 0.1, 0.15, 0.8, 0.7 ] )
# Achsen beschriften & Gitternetzlinien sichtbar machen
self.matplot_axes.grid( True ) self.matplot_axes.grid( True )
# Ersten Plot erstellen und Referenz des ersten Eintrags im zurueckgegebenen Tupel speichern
# Voerst: graphen[0,1] = Real und Img-Kanal; [2,3] = Real-Fehler, [4,5] = Img-Fehler
#self.graphen = []
#self.measurementresultgraph=None
self.matplot_axes.set_ylim( [ 0.0, 1.0 ] ) self.matplot_axes.set_ylim( [ 0.0, 1.0 ] )
self.matplot_axes.set_xlim( [ 0.0, 1.0 ] ) self.matplot_axes.set_xlim( [ 0.0, 1.0 ] )
self.matplot_axes.set_autoscale_on( self.display_autoscaling_checkbutton.get_active( ) ) self.matplot_axes.set_autoscale_on( self.display_autoscaling_checkbutton.get_active( ) )
# Lineare y-/x-Skalierung # linear y/x scaling
self.matplot_axes.set_yscale( "linear" ) self.matplot_axes.set_yscale( "linear" )
self.matplot_axes.set_xscale( "linear" ) self.matplot_axes.set_xscale( "linear" )
# Matplot in einen GTK-Rahmen stopfen # add figure to canvas
self.matplot_canvas = FigureCanvas( self.matplot_figure ) self.matplot_canvas = FigureCanvas( self.matplot_figure )
# Add right-click context menu to canvas # add right-click context menu to canvas
self.matplot_canvas.connect("button-press-event", self.on_canvas_button_press) self.matplot_canvas.connect("button-press-event", self.on_canvas_button_press)
self.display_table = self.xml_gui.get_object( "display_table" ) self.display_table = self.xml_gui.get_object( "display_table" )
self.display_table.attach( self.matplot_canvas, 0, 6, 0, 1, gtk.AttachOptions.EXPAND | gtk.AttachOptions.FILL, gtk.AttachOptions.EXPAND | gtk.AttachOptions.FILL, 0, 0 ) self.display_table.attach( self.matplot_canvas, 0, 6, 0, 1, gtk.AttachOptions.EXPAND | gtk.AttachOptions.FILL, gtk.AttachOptions.EXPAND | gtk.AttachOptions.FILL, 0, 0 )
self.matplot_canvas.show( ) self.matplot_canvas.show( )
# Matplot Toolbar hinzufuegen (Display_Table, 2. Zeile) # add matplotlib toolbar (display_table, 2nd row)
self.matplot_toolbar = matplotlib.backends.backend_gtk3.NavigationToolbar2GTK3( self.matplot_canvas ) self.matplot_toolbar = matplotlib.backends.backend_gtk3.NavigationToolbar2GTK3( self.matplot_canvas )
# Make cursor position text bigger and bold - access message label directly # Make cursor position text bigger and bold - access message label directly
@@ -2327,9 +2320,7 @@ class MonitorWidgets:
self.display_table.attach( self.matplot_toolbar, 0, 1, 1, 2, gtk.AttachOptions.FILL | gtk.AttachOptions.EXPAND, 0, 0, 0 ) self.display_table.attach( self.matplot_toolbar, 0, 1, 1, 2, gtk.AttachOptions.FILL | gtk.AttachOptions.EXPAND, 0, 0, 0 )
self.matplot_toolbar.show( ) self.matplot_toolbar.show( )
# /Mathplot -------------------------------------------------------------------------------- # select display source
# display source
self.display_source_combobox = self.xml_gui.get_object( "display_source_combobox" ) self.display_source_combobox = self.xml_gui.get_object( "display_source_combobox" )
self.display_source_treestore = gtk.TreeStore( gobject.TYPE_STRING ) self.display_source_treestore = gtk.TreeStore( gobject.TYPE_STRING )
self.display_source_combobox.set_model( self.display_source_treestore ) self.display_source_combobox.set_model( self.display_source_treestore )
@@ -2341,7 +2332,7 @@ class MonitorWidgets:
self.source_list_reset( ) self.source_list_reset( )
self.display_source_path_label = self.xml_gui.get_object( "display_source_path_label" ) self.display_source_path_label = self.xml_gui.get_object( "display_source_path_label" )
# display scaling: ToDo enable scaling # enable display scaling
self.display_x_scaling_combobox.set_active( 0 ) self.display_x_scaling_combobox.set_active( 0 )
self.display_y_scaling_combobox.set_active( 0 ) self.display_y_scaling_combobox.set_active( 0 )
self.display_x_scaling_combobox.set_sensitive( True ) self.display_x_scaling_combobox.set_sensitive( True )
@@ -2498,7 +2489,9 @@ class MonitorWidgets:
( (
displayed_object is object_to_display or displayed_object.__class__ is object_to_display.__class__): displayed_object is object_to_display or displayed_object.__class__ is object_to_display.__class__):
# oh, another category # oh, another category
self.update_counter_lock.acquire()
self.update_counter += 1 self.update_counter += 1
self.update_counter_lock.release()
gobject.idle_add( self.update_display_idle_event, self.displayed_data[ 0 ][ : ], gobject.idle_add( self.update_display_idle_event, self.displayed_data[ 0 ][ : ],
priority=gobject.PRIORITY_DEFAULT_IDLE ) priority=gobject.PRIORITY_DEFAULT_IDLE )
else: else:
@@ -2942,19 +2935,6 @@ class MonitorWidgets:
yminpos = in_result.get_yminpos() yminpos = in_result.get_yminpos()
ymax = in_result.get_ymax( ) ymax = in_result.get_ymax( )
# # Check for log-scale
# if xmin <= 0 or xmax <= 0:
# self.display_x_scaling_combobox.set_sensitive( False )
# self.display_x_scaling_combobox.set_active( 0 )
# else:
# self.display_x_scaling_combobox.set_sensitive( True )
#
# if ymin <= 0 or ymax <= 0:
# self.display_y_scaling_combobox.set_sensitive( False )
# self.display_y_scaling_combobox.set_active( 0 )
# else:
# self.display_y_scaling_combobox.set_sensitive( False )
# Initial rescaling needed? # Initial rescaling needed?
if self.__rescale: if self.__rescale:
x_scale = self.display_x_scaling_combobox.get_active_text( ) x_scale = self.display_x_scaling_combobox.get_active_text( )