diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 2fac3814bb60f68f80bc1c492a38f03fe8e9bea2..3dbd39a0a4304d1df13b39c690dd6dbd99cce42e 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -5664,26 +5664,13 @@ static int glist_dofinderror(t_glist *gl, void *error_object) return (0); } -extern t_class *messresponder_class; -extern t_class *message_class; void canvas_finderror(void *error_object) { t_canvas *x; - void *error_gobj = error_object; - /* Since the messresponder_class isn't patchable, - we climb up to the parent message_class addy. */ - if(((t_gobj *)error_object)->g_pd == messresponder_class) - { - /* do pointer math to potentially get the parent message */ - void *msg = error_object - sizeof(t_text); - /* if it looks like a message, it must be a message */ - if(((t_gobj *)msg)->g_pd == message_class) - error_gobj = msg; - } /* find all root canvases */ for (x = canvas_list; x; x = x->gl_next) { - if ((void *)x == error_gobj) + if ((void *)x == error_object) { /* If the error is associated with a toplevel canvas, we do a quick-and-dirty unvis and vis to give some basic @@ -5693,7 +5680,7 @@ void canvas_finderror(void *error_object) canvas_vis(glist_getcanvas(x), 1); return; } - if (glist_dofinderror(x, error_gobj)) + if (glist_dofinderror(x, error_object)) return; } post("... sorry, I couldn't find the source of that error."); diff --git a/pd/src/g_text.c b/pd/src/g_text.c index de4a74331a47599cfc5fef2e809d27951d7bde01..c2f033be9c7789f06a00bf3cadd006dce650296f 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -530,7 +530,7 @@ typedef struct _message t_clock *m_clock; } t_message; -t_class *messresponder_class; +static t_class *messresponder_class; static void messresponder_bang(t_messresponder *x) { @@ -687,6 +687,19 @@ static void message_free(t_message *x) clock_free(x->m_clock); } +t_pd *pd_mess_from_responder(t_pd *x) +{ + if (pd_class(x) == messresponder_class) + { + /* do pointer math to try to get to the container message struct */ + void *tmp = (void *)x - sizeof(t_text); + /* if it looks like a message, it must be a message */ + if(((t_text *)tmp)->te_pd == message_class) + return ((t_pd *)tmp); + } + return x; +} + void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv) { if (canvas_hasarray(gl)) return; diff --git a/pd/src/m_class.c b/pd/src/m_class.c index eff96296c752c53ae70aaaddb543156d38271886..0000d5f98ea62ddfacd415bcb8e1f6aa6a23fbb7 100644 --- a/pd/src/m_class.c +++ b/pd/src/m_class.c @@ -689,6 +689,9 @@ typedef t_pd *(*t_fun5)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, typedef t_pd *(*t_fun6)(t_int i1, t_int i2, t_int i3, t_int i4, t_int i5, t_int i6, t_floatarg d1, t_floatarg d2, t_floatarg d3, t_floatarg d4, t_floatarg d5); +/* needed for proper error reporting */ +extern t_pd *pd_mess_from_responder(t_pd *x); + void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv) { t_method *f; @@ -849,6 +852,10 @@ void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv) (*c->c_anymethod)(x, s, argc, argv); return; badarg: + /* if x is a messresponder class, tweak it to point to the + message that contains it (so it can be selected when 'Find + Error' is used). */ + x = pd_mess_from_responder(x); pd_error(x, "Bad arguments for message '%s' to object '%s'", s->s_name, c->c_name->s_name); }