sandboxed app and image not loading

Hi All,

I have an image editing app (for photoshop) which works fine and now I am trying to sandbox it for MAS and all is good except for the image well.

There is a text field that , when an image is dropped on it, triggers a routine to get the image info and place image in the image well.

on applicationWillFinishLaunching_(aNotification)
         my UpdateImageInfo_(my sourcePath as text)
end applicationWillFinishLaunching_

on controlTextDidChange_(Notification)
 my UpdateImageInfo_(my filePath as text)
 end controlTextDidChange_

on UpdateImageInfo_(filePath)
log filePath
set newImage to NSImage's alloc()'s initWithContentsOfFile_(filePath as text)
log newImage
theimageField's setImage_(newImage)
newImage's release()
end UpdateImageInfo_(filePath)

This always works when an image is dropped and triggers controlTextDidChange_(Notification). The field updates as expected.

At launch time the same routine is run, the path is passed ok but the image returned is null. This only happens in the sandbox - it works fine at launch without sandbox.

Just to test this I added a button which triggers the routine and pass it a valid path string. The image returns null every time, unless I have already dropped that image once on the text field ( which always works! ) and then the test will work after that. It is as if the image is not loaded yet and the only way is via the drop.

Hope this makes sense - I’ve spent hours trying to make this work in sandbox. Any thoughts appreciated.

I have the appropriate entitlements for applescript and read/write files etc. maybe am missing one?

best, Rob

I may be way off base – I don’t use sandboxing – but my impression is that you can use file paths like that. You need to use URLs, and they have to be chosen by the user somehow.

I’ll try URL’s and I think you may be right about the User. Oddly though, when I drop the file on the text field, it works, but when the text field is set from the open dialog it doesn’t.

More research. Also I am finding the open dialogs are not working - they often log “user canceled” and the dialog doesn’t show up. After a few tries it does.

Cheers, Rob :slight_smile:

Hi Shane et all,

Well, I have tried every possible way to get an image in the sandbox (sand pit?) and it looks like you were correct - you can not set an image programmatically in that environment unless it goes via an open dialog or drag and drop. I don’t understand this really since both end up doing the same thing:

set newImage to NSImage's alloc()'s initWithContentsOfFile_(filePath as text) 
theImageField's setImage_(newImage)
newImage release()

One gets the filePath programmatically from the text field, the other from the dialog or drop. Somehow the latter methods make the transaction ok in the end.

I did try initWithContentsOfURL with exactly the same results. Also I tried doing everything from OBJ-c classes and same there too.

If anyone has worked with sandbox and these issues ( or others ) I would love to hear. For now I will submit to MAS without sandbox before the deadline for mandatory sandboxing in June.

There are other things too. The open dialog ( in sandbox) fails to work on the first, and sometimes second, attempt. Has anyone else seen this. It feels buggy. I will try to report/get help from ADC next.

Cheers, Rob

I suspect t relates to how sandboxing can tell where something came from. Presumably a URL carries some extra info around with it, which can’t happen with a simple string.

I’ve seen reports of something like this.