Skip to content

Commit 22962ed

Browse files
author
wonder
committed
[FEATURE] Added --noplugins command line options to avoid restoring the plugins. Useful when a plugin misbehaves and causes QGIS to crash during startup.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13076 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 178abd5 commit 22962ed

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

qgis.1

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH QGIS 1 "April 13, 2008"
1+
.TH QGIS 1 "March 19, 2010"
22
.SH NAME
33
qgis \- Quantum GIS Geographic Information System
44
.SH SYNOPSIS
@@ -14,6 +14,8 @@ qgis \- Quantum GIS Geographic Information System
1414
.B " [--extent"
1515
.I xmin,ymin,xmax,ymax]
1616
.br
17+
.B " [--noplugins]"
18+
.br
1719
.B " [--help]"
1820
.br
1921
.B " [file]..."
@@ -65,7 +67,11 @@ are symbolized, and the view extent is restored.
6567
.B \--extent xmin,ymin,xmax,ymax
6668
Set initial map extent by passing coordinates of that rectangle.
6769
.TP
68-
.B \--help
70+
.B \--noplugins
71+
.br
72+
Don't restore plugins on startup. Useful if some third-party plugins make QGIS crash during startup.
73+
.TP
74+
.B \--help
6975
.br
7076
Display brief usage help.
7177
.TP

src/app/main.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ void usage( std::string const & appName )
9292
<< "\t[--project projectfile]\tload the given QGIS project\n"
9393
<< "\t[--extent xmin,ymin,xmax,ymax]\tset initial map extent\n"
9494
<< "\t[--nologo]\thide splash screen\n"
95+
<< "\t[--noplugins]\tdon't restore plugins on startup\n"
9596
<< "\t[--optionspath path]\tuse the given QSettings path\n"
9697
<< "\t[--help]\t\tthis text\n\n"
9798
<< " FILES:\n"
@@ -267,6 +268,7 @@ int main( int argc, char *argv[] )
267268
int mySnapshotHeight = 600;
268269

269270
bool myHideSplash = false;
271+
bool myRestorePlugins = true;
270272

271273
// This behaviour will set initial extent of map canvas, but only if
272274
// there are no command line arguments. This gives a usable map
@@ -296,6 +298,7 @@ int main( int argc, char *argv[] )
296298
/* These options set a flag. */
297299
{"help", no_argument, 0, '?'},
298300
{"nologo", no_argument, 0, 'n'},
301+
{"noplugins", no_argument, 0, 'P'},
299302
/* These options don't set a flag.
300303
* We distinguish them by their indices. */
301304
{"snapshot", required_argument, 0, 's'},
@@ -354,6 +357,10 @@ int main( int argc, char *argv[] )
354357
myProjectFileName = QDir::convertSeparators( QFileInfo( QFile::decodeName( optarg ) ).absoluteFilePath() );
355358
break;
356359

360+
case 'P':
361+
myRestorePlugins = false;
362+
break;
363+
357364
case 'e':
358365
myInitialExtent = optarg;
359366
break;
@@ -402,6 +409,10 @@ int main( int argc, char *argv[] )
402409
{
403410
myHideSplash = true;
404411
}
412+
else if ( arg == "--noplugins" || arg == "-P" )
413+
{
414+
myRestorePlugins = false;
415+
}
405416
else if ( i + 1 < argc && ( arg == "--snapshot" || arg == "-s" ) )
406417
{
407418
mySnapshotFileName = QDir::convertSeparators( QFileInfo( QFile::decodeName( argv[++i] ) ).absoluteFilePath() );
@@ -615,7 +626,7 @@ int main( int argc, char *argv[] )
615626
}
616627
#endif
617628

618-
QgisApp *qgis = new QgisApp( mypSplash ); // "QgisApp" used to find canonical instance
629+
QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins ); // "QgisApp" used to find canonical instance
619630
qgis->setObjectName( "QgisApp" );
620631

621632
/////////////////////////////////////////////////////////////////////

src/app/qgisapp.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void customSrsValidation_( QgsCoordinateReferenceSystem* srs )
327327
QgisApp *QgisApp::smInstance = 0;
328328

329329
// constructor starts here
330-
QgisApp::QgisApp( QSplashScreen *splash, QWidget * parent, Qt::WFlags fl )
330+
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent, Qt::WFlags fl )
331331
: QMainWindow( parent, fl ),
332332
mSplash( splash ),
333333
mPythonUtils( NULL )
@@ -425,7 +425,12 @@ QgisApp::QgisApp( QSplashScreen *splash, QWidget * parent, Qt::WFlags fl )
425425
mSplash->showMessage( tr( "Restoring loaded plugins" ), Qt::AlignHCenter | Qt::AlignBottom );
426426
qApp->processEvents();
427427
QgsPluginRegistry::instance()->setQgisInterface( mQgisInterface );
428-
QgsPluginRegistry::instance()->restoreSessionPlugins( QgsApplication::pluginPath() );
428+
if ( restorePlugins )
429+
{
430+
// Restoring of plugins can be disabled with --noplugins command line option
431+
// because some plugins may cause QGIS to crash during startup
432+
QgsPluginRegistry::instance()->restoreSessionPlugins( QgsApplication::pluginPath() );
433+
}
429434

430435
mSplash->showMessage( tr( "Initializing file filters" ), Qt::AlignHCenter | Qt::AlignBottom );
431436
qApp->processEvents();

src/app/qgisapp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class QgisApp : public QMainWindow
8181
Q_OBJECT
8282
public:
8383
//! Constructor
84-
QgisApp( QSplashScreen *splash, QWidget * parent = 0, Qt::WFlags fl = Qt::Window );
84+
QgisApp( QSplashScreen *splash, bool restorePlugins = true, QWidget * parent = 0, Qt::WFlags fl = Qt::Window );
8585
//! Destructor
8686
~QgisApp();
8787
/**

0 commit comments

Comments
 (0)