TextEditor: prevent crash on updating the completion model

Prevent updating the model with something other than a generic proposal
model.

Change-Id: I3880c1ce4ae7cf0aa4fb72d59b75a40db3f53482
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-01-16 12:49:58 +01:00
parent d9de9db6f8
commit 41294e70b4
3 changed files with 9 additions and 4 deletions

View File

@@ -289,7 +289,12 @@ public:
{
if (!proposal)
return;
updateModel(proposal->model(), prefix);
if (proposal->id() != TextEditor::Constants::GENERIC_PROPOSAL_ID) {
// We received something else than a generic proposal so we cannot update the model
closeProposal();
return;
}
updateModel(proposal->model().staticCast<GenericProposalModel>(), prefix);
delete proposal;
}