Hi everyone, I am making a paint program on wxWidgets and it has a memory leak. When I compile the program there is no error but when I run it it just shut its self down.
I think it's something to do with the 2 pointers I created and how I used them here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class MyFrame : public wxFrame
{
public:
// Constructor
MyFrame(const wxString& title, long style=wxDEFAULT_FRAME_STYLE);
// Event handlers
void OnMouseDown(wxMouseEvent& event);
void OnMouseUp(wxMouseEvent& event);
void Undo(wxCommandEvent& event);
private:
wxPoint *Start;
wxPoint *End;
// This class handles events
DECLARE_EVENT_TABLE()
};
A memory leak usually doesn't have a program shutdown as it's not immediately dangerous.
What you're doing though is causing a segmentation fault (probably) by writing to memory your application may not own. *Start and *End is set to garbage and so you're assigning to garbage locations. You need to set *Start and *End to something useful.