Re: [Plplot-devel] wxPLplotDemo.cpp errors - FIXED , with workaround

2016-12-12 Thread Pedro Vicente

Hi Phil

Here's the fix I did for the linux wxwidgets driver bug

https://github.com/pedro-vicente/plplot-wxwidgets


these are the comments I added in the code



// Modified from PLplot Copyright (C) 2015  Phil Rosenberg
// Changes:
// A non templated class derived from wxFrame
// Use of events by wxDECLARE_EVENT_TABLE()
// Explicit call to CreatePLplotstream() after Create()
//wx_PLplotFrame_stream *frame = new wx_PLplotFrame_stream();
//frame->Create(...);
//frame->CreatePLplotstream();
//frame->Show();

one thing that caught my attention in your code was this way of handling 
events

WXWINDOW::Connect( wxEVT_SIZE, wxSizeEventHandler( 
wxPLplotwindow::OnSize ) );

I usually do a static event table, in fact all the wxWidgets samples do the 
same, except
for some thread related code

but even using the static event table in your code, the bug still was there.
so the only way was to do an explicit call to

frame->CreatePLplotstream();

let me know if you have any questions
-Pedro


- Original Message - 
From: "Pedro Vicente" <pedro.vice...@space-research.org>
To: "Phil Rosenberg" <p.d.rosenb...@gmail.com>; 
<plplot-devel@lists.sourceforge.net>
Sent: Saturday, December 10, 2016 11:25 PM
Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors - FIXED , with 
workaround


