1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-12-22 12:53:19 +02:00

- 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)



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5514 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-21 18:20:37 +00:00
parent 9e7e804d1a
commit 94f4534494
13 changed files with 114 additions and 41 deletions

2
TODO
View File

@ -34,8 +34,6 @@ Bugs:
- 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

11
fped.c
View File

@ -56,13 +56,10 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
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;

13
gui.c
View File

@ -139,6 +139,15 @@ static void make_tool_bar(GtkWidget *hbox, GdkDrawable *drawable)
}
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 @@ int gui_main(void)
gtk_main();
gui_cleanup_style();
gui_cleanup_tools();
cleanup_tool_bar();
return 0;
}

View File

@ -74,3 +74,9 @@ void gui_setup_style(GdkDrawable *drawable)
item_list_font = pango_font_description_from_string(ITEM_LIST_FONT);
}
void gui_cleanup_style(void)
{
pango_font_description_free(item_list_font);
}

View File

@ -115,5 +115,6 @@ extern GdkGC *gc_frame[mode_n];
extern PangoFontDescription *item_list_font;
void gui_setup_style(GdkDrawable *drawable);
void gui_cleanup_style(void);
#endif /* !GUI_STYLE_H */

View File

@ -1044,3 +1044,13 @@ GtkWidget *gui_setup_tools(GdkDrawable *drawable)
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]);
}

View File

@ -77,5 +77,6 @@ void tool_selected_inst(struct inst *inst);
void tool_reset(void);
GtkWidget *gui_setup_tools(GdkDrawable *drawable);
void gui_cleanup_tools(void);
#endif /* !GUI_TOOL_H */

37
inst.c
View File

@ -803,18 +803,28 @@ static struct inst_ops meas_ops = {
};
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 @@ int inst_meas(struct obj *obj,
}
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 ----------------------------------------- */

4
inst.h
View File

@ -164,8 +164,8 @@ int inst_rect(struct obj *obj, struct coord a, struct coord b, unit_type width);
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);

31
leak.supp Normal file
View File

@ -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
...
}

View File

@ -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 "$@"

13
meas.c
View File

@ -231,7 +231,6 @@ static int instantiate_meas_pkg(void)
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 @@ static int instantiate_meas_pkg(void)
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;
}

13
obj.c
View File

@ -94,10 +94,15 @@ error:
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 @@ static int generate_objs(struct frame *frame, struct coord base, int active)
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();