[Openmcl-devel] Initializing an Obj-C class on the main thread?

Phil pbpublist at comcast.net
Mon Aug 14 21:05:27 PDT 2006


On Aug 14, 2006, at 9:45 PM, Gary Byers wrote:

> Note that the error message says that the QTMovie class must be  
> initialized
> on the main thread (it doesn't seem to be complaining about the  
> fact that
> you're trying to use a convenience method to allocate and  
> initialize an
> -instance- of that class.)
>
> Most classes get initialized implicitly (if they need any  
> initialization
> at all), and as far as I know, most classes don't care too much about
> what thread their +[init] method runs on.
>
> You might try doing something like:
>
> (ccl::send (ccl::@class "QTMovie")
>            :perform-selector-on-main-thread (ccl::@selector "init")
>            :with-object (ccl::%null-ptr)
>            :wait-until-done t)
>
> shortly after the framework that defines QTMovie (QTKit ?) is loaded.

Sorry... yes, this is QTKit.

>
>
> If that doesn't work, it might be necessary to ensure that the  
> framework
> gets loaded on the main thread.
>

I've tried all the permutations of this I could think of without  
success including loading the framework on the main thread  
immediately followed by by an attempt to call  
"init"/"initialize"/"movie" on the main thread (when each one failed,  
I quit out of OpenMCL and changed the selector to the next and tried  
again)

> The fact that you got the error after doing the
> :perform-selector-on-main-thread makes it sound like the first attempt
> (lazy or otherwise) to initialize the class happened on some secondary
> thread and left the class in a state where it couldn't be initialized.
> (Either that, or the :perform-selector message itself tried to  
> initialize
> the class, only to discover that it was still on the wrong thread.)
>
> Googing for 'QTMovie "main thread"' yielded a few dozen hits;  
> apparently,
> there are some subtle issues there.
>

It is definitely looking that way.  I'll keep poking around to see if  
I can find some code that programatically does what I'm attempting  
for more insight on what needs to happen.  Should I find the  
solution, I'll post a follow-up.



More information about the Openmcl-devel mailing list