I don't know if it's a BUGS or call it a WISH
Posterity will judge (by Alessandro Manzoni in the lyric “Il Cinque Maggio” dedicated to Napoleon Bonaparte)
When I create new classes the environment raises the Initialize event for me.
In some classes it is necessary to have multiple ways to initialize (eg Initialize2 and Initialize3) and for this I add the subs for that purpose.
However, it happens that if I initialize with a different method, the environment marks me with an uninitialization alert. This I often ignore and it does not generate any errors.
But in some circumstances like today, in the execution of a code, where there is a class that has two types of initialization, if I don't call Initialize strangely it generates an error.
I say oddly because in initialize it does not contain any particular functions. See code below.
I wish it was possible to have more initialization methods (as it is possible to do in classes created natively in java)
PS. Someone will say that there are methods to circumvent this problem. Don't waste time listing them, I know and use them. My request is just to avoid these methods which make the code less readable
___________________________________________________________________________________________________________
This invoked code invoked multiple times generates an error
Class
MainSub
The error occurs on this line
Posterity will judge (by Alessandro Manzoni in the lyric “Il Cinque Maggio” dedicated to Napoleon Bonaparte)
When I create new classes the environment raises the Initialize event for me.
In some classes it is necessary to have multiple ways to initialize (eg Initialize2 and Initialize3) and for this I add the subs for that purpose.
However, it happens that if I initialize with a different method, the environment marks me with an uninitialization alert. This I often ignore and it does not generate any errors.
But in some circumstances like today, in the execution of a code, where there is a class that has two types of initialization, if I don't call Initialize strangely it generates an error.
I say oddly because in initialize it does not contain any particular functions. See code below.
I wish it was possible to have more initialization methods (as it is possible to do in classes created natively in java)
PS. Someone will say that there are methods to circumvent this problem. Don't waste time listing them, I know and use them. My request is just to avoid these methods which make the code less readable
___________________________________________________________________________________________________________
This invoked code invoked multiple times generates an error
Class
B4X:
Public Sub Initialize(Width As Int, Height As Int)
mWidth=Width
mHeight=Height
End Sub
Public Sub Initialize2(Vw As B4XView)
mWidth=Vw.Width
mHeight=Vw.Height
End Sub
Public Sub Show
Dim XV As B4XView = xui.CreatePanel("")
XV.SetLayoutAnimated(0,0,0,mWidth, mHeight)
End Sub
MainSub
B4X:
'Doing so generates error
Dim G3 As MyClass
G3.Initialize2(MyViewt)
'This way it does not generate an error
Dim G3 As MyClass
G3.Initialize(MyView.Width,MyView.Height)
G3.Initialize2(MyView)
The error occurs on this line
B4X:
Dim XV As B4XView = xui.CreatePanel("")
MyClass._generaterounded (java line: 84)
java.lang.RuntimeException: Parent class was not initialized.
at anywheresoftware.b4j.objects.NodeWrapper.innerInitialize(NodeWrapper.java:103)
at anywheresoftware.b4j.objects.PaneWrapper.innerInitialize(PaneWrapper.java:107)
at anywheresoftware.b4j.objects.PaneWrapper$ConcretePaneWrapper.innerInitialize(PaneWrapper.java:409)
at anywheresoftware.b4j.objects.NodeWrapper.Initialize(NodeWrapper.java:96)
at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.CreatePanel(B4XViewWrapper.java:993)
at b4j.example.colorgradient._generaterounded(colorgradient.java:84)
at b4j.example.colorgradient._gradienttoview(colorgradient.java:122)
at b4j.example.main._appstart(main.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:37)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$166(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$179(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
java.lang.RuntimeException: Parent class was not initialized.
at anywheresoftware.b4j.objects.NodeWrapper.innerInitialize(NodeWrapper.java:103)
at anywheresoftware.b4j.objects.PaneWrapper.innerInitialize(PaneWrapper.java:107)
at anywheresoftware.b4j.objects.PaneWrapper$ConcretePaneWrapper.innerInitialize(PaneWrapper.java:409)
at anywheresoftware.b4j.objects.NodeWrapper.Initialize(NodeWrapper.java:96)
at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.CreatePanel(B4XViewWrapper.java:993)
at b4j.example.colorgradient._generaterounded(colorgradient.java:84)
at b4j.example.colorgradient._gradienttoview(colorgradient.java:122)
at b4j.example.main._appstart(main.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.start(main.java:37)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$166(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$179(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Last edited: