[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FLTK initialization bug?
From: |
John W. Eaton |
Subject: |
Re: FLTK initialization bug? |
Date: |
Tue, 14 Sep 2010 01:06:01 -0400 |
On 13-Sep-2010, Jordi Gutiérrez Hermoso wrote:
| On 13 September 2010 20:12, Ben Abbott <address@hidden> wrote:
| > This looks like a timing problem to me.
| >
| > octave:1> backend ("fltk") ; __go_figure__ (1, "__backend__", "fltk")
| > warning: implicit conversion from matrix to sq_string
| > error: fltk_backend: could not recognize fltk index
| > octave:1> backend ("fltk")
| > octave:2> __go_figure__ (1, "__backend__", "fltk")
| > ans = 1
|
| I can't reproduce this. The warning and error happen here even if
| they're on separate lines. Regardless, if you're seeing it, it's
| doubtless a race condition... I wonder if we need to start bothering
| with semaphores and mutexes...
Maybe the change is as simple as the following? But since I don't
really know how the fltk backend is supposed to work I'm not sure. It
just makes sense to me that if the __plot_stream__ object is an empty
matrix, it is probably not initialized ([] is the default value of
__plot_stream__ when a new figure is created, isn't it?) so we
shouldn't need to delete it.
diff --git a/src/DLD-FUNCTIONS/fltk_backend.cc
b/src/DLD-FUNCTIONS/fltk_backend.cc
--- a/src/DLD-FUNCTIONS/fltk_backend.cc
+++ b/src/DLD-FUNCTIONS/fltk_backend.cc
@@ -1186,7 +1186,9 @@
if (go.isa ("figure"))
{
octave_value ov = go.get (caseless_str ("__plot_stream__"));
- figure_manager::delete_window (ov.string_value ());
+
+ if (! ov.is_empty ())
+ figure_manager::delete_window (ov.string_value ());
}
}
BTW, I think we could improve the names of the following functions in
the graphics backend classes:
// Called when graphics object using this backend changes it's property.
virtual void property_changed (const graphics_object&, int)
// Called when new object using this backend is created.
virtual void object_created (const graphics_object&)
// Called when object using this backend is destroyed.
virtual void object_destroyed (const graphics_object&)
I think
// Callback function executed when the given graphics object
// changes. This allows the grahpics backend to act on property
// changes if needed.
virtual void update (const graphics_object&, int);
// Callback function executed when the given graphics object is
// created. This allows the graphics backend to do backend-specific
// initializations for a newly created object.
virtual void initialize (const_graphics_object&)
// Callback function executed just prior to deleting the given
// graphics object. This allows the graphics backend to perform
// backend-specific cleanup operations before an object is deleted.
virtual void finalize (const_graphics_object&)
would be better (assuming the comments are correct).
Any objection to making this change?
jwe