Skip to content
Permalink
Browse files

Merge pull request #4016 from nyalldawson/template_error

Avoid startup error when project template folder does not exist
  • Loading branch information
nyalldawson committed Feb 2, 2017
2 parents fbcf624 + 1eb836c commit 1d118e9671634bbd7e2bd2b694783914d4bec203
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/app/qgisapp.cpp
@@ -786,11 +786,20 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh

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 1d118e9

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