jpatcher_get_parentpatcher()


    Jan 14 2009 | 10:45 pm
    Hi all,
    I'm having some trouble getting information about the parentpatcher of an object in a subpatcher.
    If I have an object in a subpatcher or an abstraction and it calls jpatcher_get_parentpatcher(), I get a NULL pointer. However, if I open the subpatcher window and instantiate the object again, I get the parentpatcher's address.
    Code:
    t_patcher *patcher, *ppatcher;
    t_box *box;
    object_obex_lookup(x, gensym("
    Output for a normal object in the top level patcher:
    patcher address: 0x18589ff0
    patcher name: cmmjl_test.maxhelp
    box = 0x0
    parent address: 0x0
    Output for an object in an abstraction called 'abstraction':
    patcher address: 0x185a6fe0
    patcher name: abstraction
    box = 0x0
    parent address: 0x0
    Output for an object in a subpatcher called 'foo':
    patcher address: 0x185be660
    patcher name:
    box = 0x0
    parent address: 0x0
    When I open the subpatcher called 'foo' and make a copy of the object with the window open, everything works fine:
    patcher address: 0x185be660
    patcher name: foo
    box = 0x185e0bc0
    parent address: 0x18589ff0
    Any thoughts on this? Is it that I'm doing something wrong or is there a bug in jpatcher_get_parentpatcher()? I'd really appreciate any suggestions about how to do this properly or, if indeed it is a bug, a possible workaround.
    Thanks in advance,
    JM

    • Jan 14 2009 | 11:03 pm
      On Jan 14, 2009, at 2:46 PM, John MacCallum wrote:
      > I'm having some trouble getting information about the parentpatcher
      > of an object in a subpatcher.
      Sounds like you might be calling this in your object constructor,
      before the patcher has finished loading (and before these patcher
      attributes have been set). You'll need to cache #P in your constructor
      and then call after the object has been instantiated (say in loadbang,
      or response to a bang message, etc.).
      -Joshua
    • Jan 15 2009 | 8:57 pm
      That was it--thanks Joshua!
      JM