Fix wxAcceleratorEntry memory leaks in the menu test
Use wxScopedPtr to ensure that all the test accelerator entries are destroyed instead of just being leaked.
This commit is contained in:
committed by
Vadim Zeitlin
parent
18d56818f5
commit
413c05ea85
@@ -17,6 +17,7 @@
|
|||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/accel.h"
|
#include "wx/accel.h"
|
||||||
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -35,11 +36,11 @@ void CheckAccelEntry(const wxAcceleratorEntry& accel, int keycode, int flags)
|
|||||||
*/
|
*/
|
||||||
TEST_CASE( "wxAcceleratorEntry::Create", "[accelentry]" )
|
TEST_CASE( "wxAcceleratorEntry::Create", "[accelentry]" )
|
||||||
{
|
{
|
||||||
wxAcceleratorEntry* pa;
|
wxScopedPtr<wxAcceleratorEntry> pa;
|
||||||
|
|
||||||
SECTION( "Correct behavior" )
|
SECTION( "Correct behavior" )
|
||||||
{
|
{
|
||||||
pa = wxAcceleratorEntry::Create("Foo\tCtrl+Z");
|
pa.reset( wxAcceleratorEntry::Create("Foo\tCtrl+Z") );
|
||||||
|
|
||||||
CHECK( pa );
|
CHECK( pa );
|
||||||
CHECK( pa->IsOk() );
|
CHECK( pa->IsOk() );
|
||||||
@@ -48,21 +49,21 @@ TEST_CASE( "wxAcceleratorEntry::Create", "[accelentry]" )
|
|||||||
|
|
||||||
SECTION( "Tab missing" )
|
SECTION( "Tab missing" )
|
||||||
{
|
{
|
||||||
pa = wxAcceleratorEntry::Create("Shift-Q");
|
pa.reset( wxAcceleratorEntry::Create("Shift-Q") );
|
||||||
|
|
||||||
CHECK( !pa );
|
CHECK( !pa );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "No accelerator key specified" )
|
SECTION( "No accelerator key specified" )
|
||||||
{
|
{
|
||||||
pa = wxAcceleratorEntry::Create("bloordyblop");
|
pa.reset( wxAcceleratorEntry::Create("bloordyblop") );
|
||||||
|
|
||||||
CHECK( !pa );
|
CHECK( !pa );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "Display name parsing" )
|
SECTION( "Display name parsing" )
|
||||||
{
|
{
|
||||||
pa = wxAcceleratorEntry::Create("Test\tBackSpace");
|
pa.reset( wxAcceleratorEntry::Create("Test\tBackSpace") );
|
||||||
|
|
||||||
CHECK( pa );
|
CHECK( pa );
|
||||||
CHECK( pa->IsOk() );
|
CHECK( pa->IsOk() );
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/menu.h"
|
#include "wx/menu.h"
|
||||||
|
#include "wx/scopedptr.h"
|
||||||
#include "wx/translation.h"
|
#include "wx/translation.h"
|
||||||
#include "wx/uiaction.h"
|
#include "wx/uiaction.h"
|
||||||
|
|
||||||
@@ -624,7 +625,9 @@ namespace
|
|||||||
|
|
||||||
void VerifyAccelAssigned( wxString labelText, int keycode )
|
void VerifyAccelAssigned( wxString labelText, int keycode )
|
||||||
{
|
{
|
||||||
wxAcceleratorEntry* entry = wxAcceleratorEntry::Create( labelText );
|
const wxScopedPtr<wxAcceleratorEntry> entry(
|
||||||
|
wxAcceleratorEntry::Create( labelText )
|
||||||
|
);
|
||||||
|
|
||||||
CHECK( entry );
|
CHECK( entry );
|
||||||
CHECK( entry->GetKeyCode() == keycode );
|
CHECK( entry->GetKeyCode() == keycode );
|
||||||
|
Reference in New Issue
Block a user