Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tom Davie
On 17 Dec 2012, at 05:58, Tamas Nagy tamas.lov.n...@gmail.com wrote: It's a live video app, where rendering happening on a CVDisplayLink thread, so the app still running and do its job while an OpenPanel (or SavePanel) displaying. I just need to block the UI to make sure the users can't

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tamas Nagy
I really appreciate your continuous curiosity guys, but we just getting off-topic :) BTW, its a realtime graphics application, where UI events should not blocking rendering. Think about a concert where some videos projected behind the band, it would be bad if opening the next video - putting

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tom Davie
On 17 Dec 2012, at 09:26, Tamas Nagy tamas.lov.n...@gmail.com wrote: I really appreciate your continuous curiosity guys, but we just getting off-topic :) BTW, its a realtime graphics application, where UI events should not blocking rendering. Think about a concert where some videos

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tamas Nagy
The user is still able to control things like fading with a MIDI/OSC controller - they definitely do not do that with mouse. But there are things which only controllable with the UI, deleting layers for example. And there are some circumstances - for example, loading a whole project, where the

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tom Davie
On 17 Dec 2012, at 09:42, Tamas Nagy tamas.lov.n...@gmail.com wrote: The user is still able to control things like fading with a MIDI/OSC controller - they definitely do not do that with mouse. But there are things which only controllable with the UI, deleting layers for example. And there

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tamas Nagy
There is a chance in the application where only one, borderless window displayed on the secondary screen, so there are possible circumstances where displaying a window-modal panel not quite useful. On Dec 17, 2012, at 10:50 AM, Tom Davie tom.da...@gmail.com wrote: On 17 Dec 2012, at

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tom Davie
On 17 Dec 2012, at 10:11, Tamas Nagy tamas.lov.n...@gmail.com wrote: There is a chance in the application where only one, borderless window displayed on the secondary screen, so there are possible circumstances where displaying a window-modal panel not quite useful. Okay, but your example

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tamas Nagy
Yep, its a design bug for sure, which I should and will fix. On Dec 17, 2012, at 11:14 AM, Tom Davie tom.da...@gmail.com wrote: On 17 Dec 2012, at 10:11, Tamas Nagy tamas.lov.n...@gmail.com wrote: There is a chance in the application where only one, borderless window displayed on the

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Sean McBride
On Sun, 16 Dec 2012 21:46:14 -0800, Kyle Sluder said: Thanks Kyle. I know about beginWithCompletionHandler: , but I really need a modal window at that point my application opens the open panel. I have to ask, why? Sometimes it's appropriate. Apple seems to think so, as File Open shows a

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Sean McBride
On Sun, 16 Dec 2012 11:45:29 +0100, Tamas Nagy said: I'm trying to display an NSOpenPanel on a dispatch, with half-luck. The panel displays, but no files going to be displayed - the circle just spinning on the bottom-left corner. Anyone have an idea what going wrong? Others have explained what's

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Mike Abdullah
On 17 Dec 2012, at 17:15, Sean McBride s...@rogue-research.com wrote: On Sun, 16 Dec 2012 21:46:14 -0800, Kyle Sluder said: Thanks Kyle. I know about beginWithCompletionHandler: , but I really need a modal window at that point my application opens the open panel. I have to ask, why?

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Kyle Sluder
On Mon, Dec 17, 2012, at 03:15 PM, Mike Abdullah wrote: On 17 Dec 2012, at 17:15, Sean McBride s...@rogue-research.com wrote: On Sun, 16 Dec 2012 21:46:14 -0800, Kyle Sluder said: Thanks Kyle. I know about beginWithCompletionHandler: , but I really need a modal window at that point

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Sean McBride
On Mon, 17 Dec 2012 23:15:15 +, Mike Abdullah said: For what it's worth, OS X v10.8 Mountain Lion finally fixes this by making open panels non-modal. I think apps do need to be built against the new SDK for it, rather than automatically switching over to such behaviour. In in 10.8.2 now, and

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Kyle Sluder
On Mon, Dec 17, 2012, at 03:25 PM, Sean McBride wrote: On Mon, 17 Dec 2012 23:15:15 +, Mike Abdullah said: For what it's worth, OS X v10.8 Mountain Lion finally fixes this by making open panels non-modal. I think apps do need to be built against the new SDK for it, rather than

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Mike Abdullah
On 17 Dec 2012, at 23:29, Kyle Sluder k...@ksluder.com wrote: On Mon, Dec 17, 2012, at 03:25 PM, Sean McBride wrote: On Mon, 17 Dec 2012 23:15:15 +, Mike Abdullah said: For what it's worth, OS X v10.8 Mountain Lion finally fixes this by making open panels non-modal. I think apps do

Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Charles Srstka
On Dec 17, 2012, at 5:29 PM, Kyle Sluder k...@ksluder.com wrote: On Mon, Dec 17, 2012, at 03:25 PM, Sean McBride wrote: On Mon, 17 Dec 2012 23:15:15 +, Mike Abdullah said: For what it's worth, OS X v10.8 Mountain Lion finally fixes this by making open panels non-modal. I think apps do

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Tom Davie
On 16 Dec 2012, at 10:45, Tamas Nagy tamas.lov.n...@gmail.com wrote: Hey, I'm trying to display an NSOpenPanel on a dispatch, with half-luck. The panel displays, but no files going to be displayed - the circle just spinning on the bottom-left corner. Anyone have an idea what going wrong?

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Tamas Nagy
Thanks for the suggestions Tom. I know about that things, but the original code was a bit bigger, where I need a mutable array and other stuff, and just trimmed out for the example. But to back to on-topic: the code works fine on 10.6.8, the issue happens only on 10.7.5 and 10.8.2. If I call

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Mike Abdullah
On 16 Dec 2012, at 10:45, Tamas Nagy wrote: Hey, I'm trying to display an NSOpenPanel on a dispatch, with half-luck. The panel displays, but no files going to be displayed - the circle just spinning on the bottom-left corner. Anyone have an idea what going wrong? Thanks, Tamas

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Tamas Nagy
Unfortunately that doesn't help. I think the issue should be related to dispatches, because it won't happen if I just call performSelectorOnMainThread... On Dec 16, 2012, at 6:05 PM, Mike Abdullah cocoa...@mikeabdullah.net wrote: On 16 Dec 2012, at 10:45, Tamas Nagy wrote: Hey, I'm

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Kyle Sluder
On Dec 16, 2012, at 2:45 AM, Tamas Nagy tamas.lov.n...@gmail.com wrote: dispatch_async(dispatch_get_main_queue(), ^{ NSOpenPanel *oPanel = [NSOpenPanel openPanel]; *Bzzt!* Thou shalt not do UI work on a background thread. You cannot use dispatch_async here. --Kyle Sluder

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Mike Abdullah
On 16 Dec 2012, at 18:32, Kyle Sluder wrote: On Dec 16, 2012, at 2:45 AM, Tamas Nagy tamas.lov.n...@gmail.com wrote: dispatch_async(dispatch_get_main_queue(), ^{ NSOpenPanel *oPanel = [NSOpenPanel openPanel]; *Bzzt!* Thou shalt not do UI work on a background thread. You

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Mike Abdullah
On 16 Dec 2012, at 17:20, Tamas Nagy wrote: Unfortunately that doesn't help. I think the issue should be related to dispatches, because it won't happen if I just call performSelectorOnMainThread... Can you post that variant of your code then, please?

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Kyle Sluder
On Dec 16, 2012, at 10:39 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote: On 16 Dec 2012, at 18:32, Kyle Sluder wrote: On Dec 16, 2012, at 2:45 AM, Tamas Nagy tamas.lov.n...@gmail.com wrote: dispatch_async(dispatch_get_main_queue(), ^{ NSOpenPanel *oPanel = [NSOpenPanel

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Kyle Sluder
On Sun, Dec 16, 2012, at 10:40 AM, Mike Abdullah wrote: On 16 Dec 2012, at 17:20, Tamas Nagy wrote: Unfortunately that doesn't help. I think the issue should be related to dispatches, because it won't happen if I just call performSelectorOnMainThread... Can you post that variant

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Kyle Sluder
On Sun, Dec 16, 2012, at 11:28 AM, Kyle Sluder wrote: My guess is that NSOpenPanel is doing some work on a background thread, and that work is trying to use the main queue to inform the open panel of its completion. By using the dispatch_async approach, the main queue is blocked, and the

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Tamas Nagy
Thanks for the approach Kyle, but dispatch_async performs asynchronously, so it should not block the main thread. I fallback to performSelectorOnMainThread: method in my app, but the dispatch way is a bit straightforward in my opinion. I'll fill a rdar on this. On Dec 16, 2012, at 8:39 PM,

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Tom Davie
Performing asynchronously and blocking the main *queue* are not related things. The main queue is a serial queue, it only executes one block at a time. At the moment, it's executing your block, stuck in your runModal call. That runModal call will not come off the stack, and the block finish

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Tamas Nagy
Ahh, okay, thanks for the explanation Tom, now I got it. On Dec 16, 2012, at 9:21 PM, Tom Davie tom.da...@gmail.com wrote: Performing asynchronously and blocking the main *queue* are not related things. The main queue is a serial queue, it only executes one block at a time. At the

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Kyle Sluder
On Sun, Dec 16, 2012, at 12:04 PM, Tamas Nagy wrote: Thanks for the approach Kyle, but dispatch_async performs asynchronously, so it should not block the main thread. I fallback to performSelectorOnMainThread: method in my app, but the dispatch way is a bit straightforward in my opinion. I'll

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Kyle Sluder
On Sun, Dec 16, 2012, at 12:04 PM, Tamas Nagy wrote: Thanks for the approach Kyle, but dispatch_async performs asynchronously, so it should not block the main thread. I fallback to performSelectorOnMainThread: method in my app, but the dispatch way is a bit straightforward in my opinion. I'll

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Mike Abdullah
On 16 Dec 2012, at 20:04, Tamas Nagy wrote: Thanks for the approach Kyle, but dispatch_async performs asynchronously, so it should not block the main thread. I fallback to performSelectorOnMainThread: method in my app, but the dispatch way is a bit straightforward in my opinion. I'll fill

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Rob Petrovec
On Dec 16, 2012, at 9:05 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote: On 16 Dec 2012, at 10:45, Tamas Nagy wrote: Hey, I'm trying to display an NSOpenPanel on a dispatch, with half-luck. The panel displays, but no files going to be displayed - the circle just spinning on the

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Tamas Nagy
Thanks Kyle. I know about beginWithCompletionHandler: , but I really need a modal window at that point my application opens the open panel. On Dec 16, 2012, at 9:39 PM, Kyle Sluder k...@ksluder.com wrote: On Sun, Dec 16, 2012, at 12:04 PM, Tamas Nagy wrote: Thanks for the approach Kyle, but

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Kyle Sluder
On Sun, Dec 16, 2012, at 09:43 PM, Tamas Nagy wrote: Thanks Kyle. I know about beginWithCompletionHandler: , but I really need a modal window at that point my application opens the open panel. I have to ask, why? If you want to block interaction with a document, you can use

Re: NSOpenPanel runModal on a dispatch

2012-12-16 Thread Tamas Nagy
It's a live video app, where rendering happening on a CVDisplayLink thread, so the app still running and do its job while an OpenPanel (or SavePanel) displaying. I just need to block the UI to make sure the users can't interact the app while an open panel displaying. On Dec 17, 2012, at 6:46