Revert "Fix fields initialization in wxCommandEvent copy ctor."
This reverts commit 62763ad541
which seems to
have been completely unnecessary as the fields had been already initialized
and this commit actually broke initialization of the propagation level of the
copied wxCommandEvent objects.
Add a unit test proving that things do work.
Closes #16739.
This commit is contained in:
@@ -1502,8 +1502,10 @@ public:
|
||||
{
|
||||
m_clientData = NULL;
|
||||
m_clientObject = NULL;
|
||||
m_isCommandEvent = true;
|
||||
|
||||
Init();
|
||||
// the command events are propagated upwards by default
|
||||
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
|
||||
}
|
||||
|
||||
wxCommandEvent(const wxCommandEvent& event)
|
||||
@@ -1516,8 +1518,6 @@ public:
|
||||
// need to copy it explicitly.
|
||||
if ( m_cmdString.empty() )
|
||||
m_cmdString = event.GetString();
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
// Set/Get client data from controls
|
||||
@@ -1549,13 +1549,6 @@ 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;
|
||||
}
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCommandEvent);
|
||||
};
|
||||
|
@@ -248,6 +248,7 @@ private:
|
||||
#endif
|
||||
CPPUNIT_TEST( DocView );
|
||||
WXUISIM_TEST( ContextMenuEvent );
|
||||
CPPUNIT_TEST( PropagationLevel );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void OneHandler();
|
||||
@@ -260,6 +261,7 @@ private:
|
||||
void MenuEvent();
|
||||
void DocView();
|
||||
void ContextMenuEvent();
|
||||
void PropagationLevel();
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(EventPropagationTestCase);
|
||||
};
|
||||
@@ -669,4 +671,31 @@ void EventPropagationTestCase::ContextMenuEvent()
|
||||
CPPUNIT_ASSERT_EQUAL( "p", g_str );
|
||||
}
|
||||
|
||||
// Helper function: get the event propagation level.
|
||||
int GetPropagationLevel(wxEvent& e)
|
||||
{
|
||||
const int level = e.StopPropagation();
|
||||
e.ResumePropagation(level);
|
||||
return level;
|
||||
}
|
||||
|
||||
void EventPropagationTestCase::PropagationLevel()
|
||||
{
|
||||
wxSizeEvent se;
|
||||
CPPUNIT_ASSERT_EQUAL( GetPropagationLevel(se), (int)wxEVENT_PROPAGATE_NONE );
|
||||
|
||||
wxCommandEvent ce;
|
||||
CPPUNIT_ASSERT_EQUAL( GetPropagationLevel(ce), (int)wxEVENT_PROPAGATE_MAX );
|
||||
|
||||
wxCommandEvent ce2(ce);
|
||||
CPPUNIT_ASSERT_EQUAL( GetPropagationLevel(ce2), (int)wxEVENT_PROPAGATE_MAX );
|
||||
|
||||
wxCommandEvent ce3;
|
||||
ce3.ResumePropagation(17);
|
||||
CPPUNIT_ASSERT_EQUAL( GetPropagationLevel(ce3), 17 );
|
||||
|
||||
wxCommandEvent ce4(ce3);
|
||||
CPPUNIT_ASSERT_EQUAL( GetPropagationLevel(ce4), 17 );
|
||||
}
|
||||
|
||||
#endif // wxUSE_UIACTIONSIMULATOR
|
||||
|
Reference in New Issue
Block a user