Commit ad5260a7 authored by David Thompson's avatar David Thompson

Fix updates to ComponentPhraseModel.

Handle the case when descriptive phrases belonging to the
same parent item refer to the same persistent object. For
now, assume that the same object should only appear once
per parent. In the future, other phrase information should
be used to discriminate phrases.

This fixes the issue where the associated-entity list would
be cleared immediately after an operation ran -- not because
the operation removed existing objects, but because new phrases
were constructed that did not match the old phrase (causing a
removal and insertion of the same object, which reset the map
used to hold selected objects).
parent 2eeebe84
......@@ -436,9 +436,13 @@ void PhraseModel::updateChildren(
{
// Run through the entire array to see if there are different instances
// of the phrase that nonetheless behave identically.
// Note that we might have phrases that are different instances
// but identical in that they refer to the same component/resource/etc.,
// hence the second test in the conditional below:
for (auto it2 = orig.begin(); it2 != orig.end(); ++it2)
{
if (it->get() == it2->get())
if ((it->get() == it2->get()) ||
(it->get()->relatedObject() == it2->get()->relatedObject()))
{
*it = *it2;
unused.erase(lkup[*it2]);
......@@ -446,8 +450,6 @@ void PhraseModel::updateChildren(
}
}
}
// But wait, we might have phrases that are different instances
// but identical in that they refer to the same component/resource/etc.
// Now delete unused from model, starting at the back so we don't invalidate indices.
std::vector<int> removalRange(2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment