Check if 2 folderitems are identical

I’ve got some code to manage recently opened databases in a recent menu item. Since I changed this from using folderitems to getSafeInfo the app crashes whenver the code is executed the second or third time. The code to get the database is rather simple:

dim newFolderitem as FolderItem = Volume(0)
newFolderitem = newFolderitem.getRelative(FolderItemSaveInfo)
if theFolderitem = nil or Volume(0).NativePath = theFolderitem.NativePath then
Return nil
Return newFolderitem
end if

The code is executed and the app crashes somewhat later. When I take the line with the native path comparison out then the app doesn’t crash. I’ve also tried to use shell paths and simply the name. But the result is the same.

So the question is: is there another way to check if the SafeInfo was correct?

Using Xojo2013r3, Cocoa, Mac OS 10.8.4.

Here is the crash log:

Thread 0 Crashed:: Dispatch queue:
0 libsystem_c.dylib 0x9774fb05 strcasecmp_l + 71
1 libsystem_c.dylib 0x9774fbfa strcasecmp + 60
2 rbframework.dylib 0x01578b80 0x1570000 + 35712
3 rbframework.dylib 0x0166d0a6 0x1570000 + 1036454
4 rbframework.dylib 0x0166de6e 0x1570000 + 1039982
5 rbframework.dylib 0x0166e203 0x1570000 + 1040899
6 libobjc.A.dylib 0x95c9b5d3 -[NSObject performSelector:withObject:] + 70
7 0x947fcad2 -[NSApplication sendAction:to:from:] + 436
8 0x949392fc -[NSMenuItem _corePerformAction] + 529
9 0x94938f8b -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 163
10 0x94938614 -[NSMenu _performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] + 79
11 0x9461902a -[NSMenu performActionForItemAtIndex:] + 65
12 0x94618fdf -[NSMenu _internalPerformActionForItemAtIndex:] + 45
13 0x94618faa -[NSMenuItem _internalPerformActionThroughMenuIfPossible] + 106
14 0x94618e29 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 162
15 0x949316ee NSSLMMenuEventHandler + 454
16 0x97c4e9bb _InvokeEventHandlerUPP(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*, long ()(OpaqueEventHandlerCallRef, OpaqueEventRef*, void*)) + 36
17 0x97ad6394 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1343
18 0x97ad5780 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 430
19 0x97ae9655 SendEventToEventTarget + 88
20 0x97c4e86a SendHICommandEvent(unsigned long, HICommand const*, unsigned long, unsigned long, unsigned char, void const*, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 498
21 0x97ac5984 SendMenuCommandWithContextAndModifiers + 70
22 0x97ac5931 SendMenuItemSelectedEvent + 268
23 0x97ac57b6 FinishMenuSelection(SelectionData*, MenuResult*, MenuResult*) + 134
24 0x97c9ae7e MenuSelectCore(MenuData*, Point, double, unsigned long, OpaqueMenuRef**, unsigned short*) + 623
25 0x97aa6132 _HandleMenuSelection2 + 633

I don’t use getRelative but the only thing I see in your code is that Volume(0) is sometimes Nil.
If I was you, I would test it and display an alert if Nil to see if it’s that or not.

Hi Thomas,

thanks for the tip. But the nil check didn’t make a difference.

And I don’t understand, you test theFolderitem and you return NewFolderitem , then it’s not because the first in not Nil than the second one is not neither.
I repeat, I didn’t very well understang how GetRelative works, I just answer on what I see in you code.

You are 100% correct. I muddled the code up when testing. And now I can’t reproduce the bug. Okay, case closed for now and to be under observation.

Thanks for your help!

I think you can also do this:

dim newFolderitem as FolderItem = new Folderitem(FolderItemSaveInfo)