@@ -105,7 +105,7 @@ void QgsComposerSymbolItem::writeXML( QDomElement& elem, QDomDocument& doc ) con
105
105
elem.appendChild ( vectorClassElem );
106
106
}
107
107
108
- void QgsComposerSymbolItem::readXML ( const QDomElement& itemElem )
108
+ void QgsComposerSymbolItem::readXML ( const QDomElement& itemElem, bool xServerAvailable )
109
109
{
110
110
if ( itemElem.isNull () )
111
111
{
@@ -123,6 +123,10 @@ void QgsComposerSymbolItem::readXML( const QDomElement& itemElem )
123
123
QgsSymbol* symbol = new QgsSymbol ( vLayer->geometryType () );
124
124
symbol->readXML ( symbolElem, vLayer );
125
125
setSymbol ( symbol );
126
+ if ( !xServerAvailable ) // don't read icon without GUI
127
+ {
128
+ return ;
129
+ }
126
130
127
131
// add icon
128
132
switch ( symbol->type () )
@@ -193,7 +197,7 @@ void QgsComposerSymbolV2Item::writeXML( QDomElement& elem, QDomDocument& doc ) c
193
197
elem.appendChild ( vectorClassElem );
194
198
}
195
199
196
- void QgsComposerSymbolV2Item::readXML ( const QDomElement& itemElem )
200
+ void QgsComposerSymbolV2Item::readXML ( const QDomElement& itemElem, bool xServerAvailable )
197
201
{
198
202
if ( itemElem.isNull () )
199
203
{
@@ -213,7 +217,10 @@ void QgsComposerSymbolV2Item::readXML( const QDomElement& itemElem )
213
217
if ( symbolNg )
214
218
{
215
219
setSymbolV2 ( symbolNg );
216
- setIcon ( QgsSymbolLayerV2Utils::symbolPreviewIcon ( symbolNg, QSize ( 30 , 30 ) ) );
220
+ if ( xServerAvailable )
221
+ {
222
+ setIcon ( QgsSymbolLayerV2Utils::symbolPreviewIcon ( symbolNg, QSize ( 30 , 30 ) ) );
223
+ }
217
224
}
218
225
}
219
226
}
@@ -259,7 +266,7 @@ void QgsComposerRasterSymbolItem::writeXML( QDomElement& elem, QDomDocument& doc
259
266
elem.appendChild ( rasterClassElem );
260
267
}
261
268
262
- void QgsComposerRasterSymbolItem::readXML ( const QDomElement& itemElem )
269
+ void QgsComposerRasterSymbolItem::readXML ( const QDomElement& itemElem, bool xServerAvailable )
263
270
{
264
271
if ( itemElem.isNull () )
265
272
{
@@ -269,7 +276,7 @@ void QgsComposerRasterSymbolItem::readXML( const QDomElement& itemElem )
269
276
setLayerID ( itemElem.attribute ( " layerId" , " " ) );
270
277
271
278
QgsRasterLayer* rLayer = qobject_cast<QgsRasterLayer*>( QgsMapLayerRegistry::instance ()->mapLayer ( mLayerID ) );
272
- if ( rLayer )
279
+ if ( rLayer && xServerAvailable )
273
280
{
274
281
setIcon ( QIcon ( rLayer->legendAsPixmap ( true ) ) );
275
282
}
@@ -306,7 +313,7 @@ void QgsComposerLayerItem::writeXML( QDomElement& elem, QDomDocument& doc ) cons
306
313
elem.appendChild ( layerItemElem );
307
314
}
308
315
309
- void QgsComposerLayerItem::readXML ( const QDomElement& itemElem )
316
+ void QgsComposerLayerItem::readXML ( const QDomElement& itemElem, bool xServerAvailable )
310
317
{
311
318
if ( itemElem.isNull () )
312
319
{
@@ -348,7 +355,7 @@ void QgsComposerLayerItem::readXML( const QDomElement& itemElem )
348
355
{
349
356
continue ; // unsupported child type
350
357
}
351
- currentChildItem->readXML ( currentElem );
358
+ currentChildItem->readXML ( currentElem, xServerAvailable );
352
359
appendRow ( currentChildItem );
353
360
}
354
361
}
@@ -382,7 +389,7 @@ void QgsComposerGroupItem::writeXML( QDomElement& elem, QDomDocument& doc ) cons
382
389
elem.appendChild ( layerGroupElem );
383
390
}
384
391
385
- void QgsComposerGroupItem::readXML ( const QDomElement& itemElem )
392
+ void QgsComposerGroupItem::readXML ( const QDomElement& itemElem, bool xServerAvailable )
386
393
{
387
394
if ( itemElem.isNull () )
388
395
{
@@ -420,7 +427,7 @@ void QgsComposerGroupItem::readXML( const QDomElement& itemElem )
420
427
{
421
428
continue ; // unsupported child item type
422
429
}
423
- currentChildItem->readXML ( currentElem );
430
+ currentChildItem->readXML ( currentElem, xServerAvailable );
424
431
appendRow ( currentChildItem );
425
432
}
426
433
}
0 commit comments