Skip to content
Permalink
Browse files

Avoid startup error when project template folder does not exist

  • Loading branch information
nyalldawson committed Jan 18, 2017
1 parent c80e5d1 commit 1eb836c6e8720b9d704bf6cb6595f1ea86395f27
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/app/qgisapp.cpp
@@ -778,11 +778,20 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
functionProfile( &QgisApp::legendLayerSelectionChanged, this, QStringLiteral( "Legend layer selection changed" ) );
mSaveRollbackInProgress = false;

QFileSystemWatcher* projectsTemplateWatcher = new QFileSystemWatcher( this );
QString templateDirName = settings.value( QStringLiteral( "/qgis/projectTemplateDir" ),
QgsApplication::qgisSettingsDirPath() + "project_templates" ).toString();
projectsTemplateWatcher->addPath( templateDirName );
connect( projectsTemplateWatcher, SIGNAL( directoryChanged( QString ) ), this, SLOT( updateProjectFromTemplates() ) );
if ( !QFileInfo::exists( templateDirName ) )
{
// create default template directory
if ( !QDir().mkdir( QgsApplication::qgisSettingsDirPath() + "project_templates" ) )
templateDirName.clear();
}
if ( !templateDirName.isEmpty() ) // template directory exists, so watch it!
{
QFileSystemWatcher* projectsTemplateWatcher = new QFileSystemWatcher( this );
projectsTemplateWatcher->addPath( templateDirName );
connect( projectsTemplateWatcher, &QFileSystemWatcher::directoryChanged, this, [this] { updateProjectFromTemplates(); } );
}

// initialize the plugin manager
startProfile( QStringLiteral( "Plugin manager" ) );

0 comments on commit 1eb836c

Please sign in to comment.
You can’t perform that action at this time.