I understand why this is happening, but I'm stuck trying to resolve it...here is what my code is doing when the error is generated (thus, leading to a crash) when my program exits...
pure virtual method called
SomeClass::~SomeClass()
{
BaseClassObject->SomePureVirtualMethod(this);
}
void DerivedClass::SomePureVirtualMethod(SomeClass* obj)
{
//Do stuff to remove obj from a collection
}
I never have a call to new SomeClass
but I have a QList<SomeClass*>
which I append SomeClass*
objects to. The purpose of this destructor in SomeClass
is to tell DerivedClass
to remove a specific instance of SomeClass
from it's collection of QList<SomeClass*>
.
So, in a concrete example...
BaseClass
= Shape
DerivedClass
= Triangle
SomeClass
= ShapeProperties
which owns a reference to Shape
So, I never have a call to new ShapeProperties
but I have a QList<ShapeProperties*>
inside of Triangle
. The destructor in ShapeProperties
is to tell Triangle
to remove a specific property of ShapeProperties
from it's collection of QList<ShapeProperties*>
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…