src/ldObject.cpp

changeset 956
2af18ba2665f
parent 952
f116b63c4844
child 958
1dc890c73e01
equal deleted inserted replaced
955:39d789d675fc 956:2af18ba2665f
46 // 46 //
47 LDObject::LDObject (LDDocument* document) : 47 LDObject::LDObject (LDDocument* document) :
48 m_isHidden (false), 48 m_isHidden (false),
49 m_isSelected (false), 49 m_isSelected (false),
50 m_document (nullptr), 50 m_document (nullptr),
51 qObjListEntry (null) 51 qObjListEntry (null),
52 m_isDestroyed (false)
52 { 53 {
53 if (document) 54 if (document)
54 document->addObject (this); 55 document->addObject (this);
55 56
56 memset (m_coords, 0, sizeof m_coords); 57 memset (m_coords, 0, sizeof m_coords);
76 LDOBJ_DEFAULT_CTOR (LDBFC, LDObject) 77 LDOBJ_DEFAULT_CTOR (LDBFC, LDObject)
77 LDOBJ_DEFAULT_CTOR (LDComment, LDObject) 78 LDOBJ_DEFAULT_CTOR (LDComment, LDObject)
78 79
79 LDObject::~LDObject() 80 LDObject::~LDObject()
80 { 81 {
81 // Don't bother during program termination 82 if (not IsExiting() and not m_isDestroyed)
82 if (IsExiting() == false) 83 print ("Warning: Object #%1 was not destroyed before getting deleted\n", id());
83 {
84 deselect();
85
86 // If this object was associated to a file, remove it off it now
87 if (document() != null)
88 document()->forgetObject (this);
89
90 // Delete the GL lists
91 if (g_win != null)
92 g_win->R()->forgetObject (this);
93
94 // Remove this object from the list of LDObjects
95 g_allObjects.erase (g_allObjects.find (id()));
96 }
97 } 84 }
98 85
99 // ============================================================================= 86 // =============================================================================
100 // 87 //
101 void LDObject::chooseID() 88 void LDObject::chooseID()
312 299
313 // ============================================================================= 300 // =============================================================================
314 // 301 //
315 void LDObject::destroy() 302 void LDObject::destroy()
316 { 303 {
304 // Don't bother during program termination (FIXME)
305 if (IsExiting() == false)
306 {
307 deselect();
308
309 // If this object was associated to a file, remove it off it now
310 if (document() != null)
311 document()->forgetObject (this);
312
313 // Delete the GL lists
314 if (g_win != null)
315 g_win->R()->forgetObject (this);
316
317 // Remove this object from the list of LDObjects
318 g_allObjects.erase (g_allObjects.find (id()));
319
320 m_isDestroyed = true;
321 }
322
317 delete this; 323 delete this;
318 } 324 }
319 325
320 // ============================================================================= 326 // =============================================================================
321 // 327 //

mercurial