If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Hi, I encounter a strange error when running my program. I have no error on compiling. In fact, I have a function associated with the event coming up when clicking on an OK button that I added and then I close the window (by the method Destroy();), and I just close the window when the user clicks on the Cancel button I created. The window is closed when clicking on the cancel button, but when clicking on ok, the code is executed, but the program crashes when reaching the end of the function...
Here is my code:
Do not use Destroy() use Close() instead. What you are doing now is deleting an object you are still executing code in. Close will post an EVT_CLOSE to the main loop, and it will be handled safely after you exit this handler.
I tried with Close but I still got the problem. Notice that the problem is still present where I don't write anything at the end (I mean when I just drop Destroy and don't try to close the wxdialog)...
GianT wrote:I tried with Close but I still got the problem. Notice that the problem is still present where I don't write anything at the end (I mean when I just drop Destroy and don't try to close the wxdialog)...
So, could it be that the problem is not related to wxWidgets? Maybe something is wrong with your MySQL stuff..
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
Yes it seems so. Indeed, I just tried to comment the mysql part and it works well... But when I let even the mysql_init and the mysql_close (without all the requests) I have the problem... I am fed up with that I don't understand why this s**t bugs :@@@@@
Yeah you might look at the MSSQL object is it allowed to create this instance on the stack ?
Anyway the Close / Destroy was definately an issue of concern as this cleans up the object you are in yourself (ok after all events are handled, but you never know)..
To come back to the mysql problem, it sounds logical that the stack object creation is wrong. Because you declare a temp object in your function, assign it to:
And where do you tell the mysql framework the object is invalid? mysql cannot smell that the function you are in already cleaned this object. And that's ofcourse what happens upon exit of the function