Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable Python at startup #60462

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void usage( const QString &appName )
<< QStringLiteral( "\t[-n, --nologo]\thide splash screen\n" )
<< QStringLiteral( "\t[-V, --noversioncheck]\tdon't check for new version of QGIS at startup\n" )
<< QStringLiteral( "\t[-P, --noplugins]\tdon't restore plugins on startup\n" )
<< QStringLiteral( "\t[--nopython]\tdisable python support\n" )
lbartoletti marked this conversation as resolved.
Show resolved Hide resolved
<< QStringLiteral( "\t[-B, --skipbadlayers]\tdon't prompt for missing layers\n" )
<< QStringLiteral( "\t[-C, --nocustomization]\tdon't apply GUI customization\n" )
<< QStringLiteral( "\t[-z, --customizationfile path]\tuse the given ini file as GUI customization\n" )
Expand Down Expand Up @@ -579,6 +580,7 @@ int main( int argc, char *argv[] )

bool myRestoreDefaultWindowState = false;
bool myRestorePlugins = true;
bool myPython = true;
lbartoletti marked this conversation as resolved.
Show resolved Hide resolved
bool mySkipBadLayers = false;
bool myCustomization = true;

Expand Down Expand Up @@ -669,6 +671,10 @@ int main( int argc, char *argv[] )
{
myRestorePlugins = false;
}
else if ( arg == QLatin1String( "--nopython" ) )
{
myPython = false;
}
else if ( arg == QLatin1String( "--skipbadlayers" ) || arg == QLatin1String( "-B" ) )
{
QgsDebugMsgLevel( QStringLiteral( "Skipping bad layers" ), 2 );
Expand Down Expand Up @@ -1540,7 +1546,7 @@ int main( int argc, char *argv[] )
// this should be done in QgsApplication::init() but it doesn't know the settings dir.
QgsApplication::setMaxThreads( settings.value( QStringLiteral( "qgis/max_threads" ), -1 ).toInt() );

QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins, mySkipBadLayers, mySkipVersionCheck, rootProfileFolder, profileName ); // "QgisApp" used to find canonical instance
QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins, mySkipBadLayers, mySkipVersionCheck, rootProfileFolder, profileName, myPython ); // "QgisApp" used to find canonical instance
qgis->setObjectName( QStringLiteral( "QgisApp" ) );

QgsApplication::connect(
Expand Down
15 changes: 9 additions & 6 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ static bool cmpByText_( QAction *a, QAction *b )
QgisApp *QgisApp::sInstance = nullptr;

// constructor starts here
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers, bool skipVersionCheck, const QString &rootProfileLocation, const QString &activeProfile, QWidget *parent, Qt::WindowFlags fl )
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers, bool skipVersionCheck, const QString &rootProfileLocation, const QString &activeProfile, bool enablePython, QWidget *parent, Qt::WindowFlags fl )
: QMainWindow( parent, fl )
, mSplash( splash )
{
Expand Down Expand Up @@ -1633,14 +1633,17 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers
QgsProject::instance()->setBadLayerHandler( mAppBadLayersHandler );
}

mSplash->showMessage( tr( "Starting Python" ), Qt::AlignHCenter | Qt::AlignBottom, splashTextColor );
qApp->processEvents();
loadPythonSupport();
if ( enablePython )
{
mSplash->showMessage( tr( "Starting Python" ), Qt::AlignHCenter | Qt::AlignBottom, splashTextColor );
qApp->processEvents();
loadPythonSupport();

#ifdef WITH_BINDINGS
QgsApplication::dataItemProviderRegistry()->addProvider( new QgsPyDataItemProvider() );
registerCustomDropHandler( new QgsPyDropHandler() );
QgsApplication::dataItemProviderRegistry()->addProvider( new QgsPyDataItemProvider() );
registerCustomDropHandler( new QgsPyDropHandler() );
#endif
}

QgsApplication::dataItemProviderRegistry()->addProvider( new QgsProjectDataItemProvider() );
QgsApplication::dataItemProviderRegistry()->addProvider( new QgsStacDataItemProvider() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
Q_OBJECT
public:
//! Constructor
QgisApp( QSplashScreen *splash, bool restorePlugins = true, bool skipBadLayers = false, bool skipVersionCheck = false, const QString &rootProfileLocation = QString(), const QString &activeProfile = QString(), QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window );
QgisApp( QSplashScreen *splash, bool restorePlugins = true, bool skipBadLayers = false, bool skipVersionCheck = false, const QString &rootProfileLocation = QString(), const QString &activeProfile = QString(), bool enablePython = true, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window );
lbartoletti marked this conversation as resolved.
Show resolved Hide resolved
//! Constructor for unit tests
QgisApp();

Expand Down
Loading