modellist: work around filtered item models getting out of sync #2545
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have yet to understand exactly why, but since #2086 the "Clone" button on the models page sometimes results in the entire settings page being replaced with blank values instead of a cloned model.
I now know that when the "Clone" button is clicked, the id returned fromModelList::clone is not found in the combo box for selection, which leads to index=-1 -> selected value=undefined -> default-constructed
ModelInfo()
when values are accessed.This stems from the fact that m_selectableModels doesn't contain the newly added model by the end of ModelList::clone. For whatever reason, the initial ModelList::addModel call does fire an InstalledModels::filterAcceptsRow check on the cloned model, but the ModelList::updateModel call to set its data (which does call ModelList::dataChanged) does not. So m_selectableModels incorrectly thinks the cloned model is not yet "installed."
This PR works around that by explicitly invalidating all of the filter models at the end of ModelList::updateData. In the future, we should figure out why the dataChanged signal does not result in the expected update of the child models.
Summary:
Fixes issue with 'Clone' button resulting in blank values by invalidating filter models in
ModelList::updateData
.Key points:
m_selectableModels
does not contain the newly added model by the end ofModelList::clone
.m_selectableModels
,m_installedModels
,m_downloadableModels
) at the end ofModelList::updateData
.gpt4all-chat/modellist.cpp
.ModelList::updateData
.Generated with ❤️ by ellipsis.dev