Fix fields initialization in wxCommandEvent copy ctor.

Neither m_isCommandEvent nor, worse, m_propagationLevel was set correctly for
wxCommandEvent objects constructed using copy ctor -- and hence Clone(). This
means that such events were not propagated upwards the window hierarchy, quite
possibly resulting in mysterious bugs.

Fix this now by initializing these fields in both the normal and copy ctors.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78229 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2014-12-05 22:17:52 +00:00
parent 693abd284f
commit 62763ad541
2 changed files with 18 additions and 12 deletions

View File

@ -1496,7 +1496,14 @@ class WXDLLIMPEXP_CORE wxCommandEvent : public wxEvent,
public wxEventBasicPayloadMixin
{
public:
wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
wxCommandEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
: wxEvent(winid, commandType)
{
m_clientData = NULL;
m_clientObject = NULL;
Init();
}
wxCommandEvent(const wxCommandEvent& event)
: wxEvent(event),
@ -1508,6 +1515,8 @@ public:
// need to copy it explicitly.
if ( m_cmdString.empty() )
m_cmdString = event.GetString();
Init();
}
// Set/Get client data from controls
@ -1539,6 +1548,14 @@ protected:
wxClientData* m_clientObject; // Arbitrary client object
private:
void Init()
{
m_isCommandEvent = true;
// the command events are propagated upwards by default
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
}
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent)
};

View File

@ -423,17 +423,6 @@ wxEvent& wxEvent::operator=(const wxEvent& src)
// wxCommandEvent
// ----------------------------------------------------------------------------
wxCommandEvent::wxCommandEvent(wxEventType commandType, int theId)
: wxEvent(theId, commandType)
{
m_clientData = NULL;
m_clientObject = NULL;
m_isCommandEvent = true;
// the command events are propagated upwards by default
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
}
wxString wxCommandEvent::GetString() const
{
// This is part of the hack retrieving the event string from the control