[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/marble/src/lib/geodata/scene
From: Nikolas Zimmermann <wildfox () kde ! org>
Date: 2008-03-11 15:20:34
Message-ID: 1205248834.505048.23569.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 784514 by wildfox:
Don't crash on non-existant property (calling property->setName on null pointer!)
Also cleanup code & style, and add an assertion.
M +11 -11 GeoSceneSettings.cpp
M +4 -6 GeoSceneSettings.h
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneSettings.cpp #784513:784514
@@ -23,29 +23,29 @@
GeoSceneSettings::GeoSceneSettings()
{
- /* NOOP */
}
GeoSceneSettings::~GeoSceneSettings()
{
- qDebug("GeoSceneSettings::~GeoSceneSettings(). Object count: %d", m_properties.count());
-
- foreach ( GeoSceneProperty* property, m_properties ) {
- delete property;
- }
+ qDeleteAll(m_properties);
}
-void GeoSceneSettings::addProperty( const QString& name, GeoSceneProperty* property )
+void GeoSceneSettings::addProperty(const QString& name, GeoSceneProperty* property)
{
- m_properties.insert( name, property );
+ m_properties.insert(name, property);
}
GeoSceneProperty* GeoSceneSettings::property( const QString& name )
{
- GeoSceneProperty* property = m_properties.value( name );
- if ( !property )
- addProperty( name , new GeoSceneProperty );
+ GeoSceneProperty* property = m_properties.value(name);
+ if (property) {
+ Q_ASSERT(property->name() == name);
+ return property;
+ }
+
+ property = new GeoSceneProperty;
property->setName(name);
+ addProperty(name, property);
return property;
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneSettings.h #784513:784514
@@ -30,23 +30,21 @@
/**
* @short Settings of a GeoScene document.
*/
-
class GeoSceneSettings : public GeoNode {
public:
GeoSceneSettings();
- ~GeoSceneSettings();
+ virtual ~GeoSceneSettings();
/**
* @brief Add a property to the settings
* @param property the new property
*/
- void addProperty( const QString& name, GeoSceneProperty* property );
- GeoSceneProperty* property( const QString& name );
+ void addProperty(const QString& name, GeoSceneProperty*);
+ GeoSceneProperty* property(const QString&);
protected:
/// The hash table holding all the properties in the settings.
- QHash < QString, GeoSceneProperty* > m_properties;
+ QHash<QString, GeoSceneProperty*> m_properties;
};
-
#endif // GEOSCENESETTINGS_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic