asserts for accessing deleted object list nodes.
This commit is contained in:
parent
12a98bea94
commit
93f86b795d
@ -496,6 +496,15 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
|
||||
set_action_icon();
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool ObjectDataViewModelNode::valid()
|
||||
{
|
||||
// Verify that the object was not deleted yet.
|
||||
assert(m_idx >= -1);
|
||||
return m_idx >= -1;
|
||||
}
|
||||
#endif /* NDEBUG */
|
||||
|
||||
void ObjectDataViewModelNode::set_action_icon()
|
||||
{
|
||||
m_action_icon_name = m_type & itObject ? "advanced_plus" :
|
||||
@ -1417,6 +1426,7 @@ wxDataViewItem ObjectDataViewModel::GetParent(const wxDataViewItem &item) const
|
||||
return wxDataViewItem(0);
|
||||
|
||||
ObjectDataViewModelNode *node = (ObjectDataViewModelNode*)item.GetID();
|
||||
assert(node != nullptr && node->valid());
|
||||
|
||||
// objects nodes has no parent too
|
||||
if (node->m_type == itObject)
|
||||
|
@ -158,7 +158,7 @@ DECLARE_VARIANT_OBJECT(DataViewBitmapText)
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ObjectDataViewModelNode: a node inside PrusaObjectDataViewModel
|
||||
// ObjectDataViewModelNode: a node inside ObjectDataViewModel
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
enum ItemType {
|
||||
@ -251,6 +251,10 @@ public:
|
||||
ObjectDataViewModelNode *child = m_children[i];
|
||||
delete child;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
// Indicate that the object was deleted.
|
||||
m_idx = -2;
|
||||
#endif /* NDEBUG */
|
||||
}
|
||||
|
||||
bool IsContainer() const
|
||||
@ -260,6 +264,7 @@ public:
|
||||
|
||||
ObjectDataViewModelNode* GetParent()
|
||||
{
|
||||
assert(m_parent == nullptr || m_parent->valid());
|
||||
return m_parent;
|
||||
}
|
||||
MyObjectTreeModelNodePtrArray& GetChildren()
|
||||
@ -346,6 +351,11 @@ public:
|
||||
bool update_settings_digest(const std::vector<std::string>& categories);
|
||||
int volume_type() const { return int(m_volume_type); }
|
||||
void msw_rescale();
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool valid();
|
||||
#endif /* NDEBUG */
|
||||
|
||||
private:
|
||||
friend class ObjectDataViewModel;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user