0000525: Crash when doing an undo of an already deleted object
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5334 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
aab04bd85e
commit
d388f35fd0
|
@ -294,19 +294,20 @@ void Document::openTransaction(const char* name)
|
|||
d->activeUndoTransaction = new Transaction();
|
||||
if (name)
|
||||
d->activeUndoTransaction->Name = name;
|
||||
else
|
||||
d->activeUndoTransaction->Name = "<empty>";
|
||||
}
|
||||
}
|
||||
|
||||
void Document::_checkTransaction(void)
|
||||
{
|
||||
// if the undo is active but no transaction open, open one!
|
||||
if (d->iUndoMode)
|
||||
if (! d->activeUndoTransaction)
|
||||
if (d->iUndoMode) {
|
||||
if (!d->activeUndoTransaction)
|
||||
openTransaction();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Document::_clearRedos()
|
||||
{
|
||||
while (!mRedoTransactions.empty()) {
|
||||
|
@ -420,7 +421,6 @@ void Document::onChanged(const Property* prop)
|
|||
|
||||
void Document::onBeforeChangeProperty(const DocumentObject *Who, const Property *What)
|
||||
{
|
||||
_checkTransaction();
|
||||
if (d->activeUndoTransaction && !d->rollback)
|
||||
d->activeUndoTransaction->addObjectChange(Who,What);
|
||||
}
|
||||
|
@ -1232,8 +1232,6 @@ bool Document::_recomputeFeature(DocumentObject* Feat)
|
|||
|
||||
void Document::recomputeFeature(DocumentObject* Feat)
|
||||
{
|
||||
_checkTransaction();
|
||||
|
||||
// delete recompute log
|
||||
for( std::vector<App::DocumentObjectExecReturn*>::iterator it=_RecomputeLog.begin();it!=_RecomputeLog.end();++it)
|
||||
delete *it;
|
||||
|
@ -1300,8 +1298,6 @@ DocumentObject * Document::addObject(const char* sType, const char* pObjectName)
|
|||
|
||||
void Document::_addObject(DocumentObject* pcObject, const char* pObjectName)
|
||||
{
|
||||
_checkTransaction();
|
||||
|
||||
d->objectMap[pObjectName] = pcObject;
|
||||
d->objectArray.push_back(pcObject);
|
||||
// cache the pointer to the name string in the Object (for performance of DocumentObject::getNameInDocument())
|
||||
|
|
|
@ -260,7 +260,7 @@ protected:
|
|||
void _remObject(DocumentObject* pcObject);
|
||||
void _addObject(DocumentObject* pcObject, const char* pObjectName);
|
||||
DocumentObject* _copyObject(DocumentObject* obj, std::map<DocumentObject*,
|
||||
DocumentObject*>&, bool rcursive=false);
|
||||
DocumentObject*>&, bool recursive=false);
|
||||
/// checks if a valid transaction is open
|
||||
void _checkTransaction(void);
|
||||
void breakDependency(DocumentObject* pcObject, bool clear);
|
||||
|
|
|
@ -47,6 +47,15 @@ class DocumentBasicCases(unittest.TestCase):
|
|||
self.Doc.commitTransaction()
|
||||
self.Doc.undo()
|
||||
|
||||
def testAddRemoveUndo(self):
|
||||
# Bug #0000525
|
||||
self.Doc.openTransaction("Add")
|
||||
obj=self.Doc.addObject("App::FeatureTest","Label")
|
||||
self.Doc.commitTransaction()
|
||||
self.Doc.removeObject(obj.Name)
|
||||
self.Doc.undo()
|
||||
self.Doc.undo()
|
||||
|
||||
def testRemoval(self):
|
||||
# Cannot write a real test case for that but when debugging the
|
||||
# C-code there shouldn't be a memory leak (see rev. 1814)
|
||||
|
|
Loading…
Reference in New Issue
Block a user