This commit is contained in:
YuSanka 2019-07-31 17:14:51 +02:00
commit 78645ca9ce
2 changed files with 21 additions and 1 deletions

View File

@ -496,6 +496,15 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
set_action_icon(); 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() void ObjectDataViewModelNode::set_action_icon()
{ {
m_action_icon_name = m_type & itObject ? "advanced_plus" : m_action_icon_name = m_type & itObject ? "advanced_plus" :
@ -1417,6 +1426,7 @@ wxDataViewItem ObjectDataViewModel::GetParent(const wxDataViewItem &item) const
return wxDataViewItem(0); return wxDataViewItem(0);
ObjectDataViewModelNode *node = (ObjectDataViewModelNode*)item.GetID(); ObjectDataViewModelNode *node = (ObjectDataViewModelNode*)item.GetID();
assert(node != nullptr && node->valid());
// objects nodes has no parent too // objects nodes has no parent too
if (node->m_type == itObject) if (node->m_type == itObject)

View File

@ -158,7 +158,7 @@ DECLARE_VARIANT_OBJECT(DataViewBitmapText)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ObjectDataViewModelNode: a node inside PrusaObjectDataViewModel // ObjectDataViewModelNode: a node inside ObjectDataViewModel
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
enum ItemType { enum ItemType {
@ -251,6 +251,10 @@ public:
ObjectDataViewModelNode *child = m_children[i]; ObjectDataViewModelNode *child = m_children[i];
delete child; delete child;
} }
#ifndef NDEBUG
// Indicate that the object was deleted.
m_idx = -2;
#endif /* NDEBUG */
} }
bool IsContainer() const bool IsContainer() const
@ -260,6 +264,7 @@ public:
ObjectDataViewModelNode* GetParent() ObjectDataViewModelNode* GetParent()
{ {
assert(m_parent == nullptr || m_parent->valid());
return m_parent; return m_parent;
} }
MyObjectTreeModelNodePtrArray& GetChildren() MyObjectTreeModelNodePtrArray& GetChildren()
@ -346,6 +351,11 @@ public:
bool update_settings_digest(const std::vector<std::string>& categories); bool update_settings_digest(const std::vector<std::string>& categories);
int volume_type() const { return int(m_volume_type); } int volume_type() const { return int(m_volume_type); }
void msw_rescale(); void msw_rescale();
#ifndef NDEBUG
bool valid();
#endif /* NDEBUG */
private: private:
friend class ObjectDataViewModel; friend class ObjectDataViewModel;
}; };