From cf794c78d1728d86c0d78d1a2a50f325781bf97e Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sun, 4 Jan 2009 03:06:57 +0000 Subject: [PATCH] clean up code a bit. especially remove obscure newing of a struct with C++ objects. --- src/marker.cpp | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/marker.cpp b/src/marker.cpp index 3961f8473..4aa8c3a9d 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -602,30 +602,29 @@ sp_marker_print (SPItem */*item*/, SPPrintContext */*ctx*/) void sp_marker_show_dimension (SPMarker *marker, unsigned int key, unsigned int size) { - SPMarkerView *view; - unsigned int i; + SPMarkerView *view; + unsigned int i; - for (view = marker->views; view != NULL; view = view->next) { - if (view->key == key) break; - } - if (view && (view->items.size() != size)) { - /* Free old view and allocate new */ - /* Parent class ::hide method */ - ((SPItemClass *) parent_class)->hide ((SPItem *) marker, key); - sp_marker_view_remove (marker, view, TRUE); - view = NULL; - } - if (!view) { - view = (SPMarkerView *) g_new (SPMarkerView, 1); - new (&view->items) std::vector; - view->items.clear(); - for (i = 0; i < size; i++) { - view->items.push_back(NULL); + for (view = marker->views; view != NULL; view = view->next) { + if (view->key == key) break; + } + if (view && (view->items.size() != size)) { + /* Free old view and allocate new */ + /* Parent class ::hide method */ + ((SPItemClass *) parent_class)->hide ((SPItem *) marker, key); + sp_marker_view_remove (marker, view, TRUE); + view = NULL; + } + if (!view) { + view = new SPMarkerView(); + view->items.clear(); + for (i = 0; i < size; i++) { + view->items.push_back(NULL); + } + view->next = marker->views; + marker->views = view; + view->key = key; } - view->next = marker->views; - marker->views = view; - view->key = key; - } } /** @@ -661,8 +660,8 @@ sp_marker_show_instance ( SPMarker *marker, NRArenaItem *parent, m = base; } else { /* fixme: Orient units (Lauris) */ - m = Geom::Matrix(Geom::Rotate::from_degrees(marker->orient)); - m *= Geom::Translate(base[4], base[5]); // TODO: this was NR::get_translation() originally; should it be extracted into a new 2geom function? + m = Geom::Rotate::from_degrees(marker->orient); + m *= Geom::Translate(base.translation()); } if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { m = Geom::Scale(linewidth) * m; -- 2.30.2