Skip to content

BUG: Preventing Unwanted Subphrase Generation

These changes prevent the qtDescriptivePhrase::index and qtDescriptivePhrase::rowCount functions from causing the underlying phrase model to generate subphrases while QSortFilterProxyModel reads its source model.

The changes include:

  1. qtDescriptivePhrase will check if DescriptivePhrase::areSubphrasesBuilt returns true before calling DescriptivePhrase::subphrases in functions declared const. Calling the DescriptivePhrase::subphrases without this check caused new subphrases to be built during the call to qtDescriptivePhrase::rowCount while QSortFilterProxyModel was creating mappings to its source model. QSortFilterProxyModel expects its source model to effectively be read-only during this process. In fact, the act of generating new data during QAbstractItemModel::index or QAbstractItemModel::rowCount violates the const-ness of those functions.

  2. With the previously described check in place, we observed that ComponentPhraseModel would not insert any subphrases that are supposed to be under phrases on the root. As a result, the SubphraseGenerator::subphrasesForCreatedObjects method was modified to generate the subphrases, if they are not currently built, before proceeding. Not not sure if this was the best place to do this, but it did in fact populate the phrases on the root level as was expected originally.

Merge request reports

Loading