ApplicationCommandTarget & manager problems

Hi…
I got a problem with ApplicationCommandTarget and ApplicationCommandManager…
Here is the situation:

  • There’s one of the main components of my app (called A) that inherits from ApplicationCommandTarget and all gone well (its commands work fine); in this component, there’s a command that create another component (called B) that inherits from ApplicationCommandTarget too; after creating this child, it (A) use “registerAllCommandsForTarget” to register its commands.

  • Compiling it’s ok but when I run the application and use the command to create the child (B) the app crashes…
    All the virtual methods are implemented in the same way… so I don’t know why A works and B not!!!
    (if i leave B::getAllCommands (…) empty it runs but, of course, its commands don’t work).

Maybe I’m missing something stupid but I don’t know.

Thanks to everybody.

Well surely you can debug the crash and find out what’s going on? Probably just a dangling pointer or something.

Yes Jules… I’ve already debugged the code and it crash when trying to add new commandId to the commands array ( getAllCommands(…) ) …
I don’t know but i’m continuing with the debug… if you have any issue you are kind and welcome!
thanks

Debugging crash here:

const ApplicationCommandInfo* ApplicationCommandManager::getCommandForID (const CommandID commandID) const throw()
{
    for (int i = commands.size(); --i >= 0;)               <===== this line
        if (commands.getUnchecked(i)->commandID == commandID)
            return commands.getUnchecked(i);

    return 0;
}

errors with (unknown): this->keyMappings, this->firstTarget, this->commands…

what i miss?

basic c++ tip - if all the members of your object seem to be garbage, you’re probably calling a method on a dangling or null pointer.

You might want to post the code that creates the B object. When I run into this, I’ve generally done some bonehead and my object is being deleted at the end of it’s scope.

To see, put a breakpoint in the B object’s destructor. See if it gets called before A gets the commandIDs (or before you use it).

Bruce