Bug #9678
openCrash in Wt::Dbo if we clear a collection and add an item.
0%
Description
The following code crashes:
template
void reduceCollectionToOne(Wt::Dbo::collectionWt::Dbo::ptr
const Wt::Dbo::ptr& one)
{
colleciton.clear();
collection.insert(one)
}
The following code works.
template
void reduceCollectionToOne(Wt::Dbo::collectionWt::Dbo::ptr
const Wt::Dbo::ptr& one)
for (const Wt::Dbo::ptr& element : collection) {
if (element != one) {
collection.erase(element);
}
}
}
Updated by Tomaz Canabrava about 2 years ago
The following code crashes deep into Wt.
Wt version 4.6.0
template <class TYPE>
void reduceCollectionToOne(Wt::Dbo::collection<Wt::Dbo::ptr<TYPE>>& collection,
const Wt::Dbo::ptr<TYPE>& one)
{
collection.clear();
collection.insert(one);
}
Updated by Korneel Dumon about 2 years ago
I tried your function using the feature/dbo/tutorial2
example and it worked. I don't know what's going wrong for you, but you could check if the ptr
argument is added to the session and if there is an active transaction.