Skip to content

Commit

Permalink
Avoid startup error when project template folder does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 18, 2017
1 parent c80e5d1 commit 1eb836c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );
Expand Down

0 comments on commit 1eb836c

Please sign in to comment.