DRBurn.progressPanel in Swift

Hi,


I'm struggling with the Disk Recording documentation and at the moment I can't find a Swift equivalent of

DRBurnProgressPanel* a_panel = [DRBurn progressPanel];


I'm assuming that this would return a default, OSX version of a progress panel, similar to:


let setup_panel: DRBurnSetupPanel = DRBurnSetupPanel()


Which provides an entire setup panel with which to start a burn.


I've tried


let prog_panel: DRBurnProgressPanel = DRBurnProgressPanel.init()

and

let prog_panel: DRBurnProgressPanel = DRBurnProgressPanel()


But both create an empty view. Can anyone help?

Accepted Reply

And that solved it: I wrote a bridging class in Obj-C with the equivalent code and a progress sheet appeared as normal. It must be a Swift bug...

Replies

>> I'm assuming that this would return a default, OSX version of a progress panel, similar to […] Which provides an entire setup panel with which to start a burn.


This assumption isn't quite correct, according to the header file, if you mean what you appear to say. The object you get back from the initializer:


let prog_panel: DRBurnProgressPanel = DRBurnProgressPanel()


isn't something you display yourself. Instead, when you invoke 'beginProgressPanelForBurn…' or 'beginProgressSheetForBurn…', this both displays the panel and starts the burn. It sounds like you're trying to display the panel "manually" before starting the burn, and that's not the API.

Thanks Quincey,


I'm using


prog_panel.beginProgressSheetForBurn(burner, layout: vDRTrack, modalForWindow: self.window)



the burn completes just fine but the progress panel is a white square block.

Is there any chance that:


a. You're doing this (beginning the burn) from a thread other than the main thread, or


b. Regardless of where you're starting it from, you subsequently block the main thread waiting for the burn to finish?


Either of those things could prevent the sheet from updating properly.

a. Yes, I dispatch_async to do calculations and file organising then that thread dispatches a block synchromously to the main thread to do the burn setup panel and burn progress. So the background thread that passes it on is effectively blocked. I've tried also dispatch_async for the burn setup and progress with the same result.


b. No, the main thread does the dispatch_async mentioned above in response to a user click and that's the last bit of code in the @IBAction method.


Thanks!

Sorry I missed seeing your reply immediately.


I'm not sure, but I think you described every part of the sequence except the one I was concerned about: what does the main thread do immediately after it calls beginProgressSheetForBurn?


This call is itself in a block dispatched by the worker thread (according to your first sentence. If this block then immediately exits (return or falling off the end), then the main thread isn't blocked. However, if there's code in that block (or anywhere else that executes on the main thread) that waits for the burn to complete in a blocking manner, then the main thread will be blocked.


I'm guessing that you don't have any blocking code that does a wait, but it's worth asking the question.

No problem; I didn't expect an answer on a Saturday! Sorry, i wrote too much information to be clear. No, I don't believe the threads - main or otherwise - are being blocked. And the burn progress panel is being called on the main thread by a dispatch_async from a background one. The next stage will be to try either a re-write so that the background thread notifies the main that it can go ahead and burn so that there's no doubt it's being called in the standard way (although that shouldn't be any different to what I have now). Or - my preferred theory at the moment - is that this has been forgotten in the Swift library and I'll write a small, bridging class in obj-c that does the burn ui setup and presentation. Actually perhaps a mixture of the two would be best: notify main thread to call bridging class methods... I'm not at the project until Tuesday now but I'll post the results. Ta!

Can't edit on my iPhone: I downloaded the example DRBurn code and it worked fine. The only two differences are that the example has no other threads beside the main one and it's written in obj-c. If I get as close to that as I can with my app then I think it'll work.

And that solved it: I wrote a bridging class in Obj-C with the equivalent code and a progress sheet appeared as normal. It must be a Swift bug...

And you'll submit a bug report, won't you? 😉


I won't have to convert my DRBurn code to Swift for a couple of months at least. It would be nice if Apple was aware of the problem before I got stuck too.

yup, will do.

I'm running into the same issue... before I spend all day re-inventing the wheel, how much of your code did you put in ObjC? The whole view controller? Just the part that sets up the progress panel?