To all,<br><br>For informations, this commit from Patrick into marble from trunk must speed-up digiKam startup to use shared components for all marble instances...<br><br>Gilles Caulier<br><br><br><br><div class="gmail_quote">
---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Patrick Spendrin</b> <span dir="ltr"><<a href="mailto:ps_ml@gmx.de">ps_ml@gmx.de</a>></span><br>Date: 2008/11/26<br>Subject: KDE/kdeedu/marble/src/lib<br>
To: <a href="mailto:kde-commits@kde.org">kde-commits@kde.org</a><br>Cc: <a href="mailto:caulier.gilles@gmail.com">caulier.gilles@gmail.com</a><br><br><br>SVN commit 889199 by sengels:<br>
<br>
reuse some stuff and make marblewidget faster<br>
<a href="mailto:CCMAIL%3Acaulier.gilles@gmail.com">CCMAIL:caulier.gilles@gmail.com</a><br>
<br>
M +21 -8 MarbleModel.cpp<br>
<br>
<br>
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #889198:889199<br>
@@ -8,12 +8,14 @@<br>
// Copyright 2006-2007 Torsten Rahn <<a href="mailto:tackat@kde.org">tackat@kde.org</a>>"<br>
// Copyright 2007 Inge Wallin <<a href="mailto:ingwa@kde.org">ingwa@kde.org</a>>"<br>
// Copyright 2008 Jens-Michael Hoffmann <<a href="mailto:jensmh@gmx.de">jensmh@gmx.de</a>><br>
+// Copyright 2008 Patrick Spendrin <<a href="mailto:ps_ml@gmx.de">ps_ml@gmx.de</a>><br>
//<br>
<br>
#include "MarbleModel.h"<br>
<br>
#include <cmath><br>
<br>
+#include <QtCore/QAtomicInt><br>
#include <QtCore/QDebug><br>
#include <QtCore/QTime><br>
#include <QtCore/QTimer><br>
@@ -79,20 +81,21 @@<br>
void notifyModelChanged();<br>
void geoDataDocumentLoaded( GeoDataDocument& document );<br>
<br>
+ static QAtomicInt refCounter;<br>
MarbleModel *m_parent;<br>
MarbleDataFacade *m_dataFacade;<br>
<br>
// View and paint stuff<br>
GeoSceneDocument *m_mapTheme;<br>
LayerManager *m_layerManager;<br>
- TextureColorizer *m_texcolorizer;<br>
+ static TextureColorizer *m_texcolorizer;<br>
<br>
HttpDownloadManager *m_downloadManager;<br>
<br>
TileLoader *m_tileLoader;<br>
AbstractScanlineTextureMapper *m_texmapper;<br>
<br>
- VectorComposer *m_veccomposer; // FIXME: Make not a pointer.<br>
+ static VectorComposer *m_veccomposer; // FIXME: Make not a pointer.<br>
GridMap *m_gridmap;<br>
<br>
// Places on the map<br>
@@ -118,10 +121,15 @@<br>
FileViewModel *m_fileviewmodel;<br>
};<br>
<br>
+VectorComposer *MarbleModelPrivate::m_veccomposer = 0;<br>
+TextureColorizer *MarbleModelPrivate::m_texcolorizer = 0;<br>
+QAtomicInt MarbleModelPrivate::refCounter(0);<br>
+<br>
MarbleModel::MarbleModel( QObject *parent )<br>
: QObject( parent ),<br>
d( new MarbleModelPrivate( this ) )<br>
{<br>
+ MarbleModelPrivate::refCounter.ref();<br>
d->m_dataFacade = new MarbleDataFacade( this );<br>
d->m_layerManager = new LayerManager( d->m_dataFacade, this );<br>
<br>
@@ -143,11 +151,13 @@<br>
// this, SLOT( paintTile(TextureTile*, int, int, int, GeoSceneTexture*, bool) ) );<br>
<br>
d->m_texmapper = 0;<br>
- d->m_veccomposer = new VectorComposer();<br>
-<br>
d->m_gridmap = new GridMap( this );<br>
- d->m_texcolorizer = new TextureColorizer( MarbleDirs::path( "seacolors.leg" ),<br>
- MarbleDirs::path( "landcolors.leg" ) );<br>
+<br>
+ if( MarbleModelPrivate::refCounter == 1 ) {<br>
+ d->m_veccomposer = new VectorComposer();<br>
+ d->m_texcolorizer = new TextureColorizer( MarbleDirs::path( "seacolors.leg" ),<br>
+ MarbleDirs::path( "landcolors.leg" ) );<br>
+ }<br>
<br>
d->m_placemarkmanager = new PlaceMarkManager();<br>
<br>
@@ -206,8 +216,11 @@<br>
delete d->m_tileLoader; // disconnects from downloadManager in dtor<br>
delete d->m_downloadManager;<br>
<br>
- delete d->m_veccomposer;<br>
- delete d->m_texcolorizer;<br>
+ if( MarbleModelPrivate::refCounter == 1 ) {<br>
+ delete d->m_veccomposer;<br>
+ delete d->m_texcolorizer;<br>
+ MarbleModelPrivate::refCounter.deref();<br>
+ }<br>
delete d->m_gridmap;<br>
delete d->m_geometrymodel;<br>
delete d->m_placemarkmodel;<br>
</div><br>