Guard Qt6-only deprecation replacements for Qt5 compatibility

Three deprecated APIs have replacements that only exist in newer Qt6:
- QLocale::nativeCountryName() -> nativeTerritoryName() (Qt 6.2)
- QDomDocument::setContent() overload -> ParseResult (Qt 6.5)
- qt_ntfs_permission_lookup -> QNtfsPermissionCheckGuard RAII (Qt 6.6)
Each is wrapped in QT_VERSION_CHECK so Qt5 keeps the old path. Clears
4 -Wdeprecated-declarations warnings.
This commit is contained in:
Dieter Mayer
2026-07-12 21:54:14 +02:00
parent f57c921b78
commit e099fca5ad
3 changed files with 19 additions and 0 deletions
@@ -143,8 +143,12 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL
//On windows when user drag and drop an element from the common elements collection
//to the custom elements collection, the element file stay in read only mode, and so
//user can't save the element
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
QNtfsPermissionCheckGuard ntfs_guard;
#else
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
qt_ntfs_permission_lookup++;
#endif
QFile file(destination.fileSystemPath() % "/" % new_elmt_name);
if (!file.isWritable()) {
if (!file.setPermissions(file.permissions() | QFileDevice::WriteUser)) {
@@ -152,7 +156,9 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL
<< " in ECHSFileToFile::copyElement";
}
}
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
qt_ntfs_permission_lookup--;
#endif
#endif
return ElementsLocation (destination.fileSystemPath() % "/" % new_elmt_name);
}
+9
View File
@@ -422,6 +422,14 @@ int checkOneElement(const QString &path)
return 2;
}
QDomDocument doc;
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
if (const auto result = doc.setContent(&file); !result) {
file.close();
out << "FAIL " << path << " (XML error line "
<< result.errorLine << ": " << result.errorMessage << ")\n";
return 2;
}
#else
QString error;
int line = 0;
if (!doc.setContent(&file, &error, &line)) {
@@ -430,6 +438,7 @@ int checkOneElement(const QString &path)
<< line << ": " << error << ")\n";
return 2;
}
#endif
file.close();
const QDomElement root = doc.documentElement();
+4
View File
@@ -150,7 +150,11 @@ void MachineInfo::send_info_to_debug()
qInfo()<< "";
qInfo()<< " OS System language:"<< QLocale::system().name();
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
qInfo()<< " OS System Native Country Name:"<< QLocale::system().nativeTerritoryName();
#else
qInfo()<< " OS System Native Country Name:"<< QLocale::system().nativeCountryName();
#endif
qInfo()<< " OS System Native Language Name:"<< QLocale::system().nativeLanguageName();
qInfo()<< "";
qInfo()<< " System language defined in QET configuration:"<< QString(QETApp::langFromSetting().toLatin1());