From 6aee33be14ffdaffe2fb7f0039cb51753b89db40 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sun, 28 Jun 2009 19:47:51 +0200 Subject: [PATCH] Fixed error Private struct size == 0. --- src/geometry.c | 40 +++++++------------------------------ src/geometryline.c | 8 ++++---- src/geometrypoint.c | 28 +------------------------- src/geometrypolygon.c | 10 +++++++--- src/geometrypolygon.h | 1 - src/geometryraster.c | 28 +------------------------- src/layer.c | 43 ++++++++++------------------------------ src/layer.h | 4 ++-- src/layersgroup.c | 28 +------------------------- src/layersource.c | 7 ++++--- src/layersourcepostgis.c | 28 +------------------------- src/layersourceshp.c | 28 +------------------------- tests/test1.gtkgis | 6 +++--- 13 files changed, 42 insertions(+), 217 deletions(-) diff --git a/src/geometry.c b/src/geometry.c index b0bd855..78a3f0e 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -40,47 +40,21 @@ static void gtk_gis_geometry_get_property (GObject *object, GParamSpec *pspec); -#define GTK_GIS_GEOMETRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_GIS_GEOMETRY, GtkGisGeometryPrivate)) +/*#define GTK_GIS_GEOMETRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_GIS_GEOMETRY, GtkGisGeometryPrivate)) typedef struct _GtkGisGeometryPrivate GtkGisGeometryPrivate; struct _GtkGisGeometryPrivate { - }; + };*/ -GType -gtk_gis_geometry_get_type (void) -{ - static GType gtk_gis_geometry_type = 0; - - if (!gtk_gis_geometry_type) - { - static const GTypeInfo gtk_gis_geometry_info = - { - sizeof (GtkGisGeometryClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_gis_geometry_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkGisGeometry), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_gis_geometry_init, - NULL - }; - - gtk_gis_geometry_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisGeometry", - >k_gis_geometry_info, 0); - } - - return gtk_gis_geometry_type; -} +G_DEFINE_TYPE (GtkGisGeometry, gtk_gis_geometry, G_TYPE_OBJECT) static void gtk_gis_geometry_class_init (GtkGisGeometryClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (GtkGisGeometryPrivate)); + /*g_type_class_add_private (object_class, sizeof (GtkGisGeometryPrivate));*/ object_class->set_property = gtk_gis_geometry_set_property; object_class->get_property = gtk_gis_geometry_get_property; @@ -89,7 +63,7 @@ gtk_gis_geometry_class_init (GtkGisGeometryClass *klass) static void gtk_gis_geometry_init (GtkGisGeometry *gtk_gis_geometry) { - GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry); + /*GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);*/ } static void @@ -97,7 +71,7 @@ gtk_gis_geometry_set_property (GObject *object, guint property_id, const GValue { GtkGisGeometry *gtk_gis_geometry = GTK_GIS_GEOMETRY (object); - GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry); + /*GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);*/ switch (property_id) { @@ -112,7 +86,7 @@ gtk_gis_geometry_get_property (GObject *object, guint property_id, GValue *value { GtkGisGeometry *gtk_gis_geometry = GTK_GIS_GEOMETRY (object); - GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry); + /*GtkGisGeometryPrivate *priv = GTK_GIS_GEOMETRY_GET_PRIVATE (gtk_gis_geometry);*/ switch (property_id) { diff --git a/src/geometryline.c b/src/geometryline.c index 11fdeba..c2cd977 100644 --- a/src/geometryline.c +++ b/src/geometryline.c @@ -79,11 +79,11 @@ gtk_gis_geometry_line_init (GtkGisGeometryLine *gtk_gis_geometry_line) GtkGisGeometry *gtk_gis_geometry_line_new () { - GtkGisGeometry *gtk_gis_geometry_line; + GtkGisGeometry *line; - gtk_gis_geometry_line = g_object_new (gtk_gis_geometry_line_get_type (), NULL); + line = g_object_new (gtk_gis_geometry_line_get_type (), NULL); - return gtk_gis_geometry_line; + return line; } /** @@ -97,7 +97,7 @@ GtkGisGeometry GtkGisGeometry *gtk_gis_geometry_line_new_from_array (GPtrArray *points) { - GtkGisGeometry *line; + GtkGisGeometry *line = NULL; GtkGisGeometryLinePrivate *priv; line = gtk_gis_geometry_line_new (); diff --git a/src/geometrypoint.c b/src/geometrypoint.c index f352267..8647b29 100644 --- a/src/geometrypoint.c +++ b/src/geometrypoint.c @@ -48,33 +48,7 @@ struct _GtkGisGeometryPointPrivate GtkGisPoint point; }; -GType -gtk_gis_geometry_point_get_type (void) -{ - static GType gtk_gis_geometry_point_type = 0; - - if (!gtk_gis_geometry_point_type) - { - static const GTypeInfo gtk_gis_geometry_point_info = - { - sizeof (GtkGisGeometryPointClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_gis_geometry_point_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkGisGeometryPoint), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_gis_geometry_point_init, - NULL - }; - - gtk_gis_geometry_point_type = g_type_register_static (TYPE_GTK_GIS_GEOMETRY, "GtkGisGeometryPoint", - >k_gis_geometry_point_info, 0); - } - - return gtk_gis_geometry_point_type; -} +G_DEFINE_TYPE (GtkGisGeometryPoint, gtk_gis_geometry_point, TYPE_GTK_GIS_GEOMETRY) static void gtk_gis_geometry_point_class_init (GtkGisGeometryPointClass *klass) diff --git a/src/geometrypolygon.c b/src/geometrypolygon.c index 6d79aa8..01bc588 100644 --- a/src/geometrypolygon.c +++ b/src/geometrypolygon.c @@ -115,12 +115,16 @@ GtkGisGeometry GtkGisGeometry *gtk_gis_geometry_polygon_new_from_array (GPtrArray *points) { - GtkGisGeometry *polygon; - GtkGisGeometry *line; + GtkGisGeometry *polygon = NULL; + GtkGisGeometry *line = NULL; line = gtk_gis_geometry_line_new_from_array (points); - gtk_gis_geometry_polygon_add_line (GTK_GIS_GEOMETRY_POLYGON (polygon), GTK_GIS_GEOMETRY_LINE (line)); + if (line != NULL) + { + polygon = gtk_gis_geometry_polygon_new (); + gtk_gis_geometry_polygon_add_line (GTK_GIS_GEOMETRY_POLYGON (polygon), GTK_GIS_GEOMETRY_LINE (line)); + } return polygon; } diff --git a/src/geometrypolygon.h b/src/geometrypolygon.h index a1ecbd8..0b6e008 100644 --- a/src/geometrypolygon.h +++ b/src/geometrypolygon.h @@ -20,7 +20,6 @@ #ifndef __GTK_GIS_GEOMETRY_POLYGON_H__ #define __GTK_GIS_GEOMETRY_POLYGON_H__ -#include "geometry.h" #include "geometryline.h" G_BEGIN_DECLS diff --git a/src/geometryraster.c b/src/geometryraster.c index 9979a0c..9d52f9d 100644 --- a/src/geometryraster.c +++ b/src/geometryraster.c @@ -47,33 +47,7 @@ struct _GtkGisGeometryRasterPrivate { }; -GType -gtk_gis_geometry_raster_get_type (void) -{ - static GType gtk_gis_geometry_raster_type = 0; - - if (!gtk_gis_geometry_raster_type) - { - static const GTypeInfo gtk_gis_geometry_raster_info = - { - sizeof (GtkGisGeometryRasterClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_gis_geometry_raster_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkGisGeometryRaster), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_gis_geometry_raster_init, - NULL - }; - - gtk_gis_geometry_raster_type = g_type_register_static (TYPE_GTK_GIS_GEOMETRY, "GtkGisGeometryRaster", - >k_gis_geometry_raster_info, 0); - } - - return gtk_gis_geometry_raster_type; -} +G_DEFINE_TYPE (GtkGisGeometryRaster, gtk_gis_geometry_raster, TYPE_GTK_GIS_GEOMETRY) static void gtk_gis_geometry_raster_class_init (GtkGisGeometryRasterClass *klass) diff --git a/src/layer.c b/src/layer.c index 9f7b42d..66c88f8 100644 --- a/src/layer.c +++ b/src/layer.c @@ -56,33 +56,7 @@ struct _GtkGisLayerPrivate gboolean editable; }; -GType -gtk_gis_layer_get_type (void) -{ - static GType gtk_gis_layer_type = 0; - - if (!gtk_gis_layer_type) - { - static const GTypeInfo gtk_gis_layer_info = - { - sizeof (GtkGisLayerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_gis_layer_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkGisLayer), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_gis_layer_init, - NULL - }; - - gtk_gis_layer_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisLayer", - >k_gis_layer_info, 0); - } - - return gtk_gis_layer_type; -} +G_DEFINE_TYPE (GtkGisLayer, gtk_gis_layer, G_TYPE_OBJECT) static void gtk_gis_layer_class_init (GtkGisLayerClass *klass) @@ -113,7 +87,7 @@ gtk_gis_layer_init (GtkGisLayer *gtk_gis_layer) */ GtkGisLayer *gtk_gis_layer_new (GtkGisLayerSource *source, - gchar *name, + const gchar *name, GtkGisLayerGeometryType geometry_type) { GtkGisLayer *gtk_gis_layer; @@ -143,17 +117,20 @@ GtkGisLayer */ GtkGisLayer *gtk_gis_layer_new_from_source (GtkGisLayerSource *source, - gchar *name) + const gchar *name) { - GtkGisLayer *layer; + GtkGisLayer *layer = NULL; - GtkGisLayerGeometryType type; + GtkGisLayerGeometryType type = -1; type = gtk_gis_layer_source_get_layer_geometry_type (source, name); - layer = gtk_gis_layer_new (source, name, type); + if (type >= 0) + { + layer = gtk_gis_layer_new (source, name, type); - gtk_gis_layer_fill_from_source (layer); + gtk_gis_layer_fill_from_source (layer); + } return layer; } diff --git a/src/layer.h b/src/layer.h index 5e9f3f6..a89b7c4 100644 --- a/src/layer.h +++ b/src/layer.h @@ -56,11 +56,11 @@ GType gtk_gis_layer_get_type (void) G_GNUC_CONST; GtkGisLayer *gtk_gis_layer_new (GtkGisLayerSource *source, - gchar *name, + const gchar *name, GtkGisLayerGeometryType geometry_type); GtkGisLayer *gtk_gis_layer_new_from_source (GtkGisLayerSource *source, - gchar *name); + const gchar *name); gchar *gtk_gis_layer_get_name (GtkGisLayer *layer); diff --git a/src/layersgroup.c b/src/layersgroup.c index 1a4b236..bc9ba50 100644 --- a/src/layersgroup.c +++ b/src/layersgroup.c @@ -47,33 +47,7 @@ struct _GtkGisLayersGroupPrivate GList *layers; }; -GType -gtk_gis_layers_group_get_type (void) -{ - static GType gtk_gis_layers_group_type = 0; - - if (!gtk_gis_layers_group_type) - { - static const GTypeInfo gtk_gis_layers_group_info = - { - sizeof (GtkGisLayersGroupClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_gis_layers_group_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkGisLayersGroup), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_gis_layers_group_init, - NULL - }; - - gtk_gis_layers_group_type = g_type_register_static (G_TYPE_OBJECT, "GtkGisLayersGroup", - >k_gis_layers_group_info, 0); - } - - return gtk_gis_layers_group_type; -} +G_DEFINE_TYPE (GtkGisLayersGroup, gtk_gis_layers_group, G_TYPE_OBJECT) static void gtk_gis_layers_group_class_init (GtkGisLayersGroupClass *klass) diff --git a/src/layersource.c b/src/layersource.c index 91a88ab..b40d53c 100644 --- a/src/layersource.c +++ b/src/layersource.c @@ -24,9 +24,11 @@ #include #include "layersource.h" +#include "geometry.h" #include "geometryline.h" #include "geometrypoint.h" #include "geometrypolygon.h" +#include "geometryraster.h" static void gtk_gis_layer_source_class_init (GtkGisLayerSourceClass *klass); static void gtk_gis_layer_source_init (GtkGisLayerSource *gtk_gis_layer_source); @@ -76,7 +78,7 @@ gtk_gis_layer_source_init (GtkGisLayerSource *gtk_gis_layer_source) static void gtk_gis_layer_source_set_ogr_datasource (GtkGisLayerSource *source, - OGRDataSourceH datasource) + OGRDataSourceH datasource) { GtkGisLayerSourcePrivate *priv = GTK_GIS_LAYER_SOURCE_GET_PRIVATE (source); @@ -91,7 +93,7 @@ gtk_gis_layer_source_set_ogr_datasource (GtkGisLayerSource *source, * * Loads the #GtkGisLayerSource from the disk. * - * Returns: . + * Returns: a #GList of #GtkGeometry objects. */ GList *gtk_gis_layer_source_get_geometries (GtkGisLayerSource *source, @@ -168,7 +170,6 @@ GList for (i_geometry = 0; i_geometry < num_geometries; i_geometry++) { - gint points; gint point; GPtrArray *gar_points; diff --git a/src/layersourcepostgis.c b/src/layersourcepostgis.c index b0ce113..398b467 100644 --- a/src/layersourcepostgis.c +++ b/src/layersourcepostgis.c @@ -46,33 +46,7 @@ struct _GtkGisLayerSourcePostgisPrivate gchar *password; }; -GType -gtk_gis_layer_source_postgis_get_type (void) -{ - static GType gtk_gis_layer_source_postgis_type = 0; - - if (!gtk_gis_layer_source_postgis_type) - { - static const GTypeInfo gtk_gis_layer_source_postgis_info = - { - sizeof (GtkGisLayerSourcePostgisClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_gis_layer_source_postgis_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkGisLayerSourcePostgis), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_gis_layer_source_postgis_init, - NULL - }; - - gtk_gis_layer_source_postgis_type = g_type_register_static (TYPE_GTK_GIS_LAYER_SOURCE, "GtkGisLayerSourcePostgis", - >k_gis_layer_source_postgis_info, 0); - } - - return gtk_gis_layer_source_postgis_type; -} +G_DEFINE_TYPE (GtkGisLayerSourcePostgis, gtk_gis_layer_source_postgis, TYPE_GTK_GIS_LAYER_SOURCE) static void gtk_gis_layer_source_postgis_class_init (GtkGisLayerSourcePostgisClass *klass) diff --git a/src/layersourceshp.c b/src/layersourceshp.c index 5132a51..127f692 100644 --- a/src/layersourceshp.c +++ b/src/layersourceshp.c @@ -50,33 +50,7 @@ struct _GtkGisLayerSourceShpPrivate gchar *filename; }; -GType -gtk_gis_layer_source_shp_get_type (void) -{ - static GType gtk_gis_layer_source_shp_type = 0; - - if (!gtk_gis_layer_source_shp_type) - { - static const GTypeInfo gtk_gis_layer_source_shp_info = - { - sizeof (GtkGisLayerSourceShpClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_gis_layer_source_shp_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkGisLayerSourceShp), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_gis_layer_source_shp_init, - NULL - }; - - gtk_gis_layer_source_shp_type = g_type_register_static (TYPE_GTK_GIS_LAYER_SOURCE, "GtkGisLayerSourceShp", - >k_gis_layer_source_shp_info, 0); - } - - return gtk_gis_layer_source_shp_type; -} +G_DEFINE_TYPE (GtkGisLayerSourceShp, gtk_gis_layer_source_shp, TYPE_GTK_GIS_LAYER_SOURCE) static void gtk_gis_layer_source_shp_class_init (GtkGisLayerSourceShpClass *klass) diff --git a/tests/test1.gtkgis b/tests/test1.gtkgis index bf96191..eb25c76 100644 --- a/tests/test1.gtkgis +++ b/tests/test1.gtkgis @@ -8,19 +8,19 @@ -- 2.49.0