Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] Added --noplugins command line options to avoid restoring t…
…he 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
  • Loading branch information
wonder committed Mar 19, 2010
1 parent 178abd5 commit 22962ed
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
10 changes: 8 additions & 2 deletions qgis.1
@@ -1,4 +1,4 @@
.TH QGIS 1 "April 13, 2008"
.TH QGIS 1 "March 19, 2010"
.SH NAME
qgis \- Quantum GIS Geographic Information System
.SH SYNOPSIS
Expand All @@ -14,6 +14,8 @@ qgis \- Quantum GIS Geographic Information System
.B " [--extent"
.I xmin,ymin,xmax,ymax]
.br
.B " [--noplugins]"
.br
.B " [--help]"
.br
.B " [file]..."
Expand Down Expand Up @@ -65,7 +67,11 @@ are symbolized, and the view extent is restored.
.B \--extent xmin,ymin,xmax,ymax
Set initial map extent by passing coordinates of that rectangle.
.TP
.B \--help
.B \--noplugins
.br
Don't restore plugins on startup. Useful if some third-party plugins make QGIS crash during startup.
.TP
.B \--help
.br
Display brief usage help.
.TP
Expand Down
13 changes: 12 additions & 1 deletion src/app/main.cpp
Expand Up @@ -92,6 +92,7 @@ void usage( std::string const & appName )
<< "\t[--project projectfile]\tload the given QGIS project\n"
<< "\t[--extent xmin,ymin,xmax,ymax]\tset initial map extent\n"
<< "\t[--nologo]\thide splash screen\n"
<< "\t[--noplugins]\tdon't restore plugins on startup\n"
<< "\t[--optionspath path]\tuse the given QSettings path\n"
<< "\t[--help]\t\tthis text\n\n"
<< " FILES:\n"
Expand Down Expand Up @@ -267,6 +268,7 @@ int main( int argc, char *argv[] )
int mySnapshotHeight = 600;

bool myHideSplash = false;
bool myRestorePlugins = true;

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

case 'P':
myRestorePlugins = false;
break;

case 'e':
myInitialExtent = optarg;
break;
Expand Down Expand Up @@ -402,6 +409,10 @@ int main( int argc, char *argv[] )
{
myHideSplash = true;
}
else if ( arg == "--noplugins" || arg == "-P" )
{
myRestorePlugins = false;
}
else if ( i + 1 < argc && ( arg == "--snapshot" || arg == "-s" ) )
{
mySnapshotFileName = QDir::convertSeparators( QFileInfo( QFile::decodeName( argv[++i] ) ).absoluteFilePath() );
Expand Down Expand Up @@ -615,7 +626,7 @@ int main( int argc, char *argv[] )
}
#endif

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

/////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 7 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -327,7 +327,7 @@ static void customSrsValidation_( QgsCoordinateReferenceSystem* srs )
QgisApp *QgisApp::smInstance = 0;

// constructor starts here
QgisApp::QgisApp( QSplashScreen *splash, QWidget * parent, Qt::WFlags fl )
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent, Qt::WFlags fl )
: QMainWindow( parent, fl ),
mSplash( splash ),
mPythonUtils( NULL )
Expand Down Expand Up @@ -425,7 +425,12 @@ QgisApp::QgisApp( QSplashScreen *splash, QWidget * parent, Qt::WFlags fl )
mSplash->showMessage( tr( "Restoring loaded plugins" ), Qt::AlignHCenter | Qt::AlignBottom );
qApp->processEvents();
QgsPluginRegistry::instance()->setQgisInterface( mQgisInterface );
QgsPluginRegistry::instance()->restoreSessionPlugins( QgsApplication::pluginPath() );
if ( restorePlugins )
{
// Restoring of plugins can be disabled with --noplugins command line option
// because some plugins may cause QGIS to crash during startup
QgsPluginRegistry::instance()->restoreSessionPlugins( QgsApplication::pluginPath() );
}

mSplash->showMessage( tr( "Initializing file filters" ), Qt::AlignHCenter | Qt::AlignBottom );
qApp->processEvents();
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.h
Expand Up @@ -81,7 +81,7 @@ class QgisApp : public QMainWindow
Q_OBJECT
public:
//! Constructor
QgisApp( QSplashScreen *splash, QWidget * parent = 0, Qt::WFlags fl = Qt::Window );
QgisApp( QSplashScreen *splash, bool restorePlugins = true, QWidget * parent = 0, Qt::WFlags fl = Qt::Window );
//! Destructor
~QgisApp();
/**
Expand Down

0 comments on commit 22962ed

Please sign in to comment.