On 2016-12-18 23:27-0000 Phil Rosenberg wrote:

> The error is in the wxplplotdemo code, not in the wxplplotwindow. In
> the demo we must simply wait for the OnCreate message to arrive and be
> processed before we grab the stream in Plot(). We may be able to do
> that with
> while(!m_created)
>   wxYield();

To Phil and Pedro:

I tried the following patch (to master tip, note the use of the
latest PLPLOT_wxLogDebug macro in the context for the diff)

diff --git a/examples/c++/wxPLplotDemo.cpp b/examples/c++/wxPLplotDemo.cpp
index afbf260..17b1259 100644
--- a/examples/c++/wxPLplotDemo.cpp
+++ b/examples/c++/wxPLplotDemo.cpp
@@ -155,7 +155,11 @@ bool MyApp::OnInit()
  template< class WXWINDOW >
  void Plot( wxPLplotwindow<WXWINDOW> *plotwindow )
  {
-    wxPLplotstream* pls = plotwindow->GetStream();
+    wxPLplotstream* pls;
+    while(!m_created)
+      wxYield();
+
+    pls = plotwindow->GetStream();
      if (pls == NULL)
      {
       PLPLOT_wxLogDebug("pls NULL");

@Phil:

I am pretty sure this is what you meant by your suggestion, but it won't build 
because
m_created is not in scope.


/home/software/plplot/HEAD/plplot.git/examples/c++/wxPLplotDemo.cpp:159:12: 
error: ‘m_created’ was not declared in this scope
      while(!m_created)
             ^
examples/c++/CMakeFiles/wxPLplotDemo.dir/build.make:62: recipe for target 
'examples/c++/CMakeFiles/wxPLplotDemo.dir/wxPLplotDemo.cpp.o' failed
make[3]: *** [examples/c++/CMakeFiles/wxPLplotDemo.dir/wxPLplotDemo.cpp.o] 
Error 1
CMakeFiles/Makefile2:13143: recipe for target 
'examples/c++/CMakeFiles/wxPLplotDemo.dir/all' failed
make[2]: *** [examples/c++/CMakeFiles/wxPLplotDemo.dir/all] Error 2
CMakeFiles/Makefile2:5326: recipe for target 
'examples/CMakeFiles/test_wxPLplotDemo.dir/rule' failed
make[1]: *** [examples/CMakeFiles/test_wxPLplotDemo.dir/rule] Error 2
Makefile:1807: recipe for target 'test_wxPLplotDemo' failed
make: *** [test_wxPLplotDemo] Error 2

Can you suggest a way to address this build issue so I can give this
solution a try?  Or did you mean something else?

That said, wxYield was already deprecated in wxwidgets 2.8, and even
more strongly deprecated for wxwidgets 3.1.  Also, from reading
the wxYield documentation, I am not sure it will be the answer to
our problem.  And I am not particularly happy with a loop (which
alays has the potential to burn a lot of cpu or even spin indefinitely).

Isn't the real issue, that the code should wait in the above spot for
a particular event that our other code has launched to fire?  If you
agree with that characterization of the problem, shouldn't the above
two-line loop be replaced with a one-line solution which is to make
the proper wxwidgets call to wait for the correct event to fire?

I realize you are extremely pressed for time so if you think waiting
for the event is not the way to go say so here, and forget the rest
of this.  But if you think the above approach is ultimately the
correct one, please let us know in which case the rest of this
is mostly for Pedro.

@Pedro:

Assuming Phil recommends this approach, would you be willing to
implement it?

A google search for the terms <wxwidgets wait event> shows lots of
hits, in particular
<https://forums.wxwidgets.org/viewtopic.php?t=22893>.  That reference
is dated but quite encouraging about this general idea.  However, I
soon get lost in C++ and wxwidgets details so I need an expert in
those areas to move further with this idea. However, if I am reading
the above reference properly all you have to do is make the correct
wxwidgets wait call to replace the two lines above, and you need to
set up our code that launches the event so that event can be uniquely
identified for the wait call.  So it looks really easy to do "when you
know how", i.e., if you are already pretty experienced with C++ and
wxwidgets.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to