[Marble-commits] branches/KDE/4.3/kdeedu/marble/src/lib
Bastian Holst
bastianholst at gmx.de
Sat Jul 18 17:02:33 CEST 2009
SVN commit 998777 by bholst:
Fix memory leak (backport of r998775 and r998750):
==7385== 1,904 (192 direct, 1,712 indirect) bytes in 2 blocks are definitely lost in loss record 218 of 508
==7385== at 0x4C2506C: operator new(unsigned long) (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==7385== by 0x5416B6B: Marble::AbstractDataPluginModel::AbstractDataPluginModel(QString const&, QObject*) (AbstractDataPluginModel.cpp:108)
==7385== by 0x149DB04E: Marble::WikipediaModel::WikipediaModel(QObject*) (WikipediaModel.cpp:39)
==7385== by 0x149D8B28: Marble::WikipediaPlugin::initialize() (WikipediaPlugin.cpp:79)
==7385== by 0x53D241B: Marble::LayerManager::LayerManager(Marble::MarbleDataFacade*, QObject*) (LayerManager.cpp:79)
==7385== by 0x539F539: Marble::MarbleModel::MarbleModel(QObject*) (MarbleModel.cpp:151)
==7385== by 0x53A49A9: Marble::MarbleMap::MarbleMap() (MarbleMap.cpp:350)
==7385== by 0x539B493: Marble::MarbleWidget::MarbleWidget(QWidget*) (MarbleWidget.cpp:129)
==7385== by 0x410AD4: Marble::ControlView::ControlView(QWidget*) (ControlView.cpp:43)
==7385== by 0x41A7CD: Marble::MarblePart::MarblePart(QWidget*, QObject*, QStringList const&) (marble_part.cpp:114)
==7385== by 0x41515B: Marble::MainWindow::MainWindow(QString const&, QWidget*) (KdeMainWindow.cpp:40)
==7385== by 0x414956: main (kdemain.cpp:244)
M +12 -7 AbstractDataPluginModel.cpp
M +2 -0 CacheStoragePolicy.cpp
M +2 -0 CacheStoragePolicy.h
--- branches/KDE/4.3/kdeedu/marble/src/lib/AbstractDataPluginModel.cpp #998776:998777
@@ -57,7 +57,8 @@
m_downloadedNumber( 0 ),
m_lastDataFacade( 0 ),
m_downloadTimer( new QTimer( m_parent ) ),
- m_descriptionFileNumber( 0 )
+ m_descriptionFileNumber( 0 ),
+ m_downloadManager( 0 )
{
}
@@ -88,7 +89,6 @@
QTimer *m_downloadTimer;
quint32 m_descriptionFileNumber;
- CacheStoragePolicy *m_storagePolicy;
HttpDownloadManager *m_downloadManager;
};
@@ -97,10 +97,10 @@
d( new AbstractDataPluginModelPrivate( name, this ) )
{
// Initializing file and download System
- d->m_storagePolicy = new CacheStoragePolicy( MarbleDirs::localPath()
- + "/cache/" + d->m_name + '/' );
+ CacheStoragePolicy *storagePolicy = new CacheStoragePolicy( MarbleDirs::localPath()
+ + "/cache/" + d->m_name + '/' );
d->m_downloadManager = new HttpDownloadManager( QUrl(),
- d->m_storagePolicy );
+ storagePolicy );
connect( d->m_downloadManager, SIGNAL( downloadComplete( QString, QString ) ),
this, SLOT( processFinishedJob( QString , QString ) ) );
@@ -113,6 +113,7 @@
AbstractDataPluginModel::~AbstractDataPluginModel()
{
+ d->m_downloadManager->storagePolicy()->clearCache();
delete d->m_downloadManager;
delete d;
}
@@ -305,7 +306,7 @@
bool AbstractDataPluginModel::fileExists( const QString& fileName ) const
{
- return d->m_storagePolicy->fileExists( fileName );
+ return d->m_downloadManager->storagePolicy()->fileExists( fileName );
}
bool AbstractDataPluginModel::fileExists( const QString& id, const QString& type ) const
@@ -387,7 +388,11 @@
Q_UNUSED( relativeUrlString );
if( id.startsWith( descriptionPrefix ) ) {
- parseFile( d->m_storagePolicy->data( id ) );
+ CacheStoragePolicy *storagePolicy
+ = qobject_cast<CacheStoragePolicy*>( d->m_downloadManager->storagePolicy() );
+ if ( storagePolicy ) {
+ parseFile( storagePolicy->data( id ) );
+ }
}
else {
// The downloaded file contains item data.
--- branches/KDE/4.3/kdeedu/marble/src/lib/CacheStoragePolicy.cpp #998776:998777
@@ -70,3 +70,5 @@
{
return m_cache.cacheLimit();
}
+
+#include "CacheStoragePolicy.moc"
--- branches/KDE/4.3/kdeedu/marble/src/lib/CacheStoragePolicy.h #998776:998777
@@ -24,6 +24,8 @@
class MARBLE_EXPORT CacheStoragePolicy : public StoragePolicy
{
+ Q_OBJECT
+
public:
/**
* Creates a new cache storage policy.
More information about the Marble-commits
mailing list