@@ -42,26 +42,24 @@ QgsConfigCache::~QgsConfigCache()
4242
4343QgsServerProjectParser* QgsConfigCache::serverConfiguration ( const QString& filePath )
4444{
45- QgsServerProjectParser* p = mServerConfigCache . object ( filePath );
46- if ( !p )
45+ QDomDocument* doc = xmlDocument ( filePath );
46+ if ( !doc )
4747 {
48- QDomDocument* doc = xmlDocument ( filePath );
49- if ( !doc )
50- {
51- return 0 ;
52- }
53- p = new QgsServerProjectParser ( doc, filePath );
54- mServerConfigCache .insert ( filePath, p );
55- mFileSystemWatcher .addPath ( filePath );
48+ return 0 ;
5649 }
57- return p ;
50+ return new QgsServerProjectParser ( doc, filePath ) ;
5851}
5952
6053QgsWCSProjectParser* QgsConfigCache::wcsConfiguration ( const QString& filePath )
6154{
6255 QgsWCSProjectParser* p = mWCSConfigCache .object ( filePath );
6356 if ( !p )
6457 {
58+ QDomDocument* doc = xmlDocument ( filePath );
59+ if ( !doc )
60+ {
61+ return 0 ;
62+ }
6563 p = new QgsWCSProjectParser ( filePath );
6664 mWCSConfigCache .insert ( filePath, p );
6765 mFileSystemWatcher .addPath ( filePath );
@@ -76,6 +74,11 @@ QgsWFSProjectParser* QgsConfigCache::wfsConfiguration( const QString& filePath )
7674 QgsWFSProjectParser* p = mWFSConfigCache .object ( filePath );
7775 if ( !p )
7876 {
77+ QDomDocument* doc = xmlDocument ( filePath );
78+ if ( !doc )
79+ {
80+ return 0 ;
81+ }
7982 p = new QgsWFSProjectParser ( filePath );
8083 mWFSConfigCache .insert ( filePath, p );
8184 mFileSystemWatcher .addPath ( filePath );
@@ -117,12 +120,6 @@ QgsWMSConfigParser* QgsConfigCache::wmsConfiguration( const QString& filePath, c
117120
118121QDomDocument* QgsConfigCache::xmlDocument ( const QString& filePath )
119122{
120- // first get cache
121- QDomDocument* xmlDoc = mXmlDocumentCache .object ( filePath );
122- if ( xmlDoc )
123- return xmlDoc;
124-
125- // i it's first access
126123 // first open file
127124 QFile configFile ( filePath );
128125 if ( !configFile.exists () )
@@ -136,26 +133,31 @@ QDomDocument* QgsConfigCache::xmlDocument( const QString& filePath )
136133 QgsMessageLog::logMessage ( " Error, cannot open configuration file '" + filePath + " '" , " Server" , QgsMessageLog::CRITICAL );
137134 return 0 ;
138135 }
139-
140- // then create xml document
141- xmlDoc = new QDomDocument ();
142- QString errorMsg;
143- int line, column;
144- if ( !xmlDoc->setContent ( &configFile, true , &errorMsg, &line, &column ) )
136+
137+ // first get cache
138+ QDomDocument* xmlDoc = mXmlDocumentCache .object ( filePath );
139+ if ( !xmlDoc )
145140 {
146- QgsMessageLog::logMessage ( " Error parsing file '" + filePath +
147- QString ( " ': parse error %1 at row %2, column %3" ).arg ( errorMsg ).arg ( line ).arg ( column ), " Server" , QgsMessageLog::CRITICAL );
148- delete xmlDoc;
149- return 0 ;
141+ // then create xml document
142+ xmlDoc = new QDomDocument ();
143+ QString errorMsg;
144+ int line, column;
145+ if ( !xmlDoc->setContent ( &configFile, true , &errorMsg, &line, &column ) )
146+ {
147+ QgsMessageLog::logMessage ( " Error parsing file '" + filePath +
148+ QString ( " ': parse error %1 at row %2, column %3" ).arg ( errorMsg ).arg ( line ).arg ( column ), " Server" , QgsMessageLog::CRITICAL );
149+ delete xmlDoc;
150+ return 0 ;
151+ }
152+ mXmlDocumentCache .insert ( filePath, xmlDoc );
153+ mFileSystemWatcher .addPath ( filePath );
150154 }
151- mXmlDocumentCache .insert ( filePath, xmlDoc );
152155 return xmlDoc;
153156}
154157
155158void QgsConfigCache::removeChangedEntry ( const QString& path )
156159{
157160 mXmlDocumentCache .remove ( path );
158- mServerConfigCache .remove ( path );
159161 mWMSConfigCache .remove ( path );
160162 mWFSConfigCache .remove ( path );
161163 mWCSConfigCache .remove ( path );
0 commit comments