Xojo 2017r3, MacOS X Mojave 10.14.4
My app opens a preferences file and reads in a string. Works great in the debugger, but when I build the application and run it I get an OutOfBounds Exception and the app quits. I’ve isolated this to the code that opens my preferences file, in the App.Open Event Handler (or in this case, in the MainWindow.Open event, since I tried moving it out of App.Open just for testing purposes - same error either way):
[code]//populate the preferences menu
dim prefsFilePath as string = SpecialFolder.ApplicationData.ShellPath + kSysDelim + App.ExecutableFile.Name + kSysDelim +“preferences.txt”
dim pFile as FolderItem = GetFolderItem(prefsFilePath,1)
dim prefsFileData as string
If pFile.Exists Then
Dim t As TextInputStream
Try
t = TextInputStream.Open(pFile)
t.Encoding = Encodings.UTF8
prefsFileData = t.ReadAll
t.Close
Catch e As IOException
MsgBox("Unable to open " + pFile.Name + ": " + e.Message)
End Try
End If
[/code]
It doesn’t display the error in my try/catch, so I don’t think it’s that it can’t find the file. It’s being handled by the App.UnhandledExceptions event handler. The preferences.txt file already exists at that location. And this the exception I’m getting:
RaiseOutOfBoundsException
XojoFramework$12945
MainWindow.MainWindow.Event_Open%%o<MainWindow.MainWindow>
FireWindowOpenEvents
Window.Constructor%%o<Window>
MainWindow.MainWindow%o<MainWindow.MainWindow>%
App.Event_Open%%o<App>
_Z29CocoaFinishApplicationStartupv
XojoFramework$4427
__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
___CFXRegistrationPost_block_invoke
_CFXRegistrationPost
___CFXNotificationPost_block_invoke
-[_CFXNotificationRegistrar find:object:observer:enumerator:]
_CFXNotificationPost
-[NSNotificationCenter postNotificationName:object:userInfo:]
-[NSApplication _postDidFinishNotification]
-[NSApplication _sendFinishLaunchingNotification]
_DPSNextEvent
-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
XojoFramework$4487
XojoFramework$4488
Application._CallFunctionWithExceptionHandling%%o<Application>p
_Z33CallFunctionWithExceptionHandlingPFvvE
XojoFramework$4487
-[NSApplication run]
RuntimeRun
REALbasic._RuntimeRun
_Main
main
start
Any ideas?