can't create print object with object_new_typed

Jan 20, 2012 at 10:34am

can't create print object with object_new_typed

Hi.

I need to create a print object from within my external, and I’m trying to do it with object_new_typed.

What I found out is that if I try to instantiate it after a print has been created in a Max patch (because I typed it in, or because I have loaded a patch containing one) everything is fine. But if no print object has been instantiated before, then object_new_typed returns NULL.

I suspect this has to do with print being an internal object, and somehow its class not being correctly initialized by object_new_typed – I think I had already met this problem before…

… what can I do???

Thanks!
aa

#61354
Jan 20, 2012 at 11:48am

I just found this

http://cycling74.com/forums/topic.php?id=24483

in fact, instantiating my print object with newinstance() seems to work. I’m not sure this won’t generate problems, though… any advice?

aa

#221189
Jan 20, 2012 at 7:53pm

I just updated the link in that post, but here it is for convenience:

https://github.com/jamoma/JamomaModular/blob/master/library/source/jcom.core.cpp#L159

#221190
Jan 21, 2012 at 10:06am

Hi Tim.

Thank you for the link.

What I’m not sure of is why you need to instantiate the object with newinstance, then free it, and then re-instantiate it with object_new_typed. It is not that important, as long as things work ;) , but I’d like to understand more…

Thank you!
aa

#221191
Jan 23, 2012 at 3:42pm

To be honest, I wrote that code 10 years ago and I don’t really remember why it is like that. I vaguely recall that I had to do that to make it work, but I was pretty inexperienced and wasn’t really sure what I was doing at that point. Sorry for the less-than-substantial answer on this one. At any rate, I do know that the code works and I haven’t had any problems with it.

#221192

You must be logged in to reply to this topic.