r5514 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Fri Aug 21 20:20:37 CEST 2009


Author: werner
Date: 2009-08-21 20:20:37 +0200 (Fri, 21 Aug 2009)
New Revision: 5514

Added:
   trunk/eda/fped/leak.supp
Modified:
   trunk/eda/fped/TODO
   trunk/eda/fped/fped.c
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_style.c
   trunk/eda/fped/gui_style.h
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/gui_tool.h
   trunk/eda/fped/inst.c
   trunk/eda/fped/inst.h
   trunk/eda/fped/leakcheck
   trunk/eda/fped/meas.c
   trunk/eda/fped/obj.c
Log:
- measurement offsets can now use variables. We evaluate the offset during
  instantiation and create a partially formed instance. During measurement
  instantiation, we complete that instance.
- leak.supp: finally figured out how to write a valgrind suppression file
- fped.c: we don't need the FPED_NO_GUI kludge anymore
- fped.c: moved gui_cleanup_style to gui_main
- dereference icons (seems that this doesn't deallocate everything, though)



Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/TODO	2009-08-21 18:20:37 UTC (rev 5514)
@@ -34,8 +34,6 @@
 - whenever we call parse_* for input parsing, we may leak lots of expressions
 - can't edit measurement labels through the GUI
 - r of rpads is misleading, particularly if we have a circle
-- using variables in a measurement offset causes a crash because evaluation
-  takes place after all table entries have been visited
 
 Code cleanup:
 - merge edit_unique with edit_name

Modified: trunk/eda/fped/fped.c
===================================================================
--- trunk/eda/fped/fped.c	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/fped.c	2009-08-21 18:20:37 UTC (rev 5514)
@@ -56,13 +56,10 @@
 	int error;
 	int batch_write_kicad = 0, batch_write_ps = 0;
 	int c;
-	int have_gui = !getenv("FPED_NO_GUI");
 
-	if (have_gui) {
-		error = gui_init(&argc, &argv);
-		if (error)
-			return error;
-	}
+	error = gui_init(&argc, &argv);
+	if (error)
+		return error;
 
 	while ((c = getopt(argc, argv, "kp")) != EOF)
 		switch (c) {
@@ -106,7 +103,7 @@
 		write_kicad();
 	if (batch_write_ps)
 		write_ps();
-	if (have_gui && !batch_write_kicad && !batch_write_ps) {
+	if (!batch_write_kicad && !batch_write_ps) {
 		error = gui_main();
 		if (error)
 			return error;

Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/gui.c	2009-08-21 18:20:37 UTC (rev 5514)
@@ -139,6 +139,15 @@
 }
 
 
+static void cleanup_tool_bar(void)
+{
+	g_object_unref(stuff_image[0]);
+	g_object_unref(stuff_image[1]);
+	g_object_unref(meas_image[0]);
+	g_object_unref(meas_image[1]);
+}
+
+
 static void make_top_bar(GtkWidget *vbox)
 {
 	GtkWidget *hbox;
@@ -248,5 +257,9 @@
 
 	gtk_main();
 
+	gui_cleanup_style();
+	gui_cleanup_tools();
+	cleanup_tool_bar();
+
 	return 0;
 }

Modified: trunk/eda/fped/gui_style.c
===================================================================
--- trunk/eda/fped/gui_style.c	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/gui_style.c	2009-08-21 18:20:37 UTC (rev 5514)
@@ -74,3 +74,9 @@
 
 	item_list_font = pango_font_description_from_string(ITEM_LIST_FONT);
 }
+
+
+void gui_cleanup_style(void)
+{
+	pango_font_description_free(item_list_font);
+}

Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/gui_style.h	2009-08-21 18:20:37 UTC (rev 5514)
@@ -115,5 +115,6 @@
 extern PangoFontDescription *item_list_font;
 
 void gui_setup_style(GdkDrawable *drawable);
+void gui_cleanup_style(void);
 
 #endif /* !GUI_STYLE_H */

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/gui_tool.c	2009-08-21 18:20:37 UTC (rev 5514)
@@ -1044,3 +1044,13 @@
 
 	return bar;
 }
+
+
+void gui_cleanup_tools(void)
+{
+	g_object_unref(frame_image);
+	g_object_unref(frame_image_locked);
+	g_object_unref(frame_image_ready);
+	g_object_unref(delete_image[0]);
+	g_object_unref(delete_image[1]);
+}

Modified: trunk/eda/fped/gui_tool.h
===================================================================
--- trunk/eda/fped/gui_tool.h	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/gui_tool.h	2009-08-21 18:20:37 UTC (rev 5514)
@@ -77,5 +77,6 @@
 void tool_reset(void);
 
 GtkWidget *gui_setup_tools(GdkDrawable *drawable);
+void gui_cleanup_tools(void);
 
 #endif /* !GUI_TOOL_H */

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/inst.c	2009-08-21 18:20:37 UTC (rev 5514)
@@ -803,18 +803,28 @@
 };
 
 