> Hi Phil
>
> There is actually a very simple solution.
> Instead of figuring out why the OnCreate event is not triggered in some
> linux cases, you can explicitally call that code with some function.
>
> I did just that, like this, where
> frame->CreatePLplotstream();
>
> is a function that contains your code that is in OnCreate()
>
> this makes it needed to a user to call this extra function, but well, you
> can't win them all
>
> this code below makes a plot in Windows and Linux
>
> Note:
> I did my own class
> wx_PLplotFrame
>
> that is virtually identical to wxPLplotwindow, but not templated
>
> I'll put this code in github when I have a chance later
>
> bool wxAppPlot::OnInit()
> {
>  wx_PLplotFrame *frame = new wx_PLplotFrame();
>  frame->Create(NULL, wxID_ANY, wxT("wxPLplot"),
>wxDefaultPosition,
>wxSize(900, 700));
>  frame->CreatePLplotstream();
>  frame->Show();
>  wxPLplotstream* pls = frame->GetStream();
>  assert(pls);
>  PLFLT x[4] = { 1, 2, 3, 4 };
>  PLFLT y[4] = { 1, 2, 3, 4 };
>  pls->env(0, 5, 0, 5, 0, 0);
>  pls->line(4, x, y);
>  return true;
> }
>
> -Pedro
>
>
> - Original Message - 
> From: "Phil Rosenberg" <p.d.rosenb...@gmail.com>
> To: "Pedro Vicente" <pedro.vice...@space-research.org>;
> <plplot-devel@lists.sourceforge.net>
> Sent: Saturday, December 10, 2016 3:57 AM
> Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors
>
>
>> Hi Pedro
>> I have included the devel list on this email, so the thread will get
>> documented on the mailing list.
>>
>> It is very strange that the OnCreate function is not being called. If
>> you are calling Create then you should be generating a create event.
>> Am I correct in saying that you are getting this segfault with the
>> unchanged demo app?
>>
>> This location really is the best (and maybe only) place this
>> initialisation should be done. It cannot be included in the
>> constructor, because the generic nature of the template specification
>> means the code in the constructor does not know which type of wxWindow
>> we are inheriting from so cannot pass the correct parameters to the
>> constructor. By the time OnPaint is called it is really too late,
>> because we would like to already have the plot initialised and ready
>> to draw and it would be a real pain for you in your code if you had to
>> somehow wait for the first paint or resize event.
>>
>> I do have access to a CentOS machine at work, although I think I have
>> only got access to wxWidgets 2.8 on that system. I will check. I may
>> be able to build 3.1 from source. I presume you are using 3.1.0 as
>> released in February, rather than the head of the master branch?
>>
>> On 10 December 2016 at 07:52, Pedro Vicente
>> <pedro.vice...@space-research.org> wrote:
>>> Hi Phil
>>>
>>> My idea for a fix is to move the stream initialization that is now  on
>>>
>>> void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
>>> {
>>> if ( !m_created )
>>>
>>> either to the OnSize or onPaint events
>>>
>>> void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
>>>
>>> and also in the plot call do this
>>>
>>> template< class WXWINDOW >

Re: [Plplot-devel] wxPLplotDemo.cpp errors - FIXED , with workaround

2016-12-10 Thread Pedro Vicente
Hi Phil

There is actually a very simple solution.
Instead of figuring out why the OnCreate event is not triggered in some 
linux cases, you can explicitally call that code with some function.

I did just that, like this, where
 frame->CreatePLplotstream();

is a function that contains your code that is in OnCreate()

this makes it needed to a user to call this extra function, but well, you 
can't win them all

this code below makes a plot in Windows and Linux

Note:
I did my own class
wx_PLplotFrame

that is virtually identical to wxPLplotwindow, but not templated

I'll put this code in github when I have a chance later

bool wxAppPlot::OnInit()
{
  wx_PLplotFrame *frame = new wx_PLplotFrame();
  frame->Create(NULL, wxID_ANY, wxT("wxPLplot"),
wxDefaultPosition,
wxSize(900, 700));
  frame->CreatePLplotstream();
  frame->Show();
  wxPLplotstream* pls = frame->GetStream();
  assert(pls);
  PLFLT x[4] = { 1, 2, 3, 4 };
  PLFLT y[4] = { 1, 2, 3, 4 };
  pls->env(0, 5, 0, 5, 0, 0);
  pls->line(4, x, y);
  return true;
}

-Pedro


- Original Message - 
From: "Phil Rosenberg" <p.d.rosenb...@gmail.com>
To: "Pedro Vicente" <pedro.vice...@space-research.org>; 
<plplot-devel@lists.sourceforge.net>
Sent: Saturday, December 10, 2016 3:57 AM
Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors


> Hi Pedro
> I have included the devel list on this email, so the thread will get
> documented on the mailing list.
>
> It is very strange that the OnCreate function is not being called. If
> you are calling Create then you should be generating a create event.
> Am I correct in saying that you are getting this segfault with the
> unchanged demo app?
>
> This location really is the best (and maybe only) place this
> initialisation should be done. It cannot be included in the
> constructor, because the generic nature of the template specification
> means the code in the constructor does not know which type of wxWindow
> we are inheriting from so cannot pass the correct parameters to the
> constructor. By the time OnPaint is called it is really too late,
> because we would like to already have the plot initialised and ready
> to draw and it would be a real pain for you in your code if you had to
> somehow wait for the first paint or resize event.
>
> I do have access to a CentOS machine at work, although I think I have
> only got access to wxWidgets 2.8 on that system. I will check. I may
> be able to build 3.1 from source. I presume you are using 3.1.0 as
> released in February, rather than the head of the master branch?
>
> On 10 December 2016 at 07:52, Pedro Vicente
> <pedro.vice...@space-research.org> wrote:
>> Hi Phil
>>
>> My idea for a fix is to move the stream initialization that is now  on
>>
>> void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
>> {
>> if ( !m_created )
>>
>> either to the OnSize or onPaint events
>>
>> void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
>>
>> and also in the plot call do this
>>
>> template< class WXWINDOW >
>> void Plot( wxPLplotwindow *plotwindow )
>> {
>>wxPLplotstream* pls = plotwindow->GetStream();
>>
>>if (pls == NULL)
>>{
>>  return;
>>}
>>
>>
>> Like this , in this sequence
>>
>>
>> wxPLplotwindow *frame = new wxPLplotwindow();
>>frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>>frame->SetIcon( wxIcon( graph ) );
>>frame->Show();
>>Plot( frame );
>>
>>
>> first we go to
>> Plot( frame );
>>
>> but the stream is NULL because
>> :OnCreate
>> was not called, but the function returns, avoiding the seg fault
>>
>> then the window gets a paint or size event, and the stream initialization
>> code is called
>> at this time I have a PLplot empty black window
>>
>> but because
>> Plot( frame );
>> was only called at start, it is not called again, so there is no draw
>>
>> any ideas here ?
>>
>> of course making the Plot() call in another app function should work
>>
>>
>> If you could replicate this issue, that would be great.
>> I am using CentOS 6.8, PLplot.5.11.1 , wxWidgets 3.1.0
>>
>>
>>
>>
>>
>> - Original Message - From: Pedro Vicente
>> To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
>> Sent: Saturday, December 10, 2016 12:59 AM
>> Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors
>>
>>
>> Hi Phil
>>
>> So, the issue seems to be the same that I have been reporting
>>
>>
>

Re: [Plplot-devel] wxPLplotDemo.cpp errors

2016-12-10 Thread Pedro Vicente
Hi Phil

I tested on a third Linux, with libwxgtk3.0-dev from package (the latest 
ubuntu package)

uname -a
Linux glace 3.13.0-92-generic #139-Ubuntu SMP Tue Jun 28 20:42:26 UTC 2016 
x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty

then
git clone http://git.code.sf.net/p/plplot/plplot plplot-plplot
sudo apt-get install libwxgtk3.0-dev
cd plplot-plplot/build/
cmake .. -DBUILD_TEST=ON -DENABLE_f95:BOOL=OFF
make
cd /home/pvicente/plplot-plplot/build/examples/c++
pvicente@glace:~/plplot-plplot/build/examples/c++$ ./wxPLplotDemo
Segmentation fault (core dumped)



- Original Message - 
From: "Pedro Vicente" <pedro.vice...@space-research.org>
To: "Phil Rosenberg" <p.d.rosenb...@gmail.com>; 
<plplot-devel@lists.sourceforge.net>
Sent: Saturday, December 10, 2016 4:18 AM
Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors


> Hi Phil
>
>>>I do have access to a CentOS machine at work, although I think I have
>>>only got access to wxWidgets 2.8 on that system.
>
> What I usually do when I want to quick test on many unices , I install
> Virtual Box
>
> https://www.virtualbox.org/
>
> For example on my Windows PC I have a CentOS and Ubuntu as virtual guests
> (not the ones I did the PLplot test)
>
> -Pedro
>
>
>
>
> - Original Message - 
> From: "Phil Rosenberg" <p.d.rosenb...@gmail.com>
> To: "Pedro Vicente" <pedro.vice...@space-research.org>;
> <plplot-devel@lists.sourceforge.net>
> Sent: Saturday, December 10, 2016 3:57 AM
> Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors
>
>
>> Hi Pedro
>> I have included the devel list on this email, so the thread will get
>> documented on the mailing list.
>>
>> It is very strange that the OnCreate function is not being called. If
>> you are calling Create then you should be generating a create event.
>> Am I correct in saying that you are getting this segfault with the
>> unchanged demo app?
>>
>> This location really is the best (and maybe only) place this
>> initialisation should be done. It cannot be included in the
>> constructor, because the generic nature of the template specification
>> means the code in the constructor does not know which type of wxWindow
>> we are inheriting from so cannot pass the correct parameters to the
>> constructor. By the time OnPaint is called it is really too late,
>> because we would like to already have the plot initialised and ready
>> to draw and it would be a real pain for you in your code if you had to
>> somehow wait for the first paint or resize event.
>>
>> I do have access to a CentOS machine at work, although I think I have
>> only got access to wxWidgets 2.8 on that system. I will check. I may
>> be able to build 3.1 from source. I presume you are using 3.1.0 as
>> released in February, rather than the head of the master branch?
>>
>> On 10 December 2016 at 07:52, Pedro Vicente
>> <pedro.vice...@space-research.org> wrote:
>>> Hi Phil
>>>
>>> My idea for a fix is to move the stream initialization that is now  on
>>>
>>> void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
>>> {
>>> if ( !m_created )
>>>
>>> either to the OnSize or onPaint events
>>>
>>> void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
>>>
>>> and also in the plot call do this
>>>
>>> template< class WXWINDOW >
>>> void Plot( wxPLplotwindow *plotwindow )
>>> {
>>>wxPLplotstream* pls = plotwindow->GetStream();
>>>
>>>if (pls == NULL)
>>>{
>>>  return;
>>>}
>>>
>>>
>>> Like this , in this sequence
>>>
>>>
>>> wxPLplotwindow *frame = new wxPLplotwindow();
>>>frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>>>frame->SetIcon( wxIcon( graph ) );
>>>frame->Show();
>>>Plot( frame );
>>>
>>>
>>> first we go to
>>> Plot( frame );
>>>
>>> but the stream is NULL because
>>> :OnCreate
>>> was not called, but the function returns, avoiding the seg fault
>>>
>>> then the window gets a paint or size event, and the stream 
>>> initialization
>>> code is called
>>> at this time I have a PLplot empty black window
>>>
>>> but because
>>> Plot( frame );
>>> was only called at start, it is not 

Re: [Plplot-devel] wxPLplotDemo.cpp errors

2016-12-10 Thread Pedro Vicente
Hi Phil

>>I do have access to a CentOS machine at work, although I think I have
>>only got access to wxWidgets 2.8 on that system.

What I usually do when I want to quick test on many unices , I install 
Virtual Box

https://www.virtualbox.org/

For example on my Windows PC I have a CentOS and Ubuntu as virtual guests 
(not the ones I did the PLplot test)

-Pedro




- Original Message - 
From: "Phil Rosenberg" <p.d.rosenb...@gmail.com>
To: "Pedro Vicente" <pedro.vice...@space-research.org>; 
<plplot-devel@lists.sourceforge.net>
Sent: Saturday, December 10, 2016 3:57 AM
Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors


> Hi Pedro
> I have included the devel list on this email, so the thread will get
> documented on the mailing list.
>
> It is very strange that the OnCreate function is not being called. If
> you are calling Create then you should be generating a create event.
> Am I correct in saying that you are getting this segfault with the
> unchanged demo app?
>
> This location really is the best (and maybe only) place this
> initialisation should be done. It cannot be included in the
> constructor, because the generic nature of the template specification
> means the code in the constructor does not know which type of wxWindow
> we are inheriting from so cannot pass the correct parameters to the
> constructor. By the time OnPaint is called it is really too late,
> because we would like to already have the plot initialised and ready
> to draw and it would be a real pain for you in your code if you had to
> somehow wait for the first paint or resize event.
>
> I do have access to a CentOS machine at work, although I think I have
> only got access to wxWidgets 2.8 on that system. I will check. I may
> be able to build 3.1 from source. I presume you are using 3.1.0 as
> released in February, rather than the head of the master branch?
>
> On 10 December 2016 at 07:52, Pedro Vicente
> <pedro.vice...@space-research.org> wrote:
>> Hi Phil
>>
>> My idea for a fix is to move the stream initialization that is now  on
>>
>> void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
>> {
>> if ( !m_created )
>>
>> either to the OnSize or onPaint events
>>
>> void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
>>
>> and also in the plot call do this
>>
>> template< class WXWINDOW >
>> void Plot( wxPLplotwindow *plotwindow )
>> {
>>wxPLplotstream* pls = plotwindow->GetStream();
>>
>>if (pls == NULL)
>>{
>>  return;
>>}
>>
>>
>> Like this , in this sequence
>>
>>
>> wxPLplotwindow *frame = new wxPLplotwindow();
>>frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>>frame->SetIcon( wxIcon( graph ) );
>>frame->Show();
>>Plot( frame );
>>
>>
>> first we go to
>> Plot( frame );
>>
>> but the stream is NULL because
>> :OnCreate
>> was not called, but the function returns, avoiding the seg fault
>>
>> then the window gets a paint or size event, and the stream initialization
>> code is called
>> at this time I have a PLplot empty black window
>>
>> but because
>> Plot( frame );
>> was only called at start, it is not called again, so there is no draw
>>
>> any ideas here ?
>>
>> of course making the Plot() call in another app function should work
>>
>>
>> If you could replicate this issue, that would be great.
>> I am using CentOS 6.8, PLplot.5.11.1 , wxWidgets 3.1.0
>>
>>
>>
>>
>>
>> - Original Message - From: Pedro Vicente
>> To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
>> Sent: Saturday, December 10, 2016 12:59 AM
>> Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors
>>
>>
>> Hi Phil
>>
>> So, the issue seems to be the same that I have been reporting
>>
>>
>> In the wxPLplotDemo.cpp code you have these callling functions
>>
>>
>> wxPLplotwindow *frame = new wxPlDemoFrame();
>> frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>>
>>
>> that make 2 calls to the PLplot library, or the wxWidgets driver of it
>> all these calls are in the header file wxPLplotwindow.h
>>
>> first the constructor is called
>>
>> template
>> wxPLplotwindow::wxPLplotwindow( bool useGraphicsContext, wxSize
>> clientSize )
>>: m_created( false ), m_initialSize( clientSize )
>>
>>
>> then this call OnCreate() is called, like you mentioned
>> 

Re: [Plplot-devel] wxPLplotDemo.cpp errors

2016-12-10 Thread Pedro Vicente
Hi Phil

> I have included the devel list on this email, so the thread will get
> documented on the mailing list.


I have been posting everything to the list

> Am I correct in saying that you are getting this segfault with the
> unchanged demo app?


yes, correct


>It cannot be included in the
> constructor, because the generic nature of the template specification

yes, exactly


>>> I do have access to a CentOS machine at work, although I think I have
> only got access to wxWidgets 2.8 on that system.

I just did a build on Ubuntu with wxWidgets installed from package (not sure 
which version, I will check)
see last email

>> I presume you are using 3.1.0 as
> released in February,

yes, on CentOS


-Pedro




- Original Message - 
From: "Phil Rosenberg" <p.d.rosenb...@gmail.com>
To: "Pedro Vicente" <pedro.vice...@space-research.org>; 
<plplot-devel@lists.sourceforge.net>
Sent: Saturday, December 10, 2016 3:57 AM
Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors


> Hi Pedro
> I have included the devel list on this email, so the thread will get
> documented on the mailing list.
>
> It is very strange that the OnCreate function is not being called. If
> you are calling Create then you should be generating a create event.
> Am I correct in saying that you are getting this segfault with the
> unchanged demo app?
>
> This location really is the best (and maybe only) place this
> initialisation should be done. It cannot be included in the
> constructor, because the generic nature of the template specification
> means the code in the constructor does not know which type of wxWindow
> we are inheriting from so cannot pass the correct parameters to the
> constructor. By the time OnPaint is called it is really too late,
> because we would like to already have the plot initialised and ready
> to draw and it would be a real pain for you in your code if you had to
> somehow wait for the first paint or resize event.
>
> I do have access to a CentOS machine at work, although I think I have
> only got access to wxWidgets 2.8 on that system. I will check. I may
> be able to build 3.1 from source. I presume you are using 3.1.0 as
> released in February, rather than the head of the master branch?
>
> On 10 December 2016 at 07:52, Pedro Vicente
> <pedro.vice...@space-research.org> wrote:
>> Hi Phil
>>
>> My idea for a fix is to move the stream initialization that is now  on
>>
>> void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
>> {
>> if ( !m_created )
>>
>> either to the OnSize or onPaint events
>>
>> void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
>>
>> and also in the plot call do this
>>
>> template< class WXWINDOW >
>> void Plot( wxPLplotwindow *plotwindow )
>> {
>>wxPLplotstream* pls = plotwindow->GetStream();
>>
>>if (pls == NULL)
>>{
>>  return;
>>}
>>
>>
>> Like this , in this sequence
>>
>>
>> wxPLplotwindow *frame = new wxPLplotwindow();
>>frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>>frame->SetIcon( wxIcon( graph ) );
>>frame->Show();
>>Plot( frame );
>>
>>
>> first we go to
>> Plot( frame );
>>
>> but the stream is NULL because
>> :OnCreate
>> was not called, but the function returns, avoiding the seg fault
>>
>> then the window gets a paint or size event, and the stream initialization
>> code is called
>> at this time I have a PLplot empty black window
>>
>> but because
>> Plot( frame );
>> was only called at start, it is not called again, so there is no draw
>>
>> any ideas here ?
>>
>> of course making the Plot() call in another app function should work
>>
>>
>> If you could replicate this issue, that would be great.
>> I am using CentOS 6.8, PLplot.5.11.1 , wxWidgets 3.1.0
>>
>>
>>
>>
>>
>> - Original Message - From: Pedro Vicente
>> To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
>> Sent: Saturday, December 10, 2016 12:59 AM
>> Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors
>>
>>
>> Hi Phil
>>
>> So, the issue seems to be the same that I have been reporting
>>
>>
>> In the wxPLplotDemo.cpp code you have these callling functions
>>
>>
>> wxPLplotwindow *frame = new wxPlDemoFrame();
>> frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>>
>>
>> that make 2 calls to the PLplot library, or the wxWidgets driver of it
>&g

Re: [Plplot-devel] wxPLplotDemo.cpp errors

2016-12-10 Thread Pedro Vicente
Hi Phil

I tested on a different setting

Ubuntu i686 GNU/Linux

Using wxWidgets installed from packages
using the PLplot from git

git clone http://git.code.sf.net/p/plplot/plplot plplot-plplot
cd plplot-plplot/
mkdir build
cd  build
cmake ..  -G "Unix 
Makefiles" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS:BOOL=OFF 
-DENABLE_f95:BOOL=OFF 
 -DENABLE_tcl:BOOL=OFF -DENABLE_tk:BOOL=OFF 
-DCMAKE_INSTALL_PREFIX:PATH=/home/pvn/install/plplot-5.11.1 
 -DPL_HAVE_PTHREAD:BOOL=OFF -DPLD_xwin:BOOL=OFF -DPLD_wxwidgets:BOOL=ON 
-DwxWidgets_ROOT_DIR:PATH=/usr/lib/i386-linux-gnu 
 -DwxWidgets_LIB_DIR:PATH=/usr/lib/i386-linux-gnu 
-DwxWidgets_CONFIGURATION=mswud 
 -DENABLE_MIX_CXX=ON -DwxWidgets_EXCLUDE_COMMON_LIBRARIES:BOOL=OFF 
-DBUILD_TEST:BOOL=ON 
 >& cmake.txt &
make >& make.txt &
 cd /home/pvn/svn/plot/plplot-5.11.1/build/examples/c++/
./wxPLplotDemo
Segmentation fault (core dumped)



-Pedro



- Original Message - 
From: "Pedro Vicente" <pedro.vice...@space-research.org>
To: <plplot-devel@lists.sourceforge.net>; "Phil Rosenberg" 
<p.d.rosenb...@gmail.com>
Sent: Saturday, December 10, 2016 2:52 AM
Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors


> Hi Phil
>
> My idea for a fix is to move the stream initialization that is now  on
>
> void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
> {
> if ( !m_created )
>
> either to the OnSize or onPaint events
>
> void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
>
> and also in the plot call do this
>
> template< class WXWINDOW >
> void Plot( wxPLplotwindow *plotwindow )
> {
>wxPLplotstream* pls = plotwindow->GetStream();
>
>if (pls == NULL)
>{
>  return;
>}
>
>
> Like this , in this sequence
>
>
> wxPLplotwindow *frame = new wxPLplotwindow();
>frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>frame->SetIcon( wxIcon( graph ) );
>frame->Show();
>Plot( frame );
>
>
> first we go to
> Plot( frame );
>
> but the stream is NULL because
> :OnCreate
> was not called, but the function returns, avoiding the seg fault
>
> then the window gets a paint or size event, and the stream initialization
> code is called
> at this time I have a PLplot empty black window
>
> but because
> Plot( frame );
> was only called at start, it is not called again, so there is no draw
>
> any ideas here ?
>
> of course making the Plot() call in another app function should work
>
>
> If you could replicate this issue, that would be great.
> I am using CentOS 6.8, PLplot.5.11.1 , wxWidgets 3.1.0
>
>
>
>
>
> - Original Message - 
> From: Pedro Vicente
> To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
> Sent: Saturday, December 10, 2016 12:59 AM
> Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors
>
>
> Hi Phil
>
> So, the issue seems to be the same that I have been reporting
>
>
> In the wxPLplotDemo.cpp code you have these callling functions
>
>
> wxPLplotwindow *frame = new wxPlDemoFrame();
> frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>
>
> that make 2 calls to the PLplot library, or the wxWidgets driver of it
> all these calls are in the header file wxPLplotwindow.h
>
> first the constructor is called
>
> template
> wxPLplotwindow::wxPLplotwindow( bool useGraphicsContext, wxSize
> clientSize )
>: m_created( false ), m_initialSize( clientSize )
>
>
> then this call OnCreate() is called, like you mentioned
> and the !m_created bool makes the initialization of the stream happen
>
> the problem is  that this function id *NOT* called on my linux build (it 
> is
> on the Windows build)
> so therefore later
> wxPLplotstream* pls = plotwindow->GetStream();
> this is NULL, so therefore it seg faults on the plot calls
>
> //! This is called when the widow is created i.e. after WXWINDOW::Create
> // has been called. We note that this has been called to avoid attempting
> // to redraw a plot on a window that hasn't been created yet.
> template
> void wxPLplotwindow::OnCreate( wxWindowCreateEvent  )
> {
> if ( !m_created )
>
> so, one quick try is to put the code of
>
> void wxPLplotwindow::OnCreate
> that is not called on the constructor maybe ?
>
> -Pedro
>
> - Original Message - 
> From: Pedro Vicente
> To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
> Sent: Friday, December 09, 2016 11:57 PM
> Subject: [Plplot-devel] wxPLplotDemo.cpp errors
>
>
> Hi Phil
>
> So, resuming the last thread about wxWidgets, what I did was to build and
> run wxPLplotDemo.cpp from PLpplot 5.11.1 on CentOS 6.8
>

Re: [Plplot-devel] wxPLplotDemo.cpp errors

2016-12-10 Thread Phil Rosenberg
Hi Pedro
I have included the devel list on this email, so the thread will get
documented on the mailing list.

It is very strange that the OnCreate function is not being called. If
you are calling Create then you should be generating a create event.
Am I correct in saying that you are getting this segfault with the
unchanged demo app?

This location really is the best (and maybe only) place this
initialisation should be done. It cannot be included in the
constructor, because the generic nature of the template specification
means the code in the constructor does not know which type of wxWindow
we are inheriting from so cannot pass the correct parameters to the
constructor. By the time OnPaint is called it is really too late,
because we would like to already have the plot initialised and ready
to draw and it would be a real pain for you in your code if you had to
somehow wait for the first paint or resize event.

I do have access to a CentOS machine at work, although I think I have
only got access to wxWidgets 2.8 on that system. I will check. I may
be able to build 3.1 from source. I presume you are using 3.1.0 as
released in February, rather than the head of the master branch?

On 10 December 2016 at 07:52, Pedro Vicente
<pedro.vice...@space-research.org> wrote:
> Hi Phil
>
> My idea for a fix is to move the stream initialization that is now  on
>
> void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
> {
> if ( !m_created )
>
> either to the OnSize or onPaint events
>
> void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
>
> and also in the plot call do this
>
> template< class WXWINDOW >
> void Plot( wxPLplotwindow *plotwindow )
> {
>wxPLplotstream* pls = plotwindow->GetStream();
>
>if (pls == NULL)
>{
>  return;
>}
>
>
> Like this , in this sequence
>
>
> wxPLplotwindow *frame = new wxPLplotwindow();
>frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>frame->SetIcon( wxIcon( graph ) );
>frame->Show();
>Plot( frame );
>
>
> first we go to
> Plot( frame );
>
> but the stream is NULL because
> :OnCreate
> was not called, but the function returns, avoiding the seg fault
>
> then the window gets a paint or size event, and the stream initialization
> code is called
> at this time I have a PLplot empty black window
>
> but because
> Plot( frame );
> was only called at start, it is not called again, so there is no draw
>
> any ideas here ?
>
> of course making the Plot() call in another app function should work
>
>
> If you could replicate this issue, that would be great.
> I am using CentOS 6.8, PLplot.5.11.1 , wxWidgets 3.1.0
>
>
>
>
>
> - Original Message - From: Pedro Vicente
> To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
> Sent: Saturday, December 10, 2016 12:59 AM
> Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors
>
>
> Hi Phil
>
> So, the issue seems to be the same that I have been reporting
>
>
> In the wxPLplotDemo.cpp code you have these callling functions
>
>
> wxPLplotwindow *frame = new wxPlDemoFrame();
> frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
>
>
> that make 2 calls to the PLplot library, or the wxWidgets driver of it
> all these calls are in the header file wxPLplotwindow.h
>
> first the constructor is called
>
> template
> wxPLplotwindow::wxPLplotwindow( bool useGraphicsContext, wxSize
> clientSize )
>: m_created( false ), m_initialSize( clientSize )
>
>
> then this call OnCreate() is called, like you mentioned
> and the !m_created bool makes the initialization of the stream happen
>
> the problem is  that this function id *NOT* called on my linux build (it is
> on the Windows build)
> so therefore later
> wxPLplotstream* pls = plotwindow->GetStream();
>
> this is NULL, so therefore it seg faults on the plot calls
>
> //! This is called when the widow is created i.e. after WXWINDOW::Create
> // has been called. We note that this has been called to avoid attempting
> // to redraw a plot on a window that hasn't been created yet.
> template
> void wxPLplotwindow::OnCreate( wxWindowCreateEvent  )
> {
> if ( !m_created )
>
> so, one quick try is to put the code of
>
> void wxPLplotwindow::OnCreate
> that is not called on the constructor maybe ?
>
> -Pedro
>
> - Original Message - From: Pedro Vicente
> To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
> Sent: Friday, December 09, 2016 11:57 PM
> Subject: [Plplot-devel] wxPLplotDemo.cpp errors
>
>
> Hi Phil
>
> So, resuming the last thread about wxWidgets, what I did was to build and
> run wxPLplotDemo.cpp from PLpplot 5

Re: [Plplot-devel] wxPLplotDemo.cpp errors

2016-12-09 Thread Pedro Vicente
Hi Phil

My idea for a fix is to move the stream initialization that is now  on

void wxPLplotwindow::OnCreate( wxWindowCreateEvent 
{
if ( !m_created )

either to the OnSize or onPaint events

void wxPLplotwindow::OnSize( wxSizeEvent& WXUNUSED( event ) )

and also in the plot call do this

template< class WXWINDOW >
void Plot( wxPLplotwindow *plotwindow )
{
wxPLplotstream* pls = plotwindow->GetStream();

if (pls == NULL)
{
  return;
}


Like this , in this sequence


wxPLplotwindow *frame = new wxPLplotwindow();
frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );
frame->SetIcon( wxIcon( graph ) );
frame->Show();
Plot( frame );


first we go to
Plot( frame );

but the stream is NULL because
:OnCreate
was not called, but the function returns, avoiding the seg fault

then the window gets a paint or size event, and the stream initialization 
code is called
at this time I have a PLplot empty black window

but because
Plot( frame );
was only called at start, it is not called again, so there is no draw

any ideas here ?

of course making the Plot() call in another app function should work


If you could replicate this issue, that would be great.
I am using CentOS 6.8, PLplot.5.11.1 , wxWidgets 3.1.0





- Original Message - 
From: Pedro Vicente
To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
Sent: Saturday, December 10, 2016 12:59 AM
Subject: Re: [Plplot-devel] wxPLplotDemo.cpp errors


Hi Phil

So, the issue seems to be the same that I have been reporting


In the wxPLplotDemo.cpp code you have these callling functions


wxPLplotwindow *frame = new wxPlDemoFrame();
frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );


that make 2 calls to the PLplot library, or the wxWidgets driver of it
all these calls are in the header file wxPLplotwindow.h

first the constructor is called

template
wxPLplotwindow::wxPLplotwindow( bool useGraphicsContext, wxSize 
clientSize )
: m_created( false ), m_initialSize( clientSize )


then this call OnCreate() is called, like you mentioned
and the !m_created bool makes the initialization of the stream happen

the problem is  that this function id *NOT* called on my linux build (it is 
on the Windows build)
so therefore later
wxPLplotstream* pls = plotwindow->GetStream();
this is NULL, so therefore it seg faults on the plot calls

//! This is called when the widow is created i.e. after WXWINDOW::Create
// has been called. We note that this has been called to avoid attempting
// to redraw a plot on a window that hasn't been created yet.
template
void wxPLplotwindow::OnCreate( wxWindowCreateEvent  )
{
if ( !m_created )

so, one quick try is to put the code of

void wxPLplotwindow::OnCreate
that is not called on the constructor maybe ?

-Pedro

- Original Message - 
From: Pedro Vicente
To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg
Sent: Friday, December 09, 2016 11:57 PM
Subject: [Plplot-devel] wxPLplotDemo.cpp errors


Hi Phil

So, resuming the last thread about wxWidgets, what I did was to build and 
run wxPLplotDemo.cpp from PLpplot 5.11.1 on CentOS 6.8

all builds fine, but when I do run , I get a seg fault

[pedro.vicente@rhw9121 c++]$ cd 
/data/home002/pvicente/plplot/build/examples/c++
[pedro.vicente@rhw9121 c++]$ ./wxPLplotDemo
Segmentation fault

I know that only this information is not much help to you to debug, but in 
the next couple of days I'll be debugging this and posting here any 
solution.

my cmake call was

cmake ..  -G "Unix 
Makefiles" -DBUILD_SHARED_LIBS:BOOL=OFF -DENABLE_f95:BOOL=OFF 
-DENABLE_tcl:BOOL=OFF 
 -DENABLE_tk:BOOL=OFF 
-DCMAKE_INSTALL_PREFIX:PATH=/data/data127/pvicente/install/plplot-5.11.1d 
 -DPL_HAVE_PTHREAD:BOOL=OFF -DPLD_xwin:BOOL=OFF -DPLD_wxwidgets:BOOL=ON 
-DwxWidgets_ROOT_DIR:PATH=/data/data127/pvicente/install/wxwidgets-3.1.0 
 -DwxWidgets_LIB_DIR:PATH=/data/data127/pvicente/install/wxwidgets-3.1.0/lib 
 -DwxWidgets_CONFIGURATION=mswud -DENABLE_MIX_CXX=ON 
-DwxWidgets_EXCLUDE_COMMON_LIBRARIES:BOOL=OFF 
 -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DBUILD_TEST:BOOL=ON >& cmake.txt &


the output of
cmake
and
make
are attached

-Pedro



--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi



___
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel




--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and s

Re: [Plplot-devel] wxPLplotDemo.cpp errors

2016-12-09 Thread Pedro Vicente
Hi Phil

So, the issue seems to be the same that I have been reporting


In the wxPLplotDemo.cpp code you have these callling functions


wxPLplotwindow *frame = new wxPlDemoFrame();
frame->Create( NULL, wxID_ANY, wxT( "wxPLplotDemo" ) );


that make 2 calls to the PLplot library, or the wxWidgets driver of it
all these calls are in the header file wxPLplotwindow.h

first the constructor is called

template
wxPLplotwindow::wxPLplotwindow( bool useGraphicsContext, wxSize 
clientSize )
: m_created( false ), m_initialSize( clientSize )


then this call OnCreate() is called, like you mentioned
and the !m_created bool makes the initialization of the stream happen

the problem is  that this function id *NOT* called on my linux build (it is on 
the Windows build)
so therefore later
wxPLplotstream* pls = plotwindow->GetStream();

this is NULL, so therefore it seg faults on the plot calls


//! This is called when the widow is created i.e. after WXWINDOW::Create

// has been called. We note that this has been called to avoid attempting

// to redraw a plot on a window that hasn't been created yet.

template

void wxPLplotwindow::OnCreate( wxWindowCreateEvent  )

{

if ( !m_created )


so, one quick try is to put the code of 
 
void wxPLplotwindow::OnCreate

that is not called on the constructor maybe ?



-Pedro


  - Original Message - 
  From: Pedro Vicente 
  To: plplot-devel@lists.sourceforge.net ; Phil Rosenberg 
  Sent: Friday, December 09, 2016 11:57 PM
  Subject: [Plplot-devel] wxPLplotDemo.cpp errors


  Hi Phil

  So, resuming the last thread about wxWidgets, what I did was to build and run 
wxPLplotDemo.cpp from PLpplot 5.11.1 on CentOS 6.8

  all builds fine, but when I do run , I get a seg fault 

  [pedro.vicente@rhw9121 c++]$ cd 
/data/home002/pvicente/plplot/build/examples/c++
  [pedro.vicente@rhw9121 c++]$ ./wxPLplotDemo
  Segmentation fault

  I know that only this information is not much help to you to debug, but in  
the next couple of days I'll be debugging this and posting here any solution.

  my cmake call was

  cmake ..  -G "Unix Makefiles" -DBUILD_SHARED_LIBS:BOOL=OFF 
-DENABLE_f95:BOOL=OFF -DENABLE_tcl:BOOL=OFF -DENABLE_tk:BOOL=OFF 
-DCMAKE_INSTALL_PREFIX:PATH=/data/data127/pvicente/install/plplot-5.11.1d 
-DPL_HAVE_PTHREAD:BOOL=OFF -DPLD_xwin:BOOL=OFF -DPLD_wxwidgets:BOOL=ON 
-DwxWidgets_ROOT_DIR:PATH=/data/data127/pvicente/install/wxwidgets-3.1.0 
-DwxWidgets_LIB_DIR:PATH=/data/data127/pvicente/install/wxwidgets-3.1.0/lib 
-DwxWidgets_CONFIGURATION=mswud -DENABLE_MIX_CXX=ON 
-DwxWidgets_EXCLUDE_COMMON_LIBRARIES:BOOL=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON 
-DBUILD_TEST:BOOL=ON >& cmake.txt &


  the output of 
  cmake 
  and 
  make 
  are attached

  -Pedro


--


  --
  Developer Access Program for Intel Xeon Phi Processors
  Access to Intel Xeon Phi processor-based developer platforms.
  With one year of Intel Parallel Studio XE.
  Training and support from Colfax.
  Order your platform today.http://sdm.link/xeonphi


--


  ___
  Plplot-devel mailing list
  Plplot-devel@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/plplot-devel
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi___
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel