36 QgsConfigCache::QgsConfigCache()
 
   38   QObject::connect( &mFileSystemWatcher, &QFileSystemWatcher::fileChanged, 
this, &QgsConfigCache::removeChangedEntry );
 
   44   if ( ! mProjectCache[ path ] )
 
   46     std::unique_ptr<QgsProject> prj( 
new QgsProject() );
 
   49     prj->setBadLayerHandler( badLayerHandler );
 
   66     if ( prj->read( path, readFlags ) )
 
   68       if ( !badLayerHandler->
badLayers().isEmpty() )
 
   71         QStringList unrestrictedBadLayers;
 
   73         const QStringList badLayerIds = badLayerHandler->
badLayers();
 
   74         const QMap<QString, QString> badLayerNames = badLayerHandler->
badLayerNames();
 
   76         for ( 
const QString &badLayerId : badLayerIds )
 
   80           if ( badLayerNames.contains( badLayerId ) &&
 
   81                resctrictedLayers.contains( badLayerNames.value( badLayerId ) ) )
 
   85           unrestrictedBadLayers.append( badLayerId );
 
   87         if ( !unrestrictedBadLayers.isEmpty() )
 
   93               QStringLiteral( 
"Error, Layer(s) %1 not valid in project %2" ).arg( unrestrictedBadLayers.join( QLatin1String( 
", " ) ), path ),
 
  100               QStringLiteral( 
"Warning, Layer(s) %1 not valid in project %2" ).arg( unrestrictedBadLayers.join( QLatin1String( 
", " ) ), path ),
 
  105       mProjectCache.insert( path, prj.release() );
 
  106       mFileSystemWatcher.addPath( path );
 
  111         QStringLiteral( 
"Error when loading project file '%1': %2 " ).arg( path, prj->error() ),
 
  115   return mProjectCache[ path ];
 
  119 QDomDocument *QgsConfigCache::xmlDocument( 
const QString &filePath )
 
  122   QFile configFile( filePath );
 
  123   if ( !configFile.exists() )
 
  129   if ( !configFile.open( QIODevice::ReadOnly ) )
 
  136   QDomDocument *xmlDoc = mXmlDocumentCache.object( filePath );
 
  140     xmlDoc = 
new QDomDocument();
 
  143     if ( !xmlDoc->setContent( &configFile, 
true, &errorMsg, &line, &column ) )
 
  146                                  QStringLiteral( 
"': parse error %1 at row %2, column %3" ).arg( errorMsg ).arg( line ).arg( column ), QStringLiteral( 
"Server" ), 
Qgis::Critical );
 
  150     mXmlDocumentCache.insert( filePath, xmlDoc );
 
  151     mFileSystemWatcher.addPath( filePath );
 
  152     xmlDoc = mXmlDocumentCache.object( filePath );
 
  158 void QgsConfigCache::removeChangedEntry( 
const QString &path )
 
  160   mProjectCache.remove( path );
 
  163   mXmlDocumentCache.remove( path );
 
  165   mFileSystemWatcher.removePath( path );
 
  171   removeChangedEntry( path );