How to build standalone wxWidgets application

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
User avatar
doublemax
Moderator
Moderator
Posts: 13881
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to build standalone wxWidgets application

Post by doublemax » Mon Apr 01, 2019 5:53 pm

For completeness sake:
Is it possible, that my global pointer to Frame can cause the crash?
No. A pointer in itself is safe, the question is when the instance of the class gets created. If you do it in OnInit(), it's fine.
Use the source, Luke!

ValeV
Experienced Solver
Experienced Solver
Posts: 68
Joined: Wed Jan 30, 2019 1:39 pm

Re: How to build standalone wxWidgets application

Post by ValeV » Tue Apr 02, 2019 8:57 am

Thank you. Can you give any information on my "fix"?
EDIT: I MANAGED TO "FIX" IT. I don't know if it's fixed, but it stopped crashing. In CodeBlocks went to build options and unchecked "Optimize even more" (4th flag under Optimization).
Apparently there ware a few optimization bugs in wxWidgets headers, but they were fixed some time ago?

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

Re: How to build standalone wxWidgets application

Post by doublemax » Tue Apr 02, 2019 9:27 am

Can you give any information on my "fix"?
Not really. But if compiler optimization was the root of the problem, it would have been a bug in the compiler, not wxWidgets.
Use the source, Luke!

ValeV
Experienced Solver
Experienced Solver
Posts: 68
Joined: Wed Jan 30, 2019 1:39 pm

Re: How to build standalone wxWidgets application

Post by ValeV » Tue Apr 02, 2019 11:21 am

I think I may have found a possible bug in my app. Let me know what you think. :)

I realized I don't have

Code: Select all

void OnClose(wxCloseEvent& event);
function, and its implementation.

I don't remember deleting it, but maybe I did it because with it, the X button (Close application) in upper right corner of application didn't work. Without it, X works fine.

Is this possible?

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

Re: How to build standalone wxWidgets application

Post by doublemax » Tue Apr 02, 2019 12:46 pm

The default behavior of a wxFrame is to destroy itself when it's closed. But if you override that by catching the close event, you're responsible for what happens. Usually you just have to call event.Skip() inside the close event handler, so that the default behavior is still executed. In that case you must not delete the frame yourself.
Use the source, Luke!

Post Reply