Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 1d118e9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -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" ) );
Expand Down

0 comments on commit 1d118e9

Please sign in to comment.