mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-05-10 19:14:57 +02:00
see #2654 fixes GUI crash that occured if user copied a rule from file A to file B, then closed file B, opened file C and tried to copy the same rule from A to C
This commit is contained in:
@@ -498,6 +498,25 @@ void FWObjectDatabase::buildIndex()
|
||||
addToIndexRecursive(this);
|
||||
}
|
||||
|
||||
void FWObjectDatabase::validateIndex()
|
||||
{
|
||||
std::map<int, FWObject*>::iterator it;
|
||||
for (it=obj_index.begin(); it!=obj_index.end(); ++it)
|
||||
{
|
||||
if (it->second->getRoot() != this)
|
||||
{
|
||||
cerr << "Object '" << it->second->getName() << "'"
|
||||
<< " ( "
|
||||
<< it->second
|
||||
<< " type " << it->second->getTypeName() << ")"
|
||||
<< " in index of db " << this
|
||||
<< " has incorrect db root ptr "
|
||||
<< it->second->getRoot()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FWObjectDatabase::_clearReferenceCounters(FWObject *o)
|
||||
{
|
||||
o->clearRefCounter();
|
||||
|
||||
@@ -335,6 +335,11 @@ public:
|
||||
*/
|
||||
void getIndexStats(int &index_size, int &hit_counter, int &miss_counter);
|
||||
|
||||
/**
|
||||
* this function is intended for debugging.
|
||||
*/
|
||||
void validateIndex();
|
||||
|
||||
/**
|
||||
* Some operations, such as object tree merging, should ignore
|
||||
* read-only flag on individual objects.
|
||||
|
||||
@@ -595,9 +595,10 @@ FWObject* FWObjectDatabase::_recursively_copy_subtree(
|
||||
|
||||
// search for old_ptr_obj in the index. If it is found, we do not
|
||||
// need to copy it and its ID is valid (perhaps standard object?)
|
||||
if (findInIndex(old_ptr_obj->getId())!=NULL)
|
||||
n_ptr_obj = findInIndex(old_ptr_obj->getId());
|
||||
if (n_ptr_obj != NULL)
|
||||
{
|
||||
nobj->addRef(old_ptr_obj);
|
||||
nobj->addRef(n_ptr_obj);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1504,9 +1504,7 @@ void RuleSetView::pasteRuleAbove()
|
||||
i!=FWObjectClipboard::obj_clipboard->end(); ++i)
|
||||
{
|
||||
Rule *rule = Rule::cast(createInsertTemplate(i->second, i->first));
|
||||
|
||||
if (!rule || !md->checkRuleType(rule)) continue;
|
||||
|
||||
project->undoStack->push(
|
||||
new FWCmdRuleInsert(
|
||||
project, md->getRuleSet(), md->getRulePosition(index), false, rule));
|
||||
@@ -1557,11 +1555,32 @@ FWObject* RuleSetView::createInsertTemplate(ProjectPanel* proj_p, int id)
|
||||
md->getRuleSet()->remove(t);
|
||||
|
||||
project->m_panel->om->reload();
|
||||
} else {
|
||||
|
||||
} else
|
||||
{
|
||||
t = proj_p->db()->create(co->getTypeName());
|
||||
t->duplicate(co);
|
||||
}
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
cerr << "rulesrt->getRoot()=" << md->getRuleSet()->getRoot()
|
||||
<< " "
|
||||
<< "proj_p->db()=" << proj_p->db()
|
||||
<< " "
|
||||
<< "proj_p file=" << proj_p->getFileName().toStdString()
|
||||
<< " "
|
||||
<< "id=" << id
|
||||
<< " "
|
||||
<< "co=" << co
|
||||
<< " "
|
||||
<< "co->getRoot()=" << co->getRoot()
|
||||
<< endl;
|
||||
|
||||
cerr << "Validating database index" << endl;
|
||||
proj_p->db()->getRoot()->validateIndex();
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user