mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
Don't try to load plugins which aren't compatible with qt 6
Add a plugin metadata key for "supports_qt6". Plugins which can safely be loaded in QGIS builds based on Qt6 can set supportsQt6=yes in their metadata.txt to advertise that they are safe to load on Qt 6 builds
This commit is contained in:
parent
81a45d4570
commit
e90cb8c42d
@ -30,7 +30,7 @@ from typing import (
|
||||
|
||||
from qgis.PyQt.QtCore import (pyqtSignal, QObject, QCoreApplication, QFile,
|
||||
QDir, QDirIterator, QDate, QUrl, QFileInfo,
|
||||
QLocale, QByteArray)
|
||||
QLocale, QByteArray, QT_VERSION_STR)
|
||||
from qgis.PyQt.QtXml import QDomDocument
|
||||
from qgis.PyQt.QtNetwork import QNetworkRequest, QNetworkReply
|
||||
from qgis.core import Qgis, QgsSettings, QgsSettingsTree, QgsNetworkRequestParameters
|
||||
@ -438,9 +438,11 @@ class Repositories(QObject):
|
||||
qgisMaximumVersion = pluginNodes.item(i).firstChildElement("qgis_maximum_version").text().strip()
|
||||
if not qgisMaximumVersion:
|
||||
qgisMaximumVersion = qgisMinimumVersion[0] + ".99"
|
||||
supports_qt6 = pluginNodes.item(i).firstChildElement("supports_qt6").text().strip().upper() in ("TRUE", "YES")
|
||||
qt_version = int(QT_VERSION_STR.split('.')[0])
|
||||
# if compatible, add the plugin to the list
|
||||
if not pluginNodes.item(i).firstChildElement("disabled").text().strip().upper() in ["TRUE", "YES"]:
|
||||
if isCompatible(pyQgisVersion(), qgisMinimumVersion, qgisMaximumVersion):
|
||||
if isCompatible(pyQgisVersion(), qgisMinimumVersion, qgisMaximumVersion) and (qt_version != 6 or supports_qt6):
|
||||
# add the plugin to the cache
|
||||
plugins.addFromRepository(plugin)
|
||||
self.mRepositories[reposName]["state"] = Repositories.STATE_LOADED
|
||||
@ -585,7 +587,12 @@ class Plugins(QObject):
|
||||
if os.path.exists(metadataFile):
|
||||
version = normalizeVersion(pluginMetadata("version"))
|
||||
|
||||
if version:
|
||||
qt_version = int(QT_VERSION_STR.split('.')[0])
|
||||
supports_qt6 = pluginMetadata("supportsQt6").strip().upper() in ("TRUE", "YES")
|
||||
if qt_version == 6 and not supports_qt6:
|
||||
error = "incompatible"
|
||||
errorDetails = QCoreApplication.translate("QgsPluginInstaller", "Plugin does not support Qt6 versions of QGIS")
|
||||
elif version:
|
||||
qgisMinimumVersion = pluginMetadata("qgisMinimumVersion").strip()
|
||||
if not qgisMinimumVersion:
|
||||
qgisMinimumVersion = "0"
|
||||
|
@ -721,6 +721,13 @@ bool QgsPluginRegistry::checkPythonPlugin( const QString &packageName )
|
||||
bool QgsPluginRegistry::isPythonPluginCompatible( const QString &packageName ) const
|
||||
{
|
||||
#ifdef WITH_BINDINGS
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
const QString supportsQt6 = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "supportsQt6" ) ).trimmed();
|
||||
if ( supportsQt6.compare( QLatin1String( "YES" ), Qt::CaseInsensitive ) != 0 && supportsQt6.compare( QLatin1String( "TRUE" ), Qt::CaseInsensitive ) != 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
const QString minVersion = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "qgisMinimumVersion" ) );
|
||||
// try to read qgisMaximumVersion. Note checkQgisVersion can cope with "__error__" value.
|
||||
const QString maxVersion = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "qgisMaximumVersion" ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user