Open picture from iPhoto: crash?

My app has a browse for image option.
Users are navigating to iPhoto and trying to open what LOOK like image there.
But instead of opening as a picture, the app crashes with a message about
Common\runFolderItem.cpp:572
condition: entry->mimp

So, two questions:
a) Since OSX seems intent on showing a list of ‘photos’ in a Finder folder called ‘Photos’, people will keep trying to open them. How can I turn that folder item into ‘the actual picture’?

b) Why does the openaspicture code crash instead of just returning nil?

Try

dim p as picture = picture.open( folderitem )

[quote=56409:@Jeff Tullin]My app has a browse for image option.
Users are navigating to iPhoto and trying to open what LOOK like image there.
But instead of opening as a picture, the app crashes with a message about
Common\runFolderItem.cpp:572
condition: entry->mimp

So, two questions:
a) Since OSX seems intent on showing a list of ‘photos’ in a Finder folder called ‘Photos’, people will keep trying to open them. How can I turn that folder item into ‘the actual picture’?

b) Why does the openaspicture code crash instead of just returning nil?[/quote]

How are you creating the FolderItem that you’re passing to OpenAsPicture? And is this in 2013r4.1?

Its been a problem in all versions of RB I have used at least as far back as 2012
Im currently using 2013 R2 something for production work: haven’t downloaded 4.1 yet

I display a file open dialog.

Dim dlg as OpenDialog dlg=New OpenDialog dlg.InitialDirectory=specialfolder.pictures f=dlg.ShowModal() If f <> Nil then //proceed normally Else exit sub End if

Since the user has browsed for the file, I assumed it must exist.
In fact, if a picture from ‘Photos’ is chosen, f.exists is false.

So I could display a message saying ‘that file doesn’t exist’
But since it plainly does (I just chose it myself), that message won’t wash with customers.

f.absolutepath is empty.
f.parent is nil

and trying to view the properties of f causes Xojo to crash.

Carbon or Cocoa?

cocoa

No permission to read in that folder ?

Im the administrator user.
But unlike Library, which OSX now hides, this folder is clearly visible and a normal part of the open dialog on the left side.
Oddly, its not part of the normal Finder window.
This Photos/iPhoto section appears to be only visible when an OpenDialog is displayed.

Interestingly I found this discussion from a few years ago, arguing that people SHOULD be allowed to see that folder from an Open Dialog:

https://discussions.apple.com/thread/625538

And this one:
https://discussions.apple.com/thread/3295964

It seems that what is being exposed via ‘Media’ is a list of pictures that iPho has stored in a database.

Lots of hmmmm.

So , different questions:

a) Is there a way to stop the Media option appearing in OpenDialog?
b) Is there a way to ‘call’ iPhoto and ask it for a picture, in the manner you might with OLE on a PC?

AppleScript ?

I never used iPhoto, so I do not know. Check in its AppleScript Dictionary whats there…

I have solutions.

Firstly, this only happens with images known to iPhoto but not yet thumb nailed by iPhoto. (?)
(Showing as blank white sheets)
These images give an error about iPhoto updating when accessed through Finder.

So after iPhoto starts showing an image, they are OK and don’t cause a crash.

Second, switching to OpenDialogMBS works around the problem, because the OPEN button is not enabled on any of these blank images that would have caused the crash.
So Ive switched to OpenDialogMBS