a very weird bug


    May 19 2012 | 1:48 pm
    Hi.
    I'm struggling with a bug I can't locate. Hopefully it's totally trivial and I'm just overlooking something, so I'd love another pair of eyes to have a look at it...
    I have this UI object that behaves weirdly with respect to the classic r2l order of messaging. I stripped the object to the bare bones and made this dummy weirdbug object, but the problem is still there. What happens is that, in the patch below, when I click the message box [weirdbug] first receives a bang (on the left), and then the abc message (on the right). So my question is... WHY????? (I'm on a Mac, tried with both Max 5 and 6, and both the 5.1.7 and 6.0.4 SDKs)
    To reproduce the problem, you should save and reopen the patch (if you just paste it, everything works fine).
    Thanks!!!
    aa
    #include "ext.h"
    #include "ext_obex.h"
    #include "jpatcher_api.h"
    #include "jgraphics.h"
    typedef struct _weirdbug
    {
    t_jbox r_ob;
    void *m_inlet;
    } t_weirdbug;
    t_class *s_weirdbug_class = 0;
    t_weirdbug* weirdbug_new(t_symbol *s, long argc, t_atom *argv);
    void weirdbug_paint(t_weirdbug *x, t_object *view);
    void weirdbug_free(t_weirdbug *x);
    void weirdbug_anything(t_weirdbug *x, t_symbol *s, long argc, t_atom *argv);
    void weirdbug_bang(t_weirdbug *x);
    void weirdbug_bang(t_weirdbug *x)
    {
    object_post((t_object *) x, "bang!");
    }
    int main(void){
    t_class *c;
    c = class_new("weirdbug", (method)weirdbug_new, (method)weirdbug_free, sizeof(t_weirdbug), (method)NULL, A_GIMME, 0L);
    c->c_flags |= CLASS_FLAG_NEWDICTIONARY;
    jbox_initclass(c, 0);
    class_addmethod(c, (method) weirdbug_paint, "paint", A_CANT, 0);
    class_addmethod(c, (method) weirdbug_bang, "bang", 0);
    class_addmethod(c, (method) weirdbug_anything, "anything", A_GIMME, 0);
    s_weirdbug_class = c;
    class_register(CLASS_BOX, s_weirdbug_class);
    return 0;
    }
    void weirdbug_anything(t_weirdbug *x, t_symbol *s, long argc, t_atom *argv)
    {
    object_post((t_object *) x, "anything!");
    }
    t_weirdbug* weirdbug_new(t_symbol *s, long argc, t_atom *argv)
    {
    t_weirdbug* x = NULL;
    t_dictionary *d;
    long flags;
    if (!(d=object_dictionaryarg(argc,argv)))
    return NULL;
    x = (t_weirdbug*) object_alloc(s_weirdbug_class);
    flags = 0
    | JBOX_DRAWFIRSTIN
    | JBOX_NODRAWBOX
    | JBOX_DRAWINLAST
    // | JBOX_TRANSPARENT
    // | JBOX_NOGROW
    // | JBOX_GROWY
    | JBOX_GROWBOTH
    | JBOX_HILITE
    // | JBOX_BACKGROUND
    // | JBOX_TEXTFIELD
    // | JBOX_DRAWBACKGROUND
    // | JBOX_DEFAULTNAMES
    // | JBOX_MOUSEDRAGDELTA
    ;
    jbox_new(&x->r_ob, flags, argc, argv);
    x->r_ob.b_firstin = (t_object*) x;
    attr_dictionary_process(x,d);
    jbox_ready(&x->r_ob);
    x->m_inlet = inlet_new(x, NULL);
    return x;
    }
    void weirdbug_paint(t_weirdbug *x, t_object *view)
    {
    }
    void weirdbug_free(t_weirdbug *x)
    {
    jbox_free((t_jbox *) x);
    }
    `

    • May 19 2012 | 2:19 pm
      ok, got it... I was calling jbox_ready before creating my extra inlet!
      sorry for the moment of panic...
      aa
    • May 20 2012 | 4:33 pm
      so it doesn't work on your machine either... sometimes things make sense!