Johan Schoeman Expert Licensed User Longtime User Dec 26, 2015 #1 This is the weirdest thing that @Mahares has brought to my attention. At about line 96 of the attached project the following line of code appears: Code: mlc1.XaxisLabelPosition = "BOTTOM" If you run the project in release mode then it draws the x-axis labels at the bottom or top i.e in the right place depending on BOTTOM or TOP being set. But in Debug mode it draws the x-axis labels only at the TOP regardless of setting it to BOTTOM. What in this lifetime is happening here...? Why does it do so...? The library files for this project are in the /Files folder of the attached B4A project. Copy them to your additional library folder to test this weirdness... Can anyone give an explanation for this...? Attachments b4aMPMultiLineChartV4.zip b4aMPMultiLineChartV4.zip 377.6 KB · Views: 576
This is the weirdest thing that @Mahares has brought to my attention. At about line 96 of the attached project the following line of code appears: Code: mlc1.XaxisLabelPosition = "BOTTOM" If you run the project in release mode then it draws the x-axis labels at the bottom or top i.e in the right place depending on BOTTOM or TOP being set. But in Debug mode it draws the x-axis labels only at the TOP regardless of setting it to BOTTOM. What in this lifetime is happening here...? Why does it do so...? The library files for this project are in the /Files folder of the attached B4A project. Copy them to your additional library folder to test this weirdness... Can anyone give an explanation for this...?
M Mahares Expert Licensed User Longtime User Dec 26, 2015 #2 I observed the same thing as @Johan Schoeman. With B4A 5.5, when I run the project in Rapid Debug, if this line: mlc1.XaxisLabelPosition = "BOTTOM" is in the code the labels show up on top of the graph, But if I run the project in Legacy Debug or Release mode the project works as expected. The labels show up at the bottom of the graph. Upvote 0
I observed the same thing as @Johan Schoeman. With B4A 5.5, when I run the project in Rapid Debug, if this line: mlc1.XaxisLabelPosition = "BOTTOM" is in the code the labels show up on top of the graph, But if I run the project in Legacy Debug or Release mode the project works as expected. The labels show up at the bottom of the graph.
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2015 #3 Johan, can you send me the library source code? Upvote 0
Johan Schoeman Expert Licensed User Longtime User Dec 27, 2015 #4 Erel said: Johan, can you send me the library source code? Click to expand... Here is a link (for whoever else might be interested in the library source code) - too large to upload to the forum https://www.dropbox.com/s/iych4bpkttxn1ds/MPChartLib.zip?dl=0 Upvote 0
Erel said: Johan, can you send me the library source code? Click to expand... Here is a link (for whoever else might be interested in the library source code) - too large to upload to the forum https://www.dropbox.com/s/iych4bpkttxn1ds/MPChartLib.zip?dl=0
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2015 #5 Try to add some log messages with BA.Log in renderAxisLabels. My guess is that onDraw is called before the property is set. With the log messages you can see when it happens and what are the values of mXAxis.getPosition(): BA.Log("position: " + mXAxis.getPosition()) Upvote 0
Try to add some log messages with BA.Log in renderAxisLabels. My guess is that onDraw is called before the property is set. With the log messages you can see when it happens and what are the values of mXAxis.getPosition(): BA.Log("position: " + mXAxis.getPosition())
Johan Schoeman Expert Licensed User Longtime User Dec 27, 2015 #6 Erel said: Try to add some log messages with BA.Log in renderAxisLabels. My guess is that onDraw is called before the property is set. With the log messages you can see when it happens and what are the values of mXAxis.getPosition(): BA.Log("position: " + mXAxis.getPosition()) Click to expand... Will do so Erel and will let you know. But why does it only happen in Rapid Debug mode and not in Release mode? Upvote 0
Erel said: Try to add some log messages with BA.Log in renderAxisLabels. My guess is that onDraw is called before the property is set. With the log messages you can see when it happens and what are the values of mXAxis.getPosition(): BA.Log("position: " + mXAxis.getPosition()) Click to expand... Will do so Erel and will let you know. But why does it only happen in Rapid Debug mode and not in Release mode?
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2015 #7 Johan Schoeman said: But why does it only happen in Rapid Debug mode and not in Release mode? Click to expand... Hard to say without further debugging it. Upvote 0
Johan Schoeman said: But why does it only happen in Rapid Debug mode and not in Release mode? Click to expand... Hard to say without further debugging it.
Johan Schoeman Expert Licensed User Longtime User Dec 29, 2015 #8 Erel said: Hard to say without further debugging it. Click to expand... Erel, it seems to me I got caught by one of the "newbie" pitfalls in Java. Compared two strings with == and not with string1.equals(string2). Changed the code and now it is working fine in Release, Legacy Debug and Rapid Debug. Nevertheless quite interesting that in Release and Legacy Debug it did manage to draw the labels in the correct place despite comparing the strings with ==. I don't quite understand this. Or do you think it might be something else in the code that causes the problem and by changing the string comparison I have just applied a plaster to stop the bleeding? The sequence of events seems to be fine when I added debug statements i.e XAxis.java gets initialized, then the call from B4A, and then the call to XAxisRenderer. Upvote 0
Erel said: Hard to say without further debugging it. Click to expand... Erel, it seems to me I got caught by one of the "newbie" pitfalls in Java. Compared two strings with == and not with string1.equals(string2). Changed the code and now it is working fine in Release, Legacy Debug and Rapid Debug. Nevertheless quite interesting that in Release and Legacy Debug it did manage to draw the labels in the correct place despite comparing the strings with ==. I don't quite understand this. Or do you think it might be something else in the code that causes the problem and by changing the string comparison I have just applied a plaster to stop the bleeding? The sequence of events seems to be fine when I added debug statements i.e XAxis.java gets initialized, then the call from B4A, and then the call to XAxisRenderer.
Erel B4X founder Staff member Licensed User Longtime User Dec 29, 2015 #9 The string comparison is the cause of this issue. In release mode the Java compiler adds all the literal strings to the internal strings pool. So two equal strings (from the code) will point to the same object. In rapid debug mode the string comes from a different process so it points to a different object. Upvote 0
The string comparison is the cause of this issue. In release mode the Java compiler adds all the literal strings to the internal strings pool. So two equal strings (from the code) will point to the same object. In rapid debug mode the string comes from a different process so it points to a different object.
mr23 Active Member Licensed User Longtime User Jan 17, 2016 #10 This also seems to apply to strings used for Char variable tests, with at least IDE 5.5? Code: Dim c as Char If c = """" Then ... """" should end up as a just one <doublequote>. This comparison works in 5.5 in debug, but in release it fails, while c = CHR(34) does work in release. I didn't go back and retest it, but I believe the c = """" in release worked in 5.0.2 and prior, or at least prior to 5.0. Not 100% sure of my test case coverage when using 5.0.x. Update: question moved to https://www.b4x.com/android/forum/threads/char-comparison-failed-in-release-mode.62505/ Last edited: Jan 19, 2016 Upvote 0
This also seems to apply to strings used for Char variable tests, with at least IDE 5.5? Code: Dim c as Char If c = """" Then ... """" should end up as a just one <doublequote>. This comparison works in 5.5 in debug, but in release it fails, while c = CHR(34) does work in release. I didn't go back and retest it, but I believe the c = """" in release worked in 5.0.2 and prior, or at least prior to 5.0. Not 100% sure of my test case coverage when using 5.0.x. Update: question moved to https://www.b4x.com/android/forum/threads/char-comparison-failed-in-release-mode.62505/
Erel B4X founder Staff member Licensed User Longtime User Jan 18, 2016 #11 Please start a new thread for this. It is not related to this thread. Upvote 0