-int inst_meas(struct obj *obj,
-    struct coord from, struct coord to, unit_type offset)
+static struct inst *find_meas_hint(const struct obj *obj)
 {
 	struct inst *inst;
+
+	for (inst = curr_pkg->insts[ip_meas]; inst; inst = inst->next)
+		if (inst->obj == obj)
+			break;
+	return inst;
+}
+
+
+int inst_meas(struct obj *obj, struct coord from, struct coord to)
+{
+	struct inst *inst;
 	struct coord a1, b1;
 
-	inst = add_inst(&meas_ops, ip_meas, from);
-	inst->obj = obj;
+	inst = find_meas_hint(obj);
+	assert(inst);
+	inst->base = from;
 	inst->u.meas.end = to;
-	inst->u.meas.offset = offset;
-	inst->active = 1; /* measurements are always active */
 	/* @@@ we still need to consider the text size as well */
+	update_bbox(&inst->bbox, from);
 	update_bbox(&inst->bbox, to);
 	project_meas(inst, &a1, &b1);
 	update_bbox(&inst->bbox, a1);
@@ -824,6 +834,21 @@
 }
 
 
+void inst_meas_hint(struct obj *obj, unit_type offset)
+{
+	static const struct coord zero = { 0, 0 };
+	struct inst *inst;
+
+	inst = find_meas_hint(obj);
+	if (inst)
+		return;
+	inst = add_inst(&meas_ops, ip_meas, zero);
+	inst->obj = obj;
+	inst->u.meas.offset = offset;
+	inst->active = 1; /* measurements are always active */
+}
+
+
 /* ----- direct editing of objects ----------------------------------------- */
 
 

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/inst.h	2009-08-21 18:20:37 UTC (rev 5514)
@@ -164,8 +164,8 @@
 int inst_pad(struct obj *obj, const char *name, struct coord a, struct coord b);
 int inst_arc(struct obj *obj, struct coord center, struct coord start,
     struct coord stop, unit_type width);
-int inst_meas(struct obj *obj, struct coord from, struct coord to,
-    unit_type offset);
+int inst_meas(struct obj *obj, struct coord from, struct coord to);
+void inst_meas_hint(struct obj *obj, unit_type offset);
 
 void inst_begin_active(int active);
 void inst_end_active(void);

Added: trunk/eda/fped/leak.supp
===================================================================
--- trunk/eda/fped/leak.supp	                        (rev 0)
+++ trunk/eda/fped/leak.supp	2009-08-21 18:20:37 UTC (rev 5514)
@@ -0,0 +1,31 @@
+{
+	gtk_internal
+	Memcheck:Leak
+	...
+	fun:gtk_init
+}
+
+{
+	lex
+	Memcheck:Leak
+	fun:malloc
+	...
+	fun:yyensure_buffer_stack
+	...
+}
+
+{
+	pango_leaks_like_crazy
+	Memcheck:Leak
+	...
+	fun:pango_*
+	...
+}
+
+{
+	gdk_pixbuf_new_from_xpm_data_leaks_through_dlopen
+	Memcheck:Leak
+	...
+	fun:dlopen
+	...
+}

Modified: trunk/eda/fped/leakcheck
===================================================================
--- trunk/eda/fped/leakcheck	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/leakcheck	2009-08-21 18:20:37 UTC (rev 5514)
@@ -1,13 +1,4 @@
 #!/bin/sh
-#valgrind --leak-check=full --show-reachable=yes --suppressions=leak.supp \
-#  ./fped "$@"
-
-#
-# Seems that we can't suppress warnings from gtk_init, so we use FPED_NO_GUI
-# to avoid bringing up Gtk+ at all.
-#
-FPED_NO_GUI=y valgrind --leak-check=full --show-reachable=yes \
+valgrind --leak-check=full --show-reachable=yes --num-callers=50 \
+  --suppressions=leak.supp \
   ./fped "$@"
-
-#valgrind --leak-check=full --show-reachable=no \
-#  ./fped "$@"

Modified: trunk/eda/fped/meas.c
===================================================================
--- trunk/eda/fped/meas.c	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/meas.c	2009-08-21 18:20:37 UTC (rev 5514)
@@ -231,7 +231,6 @@
 	const struct meas *meas;
 	struct coord a0, b0;
 	lt_op_type lt;
-	struct num offset;
 
 	for (obj = root_frame->objs; obj; obj = obj->next) {
 		if (obj->type != ot_meas)
@@ -250,18 +249,8 @@
 			b0 = meas_find_max(lt,
 			    curr_pkg->samples[meas->high->n]);
 
-		if (!meas->offset)
-			offset.n = 0;
-		else {
-			offset = eval_unit(meas->offset, root_frame);
-			if (is_undef(offset)) {
-				instantiation_error = obj;
-				return 0;
-			}
-		}
 		inst_meas(obj,
-		    meas->inverted ? b0 : a0, meas->inverted ? a0 : b0,
-		    offset.n);
+		    meas->inverted ? b0 : a0, meas->inverted ? a0 : b0);
 	}
 	return 1;
 }

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c	2009-08-21 17:28:19 UTC (rev 5513)
+++ trunk/eda/fped/obj.c	2009-08-21 18:20:37 UTC (rev 5514)
@@ -94,10 +94,15 @@
 
 static int generate_objs(struct frame *frame, struct coord base, int active)
 {
+	static const struct num zero_offset = {
+		.type =	nt_mm,
+		.exponent = 0,
+		.n = 0,
+	};
 	struct obj *obj;
 	char *name;
 	int ok;
-	struct num width;
+	struct num width, offset;
 
 	for (obj = frame->objs; obj; obj = obj->next)
 		switch (obj->type) {
@@ -150,6 +155,12 @@
 				goto error;
 			break;
 		case ot_meas:
+			assert(frame == root_frame);
+			offset = eval_unit_default(obj->u.meas.offset, frame,
+			    zero_offset);
+			if (is_undef(offset))
+				goto error;
+			inst_meas_hint(obj, offset.n);
 			break;
 		default:
 			abort();




More information about the commitlog mailing list