• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Interthread Communication & Graphics Contexts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Interthread Communication & Graphics Contexts


  • Subject: Interthread Communication & Graphics Contexts
  • From: Buzz Andersen <email@hidden>
  • Date: Fri, 27 Sep 2002 13:52:17 -0600

Venerable Cocoa-gurus:
I am having a problem that is a bit beyond my current level of knowledge, and I was hoping someone here might be able to at least point me in the right direction about how to solve it.

Here is the scenario:

- The application I am working on is multithreaded--it has a main thread, and an additional thread used for a file copy operation.

- It also uses the NSWindow setContentView: method to change the window to a different view used to represent the status of the copy. When the copy is initiated, the view is switched, and then it is switched back to the main view after the copy is done.

- The copy method needs to update the GUI in the copy status view, and, since the AppKit is not thread safe, it uses an NSConnection to call methods that update the progress bar, status text and so forth.

Here is the problem:

Everything works as expected--the thread is detached, the copy proceeds successfully, the GUI is updated--but I get the following error:

*** Assertion failure in -[NSTableView lockFocus], AppKit.subproj/NSView.m:2343
lockFocus sent to a view whose window is deferred and does not yet have a corresponding platform window

The table view in question is part of my main view, which, of course, cannot have its focus locked for drawing since, at the time the copy happens, it is not part of a window. The interesting this is, if I change all of the NSConnection proxy method calls to direct calls using self, the problem does not occur. For example:

[proxy updateCopyStatusText: @"Testing"]; // THIS WILL CAUSE THE ERROR

[self updateCopyStatusText: @"Testing"]; // THIS WILL NOT CAUSE THE ERROR

I theorize that the problem is that the graphics context that my thread is using via NSConnection still thinks it needs to draw the main view, not the copy status view. Does this sound right, and would anyone be able to enlighten me as to the proper way to remedy this problem? It is not causing the application to malfunction in any visible way, but I would simply like to get rid of it!

As always, *any* level of help--suggestions on reading I should do, example code, whatever--would be most appreciated!

Thanks again!

--
Buzz Andersen
email: email@hidden
web: http://www.scifihifi.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Opening Documents at Unhide
  • Next by Date: Re: (newbie)cocoa and darwin 6.0....
  • Previous by thread: NSCursor Problem
  • Next by thread: What type of "thing" do I want?
  • Index(es):
    • Date
    • Thread