mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-22 07:15:56 +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:
parent
9e7e804d1a
commit
94f4534494
2
TODO
2
TODO
@ -34,8 +34,6 @@ Bugs:
|
|||||||
- whenever we call parse_* for input parsing, we may leak lots of expressions
|
- whenever we call parse_* for input parsing, we may leak lots of expressions
|
||||||
- can't edit measurement labels through the GUI
|
- can't edit measurement labels through the GUI
|
||||||
- r of rpads is misleading, particularly if we have a circle
|
- 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:
|
Code cleanup:
|
||||||
- merge edit_unique with edit_name
|
- merge edit_unique with edit_name
|
||||||
|
5
fped.c
5
fped.c
@ -56,13 +56,10 @@ int main(int argc, char **argv)
|
|||||||
int error;
|
int error;
|
||||||
int batch_write_kicad = 0, batch_write_ps = 0;
|
int batch_write_kicad = 0, batch_write_ps = 0;
|
||||||
int c;
|
int c;
|
||||||
int have_gui = !getenv("FPED_NO_GUI");
|
|
||||||
|
|
||||||
if (have_gui) {
|
|
||||||
error = gui_init(&argc, &argv);
|
error = gui_init(&argc, &argv);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
}
|
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "kp")) != EOF)
|
while ((c = getopt(argc, argv, "kp")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -106,7 +103,7 @@ int main(int argc, char **argv)
|
|||||||
write_kicad();
|
write_kicad();
|
||||||
if (batch_write_ps)
|
if (batch_write_ps)
|
||||||
write_ps();
|
write_ps();
|
||||||
if (have_gui && !batch_write_kicad && !batch_write_ps) {
|
if (!batch_write_kicad && !batch_write_ps) {
|
||||||
error = gui_main();
|
error = gui_main();
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
13
gui.c
13
gui.c
@ -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)
|
static void make_top_bar(GtkWidget *vbox)
|
||||||
{
|
{
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
@ -248,5 +257,9 @@ int gui_main(void)
|
|||||||
|
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
|
gui_cleanup_style();
|
||||||
|
gui_cleanup_tools();
|
||||||
|
cleanup_tool_bar();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -74,3 +74,9 @@ void gui_setup_style(GdkDrawable *drawable)
|
|||||||
|
|
||||||
item_list_font = pango_font_description_from_string(ITEM_LIST_FONT);
|
item_list_font = pango_font_description_from_string(ITEM_LIST_FONT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void gui_cleanup_style(void)
|
||||||
|
{
|
||||||
|
pango_font_description_free(item_list_font);
|
||||||
|
}
|
||||||
|
@ -115,5 +115,6 @@ extern GdkGC *gc_frame[mode_n];
|
|||||||
extern PangoFontDescription *item_list_font;
|
extern PangoFontDescription *item_list_font;
|
||||||
|
|
||||||
void gui_setup_style(GdkDrawable *drawable);
|
void gui_setup_style(GdkDrawable *drawable);
|
||||||
|
void gui_cleanup_style(void);
|
||||||
|
|
||||||
#endif /* !GUI_STYLE_H */
|
#endif /* !GUI_STYLE_H */
|
||||||
|
10
gui_tool.c
10
gui_tool.c
@ -1044,3 +1044,13 @@ GtkWidget *gui_setup_tools(GdkDrawable *drawable)
|
|||||||
|
|
||||||
return bar;
|
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]);
|
||||||
|
}
|
||||||
|
@ -77,5 +77,6 @@ void tool_selected_inst(struct inst *inst);
|
|||||||
void tool_reset(void);
|
void tool_reset(void);
|
||||||
|
|
||||||
GtkWidget *gui_setup_tools(GdkDrawable *drawable);
|
GtkWidget *gui_setup_tools(GdkDrawable *drawable);
|
||||||
|
void gui_cleanup_tools(void);
|
||||||
|
|
||||||
#endif /* !GUI_TOOL_H */
|
#endif /* !GUI_TOOL_H */
|
||||||
|
37
inst.c
37
inst.c
@ -803,18 +803,28 @@ static struct inst_ops meas_ops = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int inst_meas(struct obj *obj,
|
static struct inst *find_meas_hint(const struct obj *obj)
|
||||||
struct coord from, struct coord to, unit_type offset)
|
{
|
||||||
|
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 inst *inst;
|
||||||
struct coord a1, b1;
|
struct coord a1, b1;
|
||||||
|
|
||||||
inst = add_inst(&meas_ops, ip_meas, from);
|
inst = find_meas_hint(obj);
|
||||||
inst->obj = obj;
|
assert(inst);
|
||||||
|
inst->base = from;
|
||||||
inst->u.meas.end = to;
|
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 */
|
/* @@@ we still need to consider the text size as well */
|
||||||
|
update_bbox(&inst->bbox, from);
|
||||||
update_bbox(&inst->bbox, to);
|
update_bbox(&inst->bbox, to);
|
||||||
project_meas(inst, &a1, &b1);
|
project_meas(inst, &a1, &b1);
|
||||||
update_bbox(&inst->bbox, a1);
|
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 ----------------------------------------- */
|
/* ----- direct editing of objects ----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
4
inst.h
4
inst.h
@ -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_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,
|
int inst_arc(struct obj *obj, struct coord center, struct coord start,
|
||||||
struct coord stop, unit_type width);
|
struct coord stop, unit_type width);
|
||||||
int inst_meas(struct obj *obj, struct coord from, struct coord to,
|
int inst_meas(struct obj *obj, struct coord from, struct coord to);
|
||||||
unit_type offset);
|
void inst_meas_hint(struct obj *obj, unit_type offset);
|
||||||
|
|
||||||
void inst_begin_active(int active);
|
void inst_begin_active(int active);
|
||||||
void inst_end_active(void);
|
void inst_end_active(void);
|
||||||
|
31
leak.supp
Normal file
31
leak.supp
Normal 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
|
||||||
|
...
|
||||||
|
}
|
13
leakcheck
13
leakcheck
@ -1,13 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#valgrind --leak-check=full --show-reachable=yes --suppressions=leak.supp \
|
valgrind --leak-check=full --show-reachable=yes --num-callers=50 \
|
||||||
# ./fped "$@"
|
--suppressions=leak.supp \
|
||||||
|
|
||||||
#
|
|
||||||
# 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 \
|
|
||||||
./fped "$@"
|
./fped "$@"
|
||||||
|
|
||||||
#valgrind --leak-check=full --show-reachable=no \
|
|
||||||
# ./fped "$@"
|
|
||||||
|
13
meas.c
13
meas.c
@ -231,7 +231,6 @@ static int instantiate_meas_pkg(void)
|
|||||||
const struct meas *meas;
|
const struct meas *meas;
|
||||||
struct coord a0, b0;
|
struct coord a0, b0;
|
||||||
lt_op_type lt;
|
lt_op_type lt;
|
||||||
struct num offset;
|
|
||||||
|
|
||||||
for (obj = root_frame->objs; obj; obj = obj->next) {
|
for (obj = root_frame->objs; obj; obj = obj->next) {
|
||||||
if (obj->type != ot_meas)
|
if (obj->type != ot_meas)
|
||||||
@ -250,18 +249,8 @@ static int instantiate_meas_pkg(void)
|
|||||||
b0 = meas_find_max(lt,
|
b0 = meas_find_max(lt,
|
||||||
curr_pkg->samples[meas->high->n]);
|
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,
|
inst_meas(obj,
|
||||||
meas->inverted ? b0 : a0, meas->inverted ? a0 : b0,
|
meas->inverted ? b0 : a0, meas->inverted ? a0 : b0);
|
||||||
offset.n);
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
13
obj.c
13
obj.c
@ -94,10 +94,15 @@ error:
|
|||||||
|
|
||||||
static int generate_objs(struct frame *frame, struct coord base, int active)
|
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;
|
struct obj *obj;
|
||||||
char *name;
|
char *name;
|
||||||
int ok;
|
int ok;
|
||||||
struct num width;
|
struct num width, offset;
|
||||||
|
|
||||||
for (obj = frame->objs; obj; obj = obj->next)
|
for (obj = frame->objs; obj; obj = obj->next)
|
||||||
switch (obj->type) {
|
switch (obj->type) {
|
||||||
@ -150,6 +155,12 @@ static int generate_objs(struct frame *frame, struct coord base, int active)
|
|||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case ot_meas:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
|
Loading…
Reference in New Issue
Block a user