Fix assert when constructing invalid wxGBSpan inside wxWidgets itself.
Various wxGridBagSizer methods returning wxGBSpan asserted when trying to construct an invalid wxGBSpan as its components must now (since r66964) be positive. Fix this by adding a special new method to wxGBSpan for constructing such invalid spans and use it now. Closes #15124. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73731 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -67,6 +67,14 @@ public:
|
|||||||
|
|
||||||
// default copy ctor and assignment operator are okay.
|
// default copy ctor and assignment operator are okay.
|
||||||
|
|
||||||
|
// Factor constructor creating an invalid wxGBSpan: this is mostly supposed
|
||||||
|
// to be used as return value for functions returning wxGBSpan in case of
|
||||||
|
// errors.
|
||||||
|
static wxGBSpan Invalid()
|
||||||
|
{
|
||||||
|
return wxGBSpan(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int GetRowspan() const { return m_rowspan; }
|
int GetRowspan() const { return m_rowspan; }
|
||||||
int GetColspan() const { return m_colspan; }
|
int GetColspan() const { return m_colspan; }
|
||||||
void SetRowspan(int rowspan)
|
void SetRowspan(int rowspan)
|
||||||
@@ -87,6 +95,13 @@ public:
|
|||||||
bool operator!=(const wxGBSpan& o) const { return !(*this == o); }
|
bool operator!=(const wxGBSpan& o) const { return !(*this == o); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// This private ctor is used by Invalid() only.
|
||||||
|
wxGBSpan(struct InvalidCtorTag*)
|
||||||
|
{
|
||||||
|
m_rowspan =
|
||||||
|
m_colspan = -1;
|
||||||
|
}
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
m_rowspan =
|
m_rowspan =
|
||||||
|
@@ -312,27 +312,24 @@ bool wxGridBagSizer::SetItemPosition(size_t index, const wxGBPosition& pos)
|
|||||||
|
|
||||||
wxGBSpan wxGridBagSizer::GetItemSpan(wxWindow *window)
|
wxGBSpan wxGridBagSizer::GetItemSpan(wxWindow *window)
|
||||||
{
|
{
|
||||||
wxGBSpan badspan(-1,-1);
|
|
||||||
wxGBSizerItem* item = FindItem(window);
|
wxGBSizerItem* item = FindItem(window);
|
||||||
wxCHECK_MSG( item, badspan, wxT("Failed to find item.") );
|
wxCHECK_MSG( item, wxGBSpan::Invalid(), wxT("Failed to find item.") );
|
||||||
return item->GetSpan();
|
return item->GetSpan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxGBSpan wxGridBagSizer::GetItemSpan(wxSizer *sizer)
|
wxGBSpan wxGridBagSizer::GetItemSpan(wxSizer *sizer)
|
||||||
{
|
{
|
||||||
wxGBSpan badspan(-1,-1);
|
|
||||||
wxGBSizerItem* item = FindItem(sizer);
|
wxGBSizerItem* item = FindItem(sizer);
|
||||||
wxCHECK_MSG( item, badspan, wxT("Failed to find item.") );
|
wxCHECK_MSG( item, wxGBSpan::Invalid(), wxT("Failed to find item.") );
|
||||||
return item->GetSpan();
|
return item->GetSpan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxGBSpan wxGridBagSizer::GetItemSpan(size_t index)
|
wxGBSpan wxGridBagSizer::GetItemSpan(size_t index)
|
||||||
{
|
{
|
||||||
wxGBSpan badspan(-1,-1);
|
|
||||||
wxSizerItemList::compatibility_iterator node = m_children.Item( index );
|
wxSizerItemList::compatibility_iterator node = m_children.Item( index );
|
||||||
wxCHECK_MSG( node, badspan, wxT("Failed to find item.") );
|
wxCHECK_MSG( node, wxGBSpan::Invalid(), wxT("Failed to find item.") );
|
||||||
wxGBSizerItem* item = (wxGBSizerItem*)node->GetData();
|
wxGBSizerItem* item = (wxGBSizerItem*)node->GetData();
|
||||||
return item->GetSpan();
|
return item->GetSpan();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user