B4J Question B4J UI app under Linux: why crash ?

peacemaker

Expert
Licensed User
Longtime User
HI, All

This topic is related to this one: https://www.b4x.com/android/forum/threads/b4j-how-to-debug-ui-app-under-linux.165367/

Why error "XSetErrorHandler() called with a GDK error trap pushed. Don't do that." can crash the app in this code:

B4X:
Sub Help_Action
    Dim txt As StringBuilder
    txt.Initialize
    txt.Append("0. The Internet-connection is required for correct app function.").Append(CRLF).Append(CRLF)
    txt.Append("1. Prepare 2 pictures - photos of both PCB sides. Mirror one of them (say, bottom) to be corresponding the top one").Append(CRLF).Append(CRLF)
.....

    tmp.Initialize
    tmp.Text = txt.ToString
    dialog.Title = "How to use the app:"
    tmp.Resize(Root.Width * 0.7, Root.Height * 0.7)
    dialog.ButtonsFont = xui.CreateDefaultFont(10)
    Main.fx.Clipboard.SetString(others.device_id)
    xui.MsgboxAsync(QUOTE & others.device_id & QUOTE & " is placed to clipboard, use for support", "Computer ID")
    Wait For (dialog.ShowTemplate(tmp, "OK", "Telegram", "ChangeLog & Email")) Complete (Result As Int)
    If Result = xui.DialogResponse_Negative Then
        others.OpenLink(others.telegram)
    Else If Result = xui.DialogResponse_Cancel Then
        others.OpenLink("mailto:" & others.email & "?subject=PCBComparer2_ver." & Main.ver & "_from_" & others.device_id)
        others.OpenLink("https://website")
    End If
End Sub

?

Dialog with the template is not shown, error and crash is occured.
 

peacemaker

Expert
Licensed User
Longtime User
Just checked that under Linux works OK "xui.MsgboxAsync", if to comment the dialog with the template.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes, found that under Linux this error is due to "Wait For (dialog.ShowTemplate(....".
"Wait for (dialog.Show(txt.ToString,...." works OK, but very small window even for very short message.

But such checking by recompiling under Win10 and replacing .jar file via a flash-drive manually - it's a pain.

@Erel, info just for ref: the dialog templates better if to re-check and maybe rework, for Linux compatibility.

But how to show user some loooong text, like instructions ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
@Erel, info just for ref: the dialog templates better if to re-check and maybe rework, for Linux compatibility.

Error from Linux is so:

b4xdialog$ResumableSub_ShowTemplate.resume (java line: 1136)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:522)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:468)
at peacemaker.pcbcomparer2.b4xdialog$ResumableSub_ShowTemplate.resume(b4xdialog.java:1136)
at peacemaker.pcbcomparer2.b4xdialog._showtemplate(b4xdialog.java:1102)
at peacemaker.pcbcomparer2.b4xmainpage$ResumableSub_Help_Action.resume(b4xmainpage.java:1132)
at peacemaker.pcbcomparer2.b4xmainpage._help_action(b4xmainpage.java:1052)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.BA$1.run(BA.java:236)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4j.example.customlistview._createlabel(customlistview.java:239)
at b4j.example.customlistview._insertattextitem(customlistview.java:704)
at b4j.example.customlistview._addtextitem(customlistview.java:82)
at peacemaker.pcbcomparer2.b4xlongtexttemplate._show(b4xlongtexttemplate.java:112)
at peacemaker.pcbcomparer2.b4xlongtexttemplate.callSub(b4xlongtexttemplate.java:127)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:497)
... 16 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public static double com.sun.javafx.scene.control.skin.Utils.computeTextHeight(javafx.scene.text.Font,java.lang.String,double,javafx.scene.text.TextBoundsType) accessible: module javafx.controls does not "exports com.sun.javafx.scene.control.skin" to unnamed module @c01acb2
at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:201)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:195)
at b4j.example.customlistview.MeasureMultilineTextHeight(customlistview.java:1082)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 24 more

And btw - Wait For (dialog.ShowTemplate(temp.... works OK under LInux, if the template is B4XInputTemplate.
Something with MeasureMultilineTextHeight... ?
 
Upvote 0
Top