@@ -42,26 +42,24 @@ QgsConfigCache::~QgsConfigCache()
42
42
43
43
QgsServerProjectParser* QgsConfigCache::serverConfiguration ( const QString& filePath )
44
44
{
45
- QgsServerProjectParser* p = mServerConfigCache . object ( filePath );
46
- if ( !p )
45
+ QDomDocument* doc = xmlDocument ( filePath );
46
+ if ( !doc )
47
47
{
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 ;
56
49
}
57
- return p ;
50
+ return new QgsServerProjectParser ( doc, filePath ) ;
58
51
}
59
52
60
53
QgsWCSProjectParser* QgsConfigCache::wcsConfiguration ( const QString& filePath )
61
54
{
62
55
QgsWCSProjectParser* p = mWCSConfigCache .object ( filePath );
63
56
if ( !p )
64
57
{
58
+ QDomDocument* doc = xmlDocument ( filePath );
59
+ if ( !doc )
60
+ {
61
+ return 0 ;
62
+ }
65
63
p = new QgsWCSProjectParser ( filePath );
66
64
mWCSConfigCache .insert ( filePath, p );
67
65
mFileSystemWatcher .addPath ( filePath );
@@ -76,6 +74,11 @@ QgsWFSProjectParser* QgsConfigCache::wfsConfiguration( const QString& filePath )
76
74
QgsWFSProjectParser* p = mWFSConfigCache .object ( filePath );
77
75
if ( !p )
78
76
{
77
+ QDomDocument* doc = xmlDocument ( filePath );
78
+ if ( !doc )
79
+ {
80
+ return 0 ;
81
+ }
79
82
p = new QgsWFSProjectParser ( filePath );
80
83
mWFSConfigCache .insert ( filePath, p );
81
84
mFileSystemWatcher .addPath ( filePath );
@@ -117,12 +120,6 @@ QgsWMSConfigParser* QgsConfigCache::wmsConfiguration( const QString& filePath, c
117
120
118
121
QDomDocument* QgsConfigCache::xmlDocument ( const QString& filePath )
119
122
{
120
- // first get cache
121
- QDomDocument* xmlDoc = mXmlDocumentCache .object ( filePath );
122
- if ( xmlDoc )
123
- return xmlDoc;
124
-
125
- // i it's first access
126
123
// first open file
127
124
QFile configFile ( filePath );
128
125
if ( !configFile.exists () )
@@ -136,26 +133,31 @@ QDomDocument* QgsConfigCache::xmlDocument( const QString& filePath )
136
133
QgsMessageLog::logMessage ( " Error, cannot open configuration file '" + filePath + " '" , " Server" , QgsMessageLog::CRITICAL );
137
134
return 0 ;
138
135
}
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 )
145
140
{
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 );
150
154
}
151
- mXmlDocumentCache .insert ( filePath, xmlDoc );
152
155
return xmlDoc;
153
156
}
154
157
155
158
void QgsConfigCache::removeChangedEntry ( const QString& path )
156
159
{
157
160
mXmlDocumentCache .remove ( path );
158
- mServerConfigCache .remove ( path );
159
161
mWMSConfigCache .remove ( path );
160
162
mWFSConfigCache .remove ( path );
161
163
mWCSConfigCache .remove ( path );
0 commit comments