I just purchased Xojo so I could generate a linux executable.
I copied the executable and libs over to a VM running Centos 7.9.
It complained about not being able to find libunwind.so, so I installed that via yum.
The application loaded up and the gui was displayed, but when it came to opening and reading a file it promptly segfaulted!.
I created a new simple App with one button whose action code is detailed below. I ran this on windows and a message box popped up telling me how many lines had been read.
I built this for linux and copied the files over, fired it up, pressed the button, chose a file in the file manager and it segfaulted.
Should this code work on Linux like it does in Windows? I wondering if Xojo Linux support isnāt that stable or as comprehensive as the marketing docs claim?
Thanks for your time,
Carl C.
Var File As FolderItem = FolderItem.showOpenFileDialog("")
Var lineIndex() As Integer
Var input As TextInputStream
input = TextInputStream.Open(file)
While Not input.EndOfFile
Var tmpStr As String = input.readLine()
lineIndex.Add(input.BytePosition())
Wend
If I donāt use the showOpenFileDialog call, and instead set the file path/name programmatically the code works fine (see below). So, Iām guessing that the FileDialog is returning a null/nil FolderItem, even though Iām opening the same file that I set programmatically.
Interestingly if I add a check for nill on the file variable before I use it, OR if I new the file FolderItem before trying to assign it to the return of showOpenFileDialog it still segFaults. Which would suggest that at least in Centos 7.9 the open file dialog becomes unstable after selecting a file and before returning, so it looks like its fundamentally broken as opposed to something Iām doing.
// Var file As FolderItem = FolderItem.showOpenFileDialog("")
Var file As FolderItem = New FolderItem("/home/user/Projects/Xojo/FileTestA/num.txt", FolderItem.PathModes.Shell)
var lineIndex() As Integer
Var input As TextInputStream
input = TextInputStream.Open(file)
While Not input.EndOfFile
Var tmpStr As String = input.readLine()
lineIndex.Add(input.BytePosition())
Wend
Oh, and if I use the code from the xojo docs on openFileDialog (http://documentation.xojo.com/api/user_interface/desktop/openfiledialog.html which explicitly mentions āTargetLinuxā it also SegFaults on Centos 7.9. Guess Iāll need to implement some kind of file chooser myself, or reduce the functionality to users needing to cut ānā paste their path/file into a TextBox. Kind of disappointing for my first foray into Xojo/Linux ā¦ but at least it can be worked around.
Have you checked whether the two folderitems are really pointing to the same file? Check their NativePath properties. Itās fairly possible the OpenFileDialog returns another file (e.g. by resolving symbolic links).
If youāre sure they are the same file, thatās surprising. I canāt see how showing an OpenFileDialog would interfere with reading the file later. Perhaps the dialog retains some kind of preview?
Iād try some more things:
1: try reading as a binary stream instead of a text input stream.
2: try not reading at all. e.g. Show a MessageBox telling the size of the file.
3: try delaying between showing the OpenFileDialog and accessing the file; perhaps a delay would allow the file to be released, should it be retainedā¦
4: put a breakpoint before opening the file and check if its properties are correct.
5: either build your app or run it paused; in both cases, you get an executable file not yet launched. Open the Terminal and launch your app from there. When the SegFault occurs, the Terminal should tell you more about the problem.
Itās definitely the same file, its a text file with numbers from 0 to 100 that tested the code against of windows and then moved to linux, in the same place that I copied the xojo executable to.
I canāt check the actual āpointersā since the executable crashes before the openFileDialog returns a FolderItem handler, pointer, object (whatever xojo calls it). E.g. if I do
Var file As New FolderItem
file = FolderItem.showOpenFileDialog("")
If file <> Nil Then
MessageBox (āFile openedā)
Else
MessageBox (āFile was Nilā)
End If
It crashes with the SegFault right after I select the file in the dialog, and before it gets to the Nil check. Note: Iām not even trying to open the file or do operations on itā¦ just a simple Nil check as per the xojo documentation for openFileDialog.
Re 1: it dies before I can even open it as a text stream, so Iām guessing the binary stream wont help.
Re 2: Yep, I tried that and it dies after clicking the file in the dialog.
Re 3: Hmmm, I canāt expect my users to wait an arbitrary time before interacting with the dialog that just opened for them. But, I tried it and it still dies.
Re 4: It dies before I can even check if the FolderItem is Nil, so nope cant check its properties.
Re 5: Iām actually building on windows and then copying over to linux, I think youāre suggesting that I install xojo onto linux and build thereā¦ Iāll give this a go.
My suspicion is that there is a incompatibility between centos 7.9 and whatever xojo is doing on the backend for linux, but I think trying the linux installation of xojo is a good idea.
Well I think that confirms that there is a problem with Xojo and Centos 7.9 at least where file dialogs are concerned.
I installed the linux version of Xojo. It fired up fine, I created a new project. Added a button with an action handlerā¦ cut n pasted my code over from windows. Then I went to run it.
Before I could run, I needed to save it. The save dialog window opened, I navigated to my project directory, I created a new folder I clicked saveā¦ and BAM!!
libocci.so.10.1: cannot open shared object file: No such file or directorySegmentation fault (core dumped)
According the forums one should remove the OraclePlugin ā¦ so I did that.
Started up Xojo again, created a project, added a buttonā¦ blah blah.
Went to save the project, and BAMā¦
Segmentation fault (core dumped).
Sooooooā¦ Iām guessing the previous error message was actually two errors.
Iām pretty sure there is an issue with Centos 7.9 and the file dialog windows.
So itās safe to say that it crashes āinā the file dialog. Please fill a feedback report (use the Feedback button in Xojo) and report this bug, that you could reproduce.
This will still eliminate potential bugs.
And once youāve built right on Linux, use the Terminal to launch your app. Thatās important as youāll probably see more information about the crash in the Terminal window (rather than just the app disappearing).
Please make sure this file is actually installed. Iām guessing your current installation isnāt 100% supported yet and you have to install this library. You can check the compatibility page of Xojo.
Apparently that requires me to install the āOracle Instant Clientā from Oracleā¦ Iām probably not going to do that. I was really excited with the prospect of developing cross platform apps, especially those that claimed to be self contained. My experience is that most companies donāt give you root access to linux and getting the corporate IT department to install things like āOracle Instant Clientā on all the workstations is going to dissuade potential users. Something like gnu libunwind may be doable, but when it comes to installing a whole package from oracle just for a simple $20 labor saving app is probably not going to fly. Iāll do some more research, but its not looking as simple as ājust develop the app and share it across different platformsā, if that linux platform has to be a very customized distribution.
Try/catch blocks wonāt help when an app hard crashes. These handle exceptions, but hard crashes donāt generate exceptions (the app is just terminated).
Apparently the Xojo Devs have recreated the issue themselves (#65751), so I guess this isnāt something peculiar to my relatively clean install on centos 7.9 in a VM.
I worked around this by creating my own open file dialog, which works perfectly on both windows and linux.
Iām able to double click on folders to navigate up and down the folder hierarchy, and then once a file is selected and the open button clicked, I get back a FolderItem for the file that was selected. So far no SegFaults in sight .
Its simple, but effective. Iām a little happier with Xojo ā¦ it took me a while to get my head around getting an object into and out of a modal window, but other than that it was relatively straight forward and painless. Iām pretty sure I can make it more fancy as and when I need to.
While itās true you can make your own āselect fileā dialog, itās usually not a great idea. As soon as your original issue with the built-in dialog gets resolved, I suggest you to use it again.
Here are some things an intermediate or advanced user may want:
Control+N or Command+N to create a new folder.
Backspace or Command-Up arrow to move to the parent folder.
Auto-detect when an item is added, removed or renamed in the current list (refresh the list).
Columns showing other data than just the name.
An expected UI.
(etc.).
Some users would be disappointed to not see these things.