wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
ErwinH
In need of some credit
In need of some credit
Posts: 4
Joined: Wed Aug 05, 2015 6:05 am

wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Postby ErwinH » Wed Sep 16, 2015 10:44 am

I'm trying to use wxFreeChart 1.6 with wxWidgets 3.0.2 compiled with gcc under Windows.
There are two scenarios where no chart can be displayed and the demo app and/or the application using wxFreeChart crashes:

- Using gcc compiler optimization -O3 (demo app and user app)
- When deriving from wxChartPanel and creating an instance thereof (only user app)

When I use compiler optimization -O2, there is no crash. When I use the class wxChartPanel directly, there is no crash either.

Does anyone has found a similar behavior and/or has found where the problem is?

User avatar
doublemax
Moderator
Moderator
Posts: 11479
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Postby doublemax » Wed Sep 16, 2015 11:22 am

Which gcc version?

- Using gcc compiler optimization -O3 (demo app and user app)
Sounds like a compiler bug.

- When deriving from wxChartPanel and creating an instance thereof (only user app)
Hard to tell without seeing code.
Use the source, Luke!

iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 257
Joined: Tue Mar 19, 2013 8:52 pm

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Postby iwbnwif » Wed Sep 16, 2015 6:29 pm

Please check to make sure that your wxChartPanel is not being set to either wxSize(0,0) or wxDefaultSize (I can't remember which) because this was causing a lot of crashes for me.
wxWidgets 3.10, TDM MinGW64 5.1.0, g++ 4.8.2, Ubuntu 16.04LTS, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.

ErwinH
In need of some credit
In need of some credit
Posts: 4
Joined: Wed Aug 05, 2015 6:05 am

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Postby ErwinH » Thu Sep 17, 2015 9:07 am

I use mingw32 with gcc 4.7.2 compiler.

Regarding the second problem, I have found the problem. This is the test class that is derived from wxChartPanel:

Code: Select all

class MyChartPanel : public wxChartPanel
{
public:
   /**
    * @brief Constructor.
    *
    * @param pParent Parent window.
    * @param pId Window identifier. If <code>wxID_ANY</code> a new unique identifier is created.
    * @param pPos Window position.
    * @param pSize Window size.
    */
   MyChartPanel( wxWindow *pParent, wxWindowID pId = wxID_ANY,
              const wxPoint &pPos = wxDefaultPosition,
              const wxSize &pSize = wxDefaultSize );
   /**
    * @brief Destructor.
    */
   virtual ~MyChartPanel();
};

// Implementation of constructor & destructor
MyChartPanel::MyChartPanel(   wxWindow *pParent, wxWindowID pId,
                     const wxPoint &pPos,
                     const wxSize &pSize )
//   : wxChartPanel(this, pId, NULL, pPos, pSize) {         // crash
   : wxChartPanel(pParent, pId, NULL, pPos, pSize) {      // no crash
   // nothing to do here
}

MyChartPanel::~MyChartPanel() {
   // nothing to do here
}


The problem was that I did not pass the parent window to wxChartPanel properly. So now I can derive from wxChartPanel with ease. :D
I did not see a problem with wxSize(0,0) or wxDefaultSize so far.

PB
wxWorld Domination!
wxWorld Domination!
Posts: 1317
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Postby PB » Thu Sep 17, 2015 9:17 am

ErwinH wrote:I did not see a problem with wxSize(0,0) or wxDefaultSize so far.


I noticed a similar issue with wxFreeChart and wxWidgets trunk, but it was "only" an assert for me, easily fixed:
https://github.com/pbfordev/wxFreeChart/commit/6e74f178b9dcace85fa9acbec89b59872d6ffb4e

iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 257
Joined: Tue Mar 19, 2013 8:52 pm

Re: wxFreeChart crashes with gcc optimization -O3 and when deriving from wxChartPanel

Postby iwbnwif » Thu Sep 17, 2015 7:43 pm

I noticed a similar issue with wxFreeChart and wxWidgets trunk, but it was "only" an assert for me, easily fixed:
https://github.com/pbfordev/wxFreeChart ... 872d6ffb4e

Ah yes, that is exactly it. Sorry, I forgot that they were only asserts.
wxWidgets 3.10, TDM MinGW64 5.1.0, g++ 4.8.2, Ubuntu 16.04LTS, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 1 guest