problem at object init
One of my externals (called "virtualfund") exhibits a strange behaviour when I first load it:
- If I open a patch containing the object, I get a "virtualfund: No such object". If, subsequently, I try to type it in the same patch, I get the same error. Then, if I type it in a new patch, it loads, and from now on I am able to load it in the first patch as well.
- If I type it in a new patch at first, it loads – and then I am able to correctly open a patch that contains it.
- If I load it manually, everything goes fine.
The external is in the same folder as all my other externals, which all load seamlessly.
I would guess the problem lies somewhere in the main function, but main itself is very simple and not different at all from my other externals’. The class name is correct in the class_new call… I am puzzled!
Any ideas about that?
Make sure that the object call class_register at the end of main()… or send me the external ;-)
Thank you guys…
@ej: yes, the class_register call is there indeed… more coming soon! ;)
@pizza: the code is quite long and somewhat garbled – moreover, there’s a quite clever algorithm inside, which I borrowed from a lisp thing by a friend of mine, so I don’t feel like posting it on the forum.
but here is a stripped-out version of main(), in case I am missing something evident. (it’s stripped out because I removed a long list of attribute declarations, but it doesn’t work anyway!)
c = class_new("virtualfund", (method)virtualfund_new, (method)virtualfund_free, (long)sizeof(t_virtualfund), 0L, 0);
class_addmethod(c, (method) virtualfund_int, "int", A_LONG, 0);
class_addmethod(c, (method) virtualfund_bang, "bang", 0);
class_addmethod(c, (method) virtualfund_list, "list", A_GIMME, 0);
class_addmethod(c, (method) virtualfund_assist, "assist", A_CANT, 0);
virtualfund_class = c;
post("virtualfund object instantiated");
but the thing is, if I try to debug it in Xcode it doesn’t even enter main()… and no, I have nothing else called "virtualfund" in my search path :(
I have an old testing patch that works perfectly when opened.
But if I create a new patch with only a [virtualfund] inside, I save it, close max, reopen max and load the patch, the object is gray and I have the error message.
(the declarations of the object in the two .maxpat files look pretty similar…)
You have a missing argument in your
c = class_new("virtualfund", (method)virtualfund_new, (method)virtualfund_free, (long)sizeof(t_virtualfund), 0L, A_GIMME, 0);
If that’s not the case… just send me the thing offline…
No, it’s not its fault.
Actually, A_GIMME was there, but since the object accepts no arguments I tried to remove it to see if anything changed… which didn’t…
thank you anyway!
Is your Xcode project based off of one of the example Xcode projects in the SDK? Are you absolutely certain that you spelled "virtualfund" in the class definition spelled exactly the same way as "virtualfund.mxo"?
The searchpath can be a funny thing. Did you add the folder with your Xcode project in it to your searchpath. There are lots of things with the name of your object buried in the build folders that will conflict with your mxo when Max tries to load them.
I guess the problem was in the Xcode project settings – in fact I realize that I had made an ugly mix of things from different versions of the SDK.
I made a new project, named it "virtfund" (even nicer, in fact!), changed what had to be changed in the source and now it works like a charm.
Thanks to everyone!
Forums > Dev