[Marble-commits] KDE/kdeedu/marble/src/plugins/runner/nominatim
Dennis Nienhüser
earthwings at gentoo.org
Fri Nov 19 22:55:18 CET 2010
SVN commit 1198827 by nienhueser:
Fix memory leak.
M +19 -8 OsmNominatimRunner.cpp
M +3 -1 OsmNominatimRunner.h
--- trunk/KDE/kdeedu/marble/src/plugins/runner/nominatim/OsmNominatimRunner.cpp #1198826:1198827
@@ -29,16 +29,23 @@
{
OsmNominatimRunner::OsmNominatimRunner( QObject *parent ) :
- MarbleAbstractRunner( parent ), m_manager(0)
+ MarbleAbstractRunner( parent ), m_searchManager( 0 ),
+ m_reverseGeocodingManager( 0 )
{
// nothing to do
}
OsmNominatimRunner::~OsmNominatimRunner()
{
- m_manager->deleteLater();
+ if ( m_searchManager ) {
+ m_searchManager->deleteLater();
}
+ if ( m_reverseGeocodingManager ) {
+ m_reverseGeocodingManager->deleteLater();
+ }
+}
+
GeoDataFeature::GeoDataVisualCategory OsmNominatimRunner::category() const
{
return GeoDataFeature::OsmSite;
@@ -56,15 +63,17 @@
QString query = "q=%1&format=xml&addressdetails=0&accept-language=%2";
QString url = QString(base + query).arg(searchTerm).arg(MarbleLocale::languageCode());
- m_manager = new QNetworkAccessManager;
- connect(m_manager, SIGNAL(finished(QNetworkReply*)),
+ if ( !m_searchManager ) {
+ m_searchManager = new QNetworkAccessManager;
+ connect(m_searchManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(handleSearchResult(QNetworkReply*)), Qt::DirectConnection);
+ }
QNetworkRequest request;
request.setUrl(QUrl(url));
request.setRawHeader("User-Agent", TinyWebBrowser::userAgent("Browser", "OsmNominatimRunner") );
- QNetworkReply *reply = m_manager->get(QNetworkRequest(request));
+ QNetworkReply *reply = m_searchManager->get(request);
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(returnNoResults()), Qt::DirectConnection);
}
@@ -79,15 +88,17 @@
double lat = coordinates.latitude( GeoDataCoordinates::Degree );
QString url = QString( base + query ).arg( lon ).arg( lat ).arg( MarbleLocale::languageCode() );
- m_manager = new QNetworkAccessManager;
- connect(m_manager, SIGNAL(finished(QNetworkReply*)),
+ if ( !m_reverseGeocodingManager ) {
+ m_reverseGeocodingManager = new QNetworkAccessManager;
+ connect(m_reverseGeocodingManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(handleReverseGeocodingResult(QNetworkReply*)), Qt::DirectConnection);
+ }
QNetworkRequest request;
request.setUrl(QUrl(url));
request.setRawHeader("User-Agent", TinyWebBrowser::userAgent("Browser", "OsmNominatimRunner") );
- m_manager->get(QNetworkRequest(request));
+ m_reverseGeocodingManager->get(request);
}
void OsmNominatimRunner::handleSearchResult( QNetworkReply* reply )
--- trunk/KDE/kdeedu/marble/src/plugins/runner/nominatim/OsmNominatimRunner.h #1198826:1198827
@@ -53,8 +53,10 @@
private:
void addData( const QDomNodeList &node, const QString &key, GeoDataExtendedData *extendedData );
- QNetworkAccessManager* m_manager;
+ QNetworkAccessManager* m_searchManager;
+ QNetworkAccessManager* m_reverseGeocodingManager;
+
GeoDataCoordinates m_coordinates;
};
More information about the Marble-commits
mailing list