mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Add QgsPythonUtilsImpl::initGDAL() and run it from QGIS app
fixes #57344
This commit is contained in:
parent
07067d37b5
commit
79dab4461e
@ -12523,6 +12523,7 @@ void QgisApp::loadPythonSupport()
|
||||
// init python runner
|
||||
QgsPythonRunner::setInstance( new QgsPythonRunnerImpl( mPythonUtils ) );
|
||||
|
||||
mPythonUtils->initGDAL();
|
||||
// QgsMessageLog::logMessage( tr( "Python support ENABLED :-) " ), QString(), Qgis::MessageLevel::Info );
|
||||
}
|
||||
#endif
|
||||
|
@ -218,6 +218,11 @@ class PYTHON_EXPORT QgsPythonUtils
|
||||
*/
|
||||
virtual bool unloadPlugin( const QString &packageName ) = 0;
|
||||
|
||||
/**
|
||||
* Initialize GDAL Python, turning on its exceptions.
|
||||
* \since QGIS 3.38
|
||||
*/
|
||||
virtual void initGDAL() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -755,3 +755,12 @@ QStringList QgsPythonUtilsImpl::listActivePlugins()
|
||||
evalString( QStringLiteral( "'\\n'.join(qgis.utils.active_plugins)" ), output );
|
||||
return output.split( QChar( '\n' ), Qt::SkipEmptyParts );
|
||||
}
|
||||
|
||||
void QgsPythonUtilsImpl::initGDAL()
|
||||
{
|
||||
runString("from osgeo import gdal, ogr, osr");
|
||||
// To avoid FutureWarning with GDAL >= 3.7.0
|
||||
runString("gdal.UseExceptions()");
|
||||
runString("ogr.UseExceptions()");
|
||||
runString("osr.UseExceptions()");
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ class QgsPythonUtilsImpl : public QgsPythonUtils
|
||||
bool canUninstallPlugin( const QString &packageName ) final;
|
||||
bool unloadPlugin( const QString &packageName ) final;
|
||||
bool isPluginEnabled( const QString &packageName ) const final;
|
||||
void initGDAL() final;
|
||||
|
||||
protected:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user