X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f97500b80d12d8bbb7bc8162e9b21374b74ac163..eb729cd37a2b6e81fc88a7edbeb7624a5c87a486:/include/wx/event.h diff --git a/include/wx/event.h b/include/wx/event.h index 49c7f58471..b96e4458be 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -359,8 +359,10 @@ public: // exists only for optimization purposes. bool IsCommandEvent() const { return m_isCommandEvent; } - // specialized clone function since it is done a lot - virtual wxEvent *Clone() const { return new wxEvent(*this); } + // this function is used to create a copy of the event polymorphically and + // all derived classes must implement it because otherwise wxPostEvent() + // for them wouldn't work (it needs to do a copy of the event) + virtual wxEvent *Clone() const = 0; public: wxObject* m_eventObject; @@ -372,9 +374,6 @@ public: bool m_isCommandEvent; private: - // normally copying the events is a bad idea, so disable this - wxEvent& operator=(const wxEvent&); - DECLARE_ABSTRACT_CLASS(wxEvent) }; @@ -1285,18 +1284,35 @@ class WXDLLEXPORT wxDropFilesEvent : public wxEvent public: int m_noFiles; wxPoint m_pos; - wxString* m_files; // Memory (de)allocated by code calling ProcessEvent + wxString* m_files; wxDropFilesEvent(wxEventType type = wxEVT_NULL, int noFiles = 0, wxString *files = (wxString *) NULL) { m_eventType = type; m_noFiles = noFiles; m_files = files; } + // we need a copy ctor to avoid deleting m_files pointer twice + wxDropFilesEvent(const wxDropFilesEvent& other) + : m_pos(other.m_pos) + { + m_noFiles = other.m_noFiles; + m_files = new wxString[m_noFiles]; + for ( int n = 0; n < m_noFiles; n++ ) + { + m_files[n] = other.m_files[n]; + } + } + + virtual ~wxDropFilesEvent() + { + delete [] m_files; + } + wxPoint GetPosition() const { return m_pos; } int GetNumberOfFiles() const { return m_noFiles; } wxString *GetFiles() const { return m_files; } - virtual wxEvent *Clone() const { wxFAIL_MSG("error"); return NULL; } + virtual wxEvent *Clone() const { return new wxDropFilesEvent(*this); } private: DECLARE_DYNAMIC_CLASS(wxDropFilesEvent)