[QGIS Commit] r13076 - in trunk/qgis: . src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Mar 19 07:41:18 EDT 2010


Author: wonder
Date: 2010-03-19 07:41:12 -0400 (Fri, 19 Mar 2010)
New Revision: 13076

Modified:
   trunk/qgis/qgis.1
   trunk/qgis/src/app/main.cpp
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgisapp.h
Log:
[FEATURE] Added --noplugins command line options to avoid restoring the plugins. Useful when a plugin misbehaves and causes QGIS to crash during startup.


Modified: trunk/qgis/qgis.1
===================================================================
--- trunk/qgis/qgis.1	2010-03-19 09:32:34 UTC (rev 13075)
+++ trunk/qgis/qgis.1	2010-03-19 11:41:12 UTC (rev 13076)
@@ -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
@@ -14,6 +14,8 @@
 .B "     [--extent"
 .I xmin,ymin,xmax,ymax]
 .br
+.B "     [--noplugins]"
+.br
 .B "     [--help]"
 .br
 .B "     [file]..."
@@ -65,7 +67,11 @@
 .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

Modified: trunk/qgis/src/app/main.cpp
===================================================================
--- trunk/qgis/src/app/main.cpp	2010-03-19 09:32:34 UTC (rev 13075)
+++ trunk/qgis/src/app/main.cpp	2010-03-19 11:41:12 UTC (rev 13076)
@@ -92,6 +92,7 @@
             << "\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"
@@ -267,6 +268,7 @@
   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
@@ -296,6 +298,7 @@
         /* 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'},
@@ -354,6 +357,10 @@
           myProjectFileName = QDir::convertSeparators( QFileInfo( QFile::decodeName( optarg ) ).absoluteFilePath() );
           break;
 
+        case 'P':
+          myRestorePlugins = false;
+          break;
+
         case 'e':
           myInitialExtent = optarg;
           break;
@@ -402,6 +409,10 @@
     {
       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() );
@@ -615,7 +626,7 @@
   }
 #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" );
 
   /////////////////////////////////////////////////////////////////////

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-03-19 09:32:34 UTC (rev 13075)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-03-19 11:41:12 UTC (rev 13076)
@@ -327,7 +327,7 @@
 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 )
@@ -425,7 +425,12 @@
   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();

Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h	2010-03-19 09:32:34 UTC (rev 13075)
+++ trunk/qgis/src/app/qgisapp.h	2010-03-19 11:41:12 UTC (rev 13076)
@@ -81,7 +81,7 @@
     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();
     /**



More information about the QGIS-commit mailing list