Commit d062760c authored by Mathias Wein's avatar Mathias Wein

Prevent infinite recursion with Qt >5.15.2

The fix for QTBUG-87781 is to recreate an internal mapping in
QSortFilterProxyModel::setSourceModel(), and KisResourceModel calls
this in the constructor.
This leads to KisResourceModel::filterAcceptsRow() being called, which
ultimately fetches data via KisResourceQueryMapper::variantFromResourceQuery().
So the latter must not create a temporary KisResourceModel when processing the
data role used by filterAcceptsRow().

So only create the temporary model when actually required.
parent 49d58adc
......@@ -20,7 +20,6 @@
QVariant KisResourceQueryMapper::variantFromResourceQuery(const QSqlQuery &query, int column, int role)
const QString resourceType = query.value("resource_type").toString();
KisResourceModel resourceModel(resourceType);
switch(role) {
case Qt::DisplayRole:
......@@ -107,6 +106,7 @@ QVariant KisResourceQueryMapper::variantFromResourceQuery(const QSqlQuery &query
return query.value("resource_type");
case Qt::UserRole + KisAbstractResourceModel::Tags:
KisResourceModel resourceModel(resourceType);
QStringList tagNames;
Q_FOREACH(const KisTagSP tag, resourceModel.tagsForResource(query.value("id").toInt())) {
tagNames << tag->name();
......@@ -124,6 +124,7 @@ QVariant KisResourceQueryMapper::variantFromResourceQuery(const QSqlQuery &query
else {
// Now we have to check the resource, but that's cheap since it's been loaded in any case
KisResourceModel resourceModel(resourceType);
KoResourceSP resource = resourceModel.resourceForId(query.value("id").toInt());
return resource->isDirty();
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