I'd like to use my own main function instead of wxWidgets' provided one (via the macro).
I searched a bit and came up with the following code so far:
Code: Select all
wxApp* pApp = new MyApp(); wxEntry(argc, argv); wxEntryCleanup();
pApp is an instance of MyApp, which extends wxApp and creates a frame (as shown in one of the examples, the simplest one I guess).
This successfully creates the frame (i.e. window), however, when I close it (the frame, via X button), it seems to not deallocate pApp (there is a memory leak). If I try to call delete on it, the whole program crashes. (I can call delete on pApp right after it's allocated, but after the entry stuff it's not possible anymore.
All I want is to be able to create a window, but only when my program (which happens mainly on the console) calls functions to create these windows. Like, I don't want my program to be dependent on wxWidgets.
I am aware wxApp is supposed to represent an app (the whole program), but can wxWidgets be used as I intend? And is it a reliable way to use it?
I am already able to do it, but, as the perfeccionist I am, I want to fix that memory leak, and also know whether the code is correct and I can continue from here.