spellcheckdictionarylistmodel: remove invalid lambda capture

The handleDownloadComplete lambda in onDownloadFileFinished captured was
declared static, which can lead to the captured 'locale' variable not
containing the expected value.

Change-Id: I9d44ad4e8bffc7a7f68f44e87d35af650498a3fd
This commit is contained in:
François-Simon Fauteux-Chapleau
2025-11-24 14:42:30 -05:00
parent e2557293dd
commit 89346c5401

View File

@@ -400,7 +400,32 @@ SpellCheckDictionaryListModel::onDownloadFileFinished(const QString& localPath)
QFileInfo fileInfo(localPath);
QString locale = fileInfo.baseName();
static auto handleDownloadComplete = [this, &locale](const QString& localPath) {
// We need both a .dic file and a .aff file.
// Check which one we downloaded and whether we already have the other one.
bool haveBothFiles = false;
if (localPath.endsWith(".dic")) {
QString affFilePath = localPath;
affFilePath.chop(4); // Remove ".dic"
affFilePath += ".aff";
if (QFile::exists(affFilePath)) {
haveBothFiles = true;
} else {
C_DBG << "Waiting for .aff file for:" << locale;
}
} else if (localPath.endsWith(".aff")) {
QString dicFilePath = localPath;
dicFilePath.chop(4); // Remove ".aff"
dicFilePath += ".dic";
if (QFile::exists(dicFilePath)) {
haveBothFiles = true;
} else {
C_DBG << "Waiting for .dic file for:" << locale;
}
}
if (haveBothFiles) {
// Both files are now available, mark as installed
updateDictionaryInstallationStatus(locale, true);
pendingDownloads_.removeAll(locale);
@@ -414,29 +439,6 @@ SpellCheckDictionaryListModel::onDownloadFileFinished(const QString& localPath)
if (!dictionariesAvailable_) {
dictionariesAvailable_ = true;
}
};
// Check if this is a .dic file and if the corresponding .aff file exists
if (localPath.endsWith(".dic")) {
QString affFilePath = localPath;
affFilePath.chop(4); // Remove ".dic"
affFilePath += ".aff";
if (QFile::exists(affFilePath)) {
handleDownloadComplete(affFilePath);
} else {
C_DBG << "Waiting for .aff file for:" << locale;
}
} else if (localPath.endsWith(".aff")) {
QString dicFilePath = localPath;
dicFilePath.chop(4); // Remove ".aff"
dicFilePath += ".dic";
if (QFile::exists(dicFilePath)) {
handleDownloadComplete(dicFilePath);
} else {
C_DBG << "Waiting for .dic file for:" << locale;
}
}
}