Fix memory leak in wxGridSizer::Insert() if an assert in it fails
This avoids another memory leak in the test suite, which intentionally triggers an assert in this function.
This commit is contained in:
committed by
Vadim Zeitlin
parent
02f697d0c0
commit
3dec092dff
@@ -32,6 +32,7 @@
|
|||||||
#include "wx/vector.h"
|
#include "wx/vector.h"
|
||||||
#include "wx/listimpl.cpp"
|
#include "wx/listimpl.cpp"
|
||||||
#include "wx/private/window.h"
|
#include "wx/private/window.h"
|
||||||
|
#include "wx/scopedptr.h"
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -1479,6 +1480,9 @@ wxGridSizer::wxGridSizer( int rows, int cols, const wxSize& gap )
|
|||||||
|
|
||||||
wxSizerItem *wxGridSizer::DoInsert(size_t index, wxSizerItem *item)
|
wxSizerItem *wxGridSizer::DoInsert(size_t index, wxSizerItem *item)
|
||||||
{
|
{
|
||||||
|
// Ensure that the item will be deleted in case of exception.
|
||||||
|
wxScopedPtr<wxSizerItem> scopedItem( item );
|
||||||
|
|
||||||
// if only the number of columns or the number of rows is specified for a
|
// if only the number of columns or the number of rows is specified for a
|
||||||
// sizer, arbitrarily many items can be added to it but if both of them are
|
// sizer, arbitrarily many items can be added to it but if both of them are
|
||||||
// fixed, then the sizer can't have more than that many items -- check for
|
// fixed, then the sizer can't have more than that many items -- check for
|
||||||
@@ -1519,7 +1523,7 @@ wxSizerItem *wxGridSizer::DoInsert(size_t index, wxSizerItem *item)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxSizer::DoInsert(index, item);
|
return wxSizer::DoInsert( index, scopedItem.release() );
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxGridSizer::CalcRowsCols(int& nrows, int& ncols) const
|
int wxGridSizer::CalcRowsCols(int& nrows, int& ncols) const
|
||||||
|
Reference in New Issue
Block a user