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

Gary Byers gb at clozure.com
Mon Aug 14 18:45:26 PDT 2006


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.


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

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.

On Mon, 14 Aug 2006, Phil wrote:

> I'm attempting to create a new QTMovie object but don't know quite
> how to accomplish it.  I attempted to create it with:
>
> (ccl::send (ccl::@class "QTMovie") "movie")
>
> and get an Obj-C error: QTMovie class must be initialized on the main
> thread.  So next I try:
>
> (ccl::send (ccl::@class "QTMovie")
> 					:perform-selector-on-main-thread (ccl::@selector "movie")
> 					:with-object nil
> 					:wait-until-done t)
>
> And get the same error.  So what is the correct way to accomplish this?
>
> Thanks,
> Phil
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list