ubuntu-sdk-bugs team mailing list archive
-
ubuntu-sdk-bugs team
-
Mailing list archive
-
Message #07146
[Bug 1621704] [NEW] Inconsistent javascript var values - Desktop vs Arm Kit - Qt 5.6
Public bug reported:
Hi all,
I'm working on a simple Ubuntu phone app with Qt Creator 3.5.1
I should mention I'm running ubuntu-sdk on Linux Mint 18 Sarah.Kernel
version #37-Ubuntu SMP
After recently (9/7) updating the Build Kits (UbuntuSDK for armhf (GCC
ubuntu-sdk-15.04-vivid)) && (UbuntuSDK for i386 (GCC ubuntu-
sdk-15.04-vivid)) I am getting some bad javascript variable values.
When building and running the app with the Desktop Kit, I'm getting
different javascript var values (which are incorrect) than when building
and running on a phone with the armhf kit.
In the below function getAddress(type) the variables stip1, stip2,
stip3, stip4 return inconsitent values.
Example output:
(Desktop)
input: 192.168.127.64/26
Start IP Address: 192.168.64.64
(Arm Kit on Phone)
input: 192.168.127.64/26
Start IP Address: 192.168.127.64 <-- correct
Thanks,
Bob
Main.qml code:
import QtQuick 2.4
import Ubuntu.Components 1.3
/*!
\brief MainView with a Label and Button elements.
*/
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
id:root
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "ipcalc.bob"
// useDeprecatedToolbar: false
width: units.gu(100)
height: units.gu(75)
property real margins: units.gu(2)
function getAddress(type) {
var ip1 = ip1Text.text ? parseInt(ip1Text.text) : 0
var ip2 = ip2Text.text ? parseInt(ip2Text.text) : 0
var ip3 = ip3Text.text ? parseInt(ip3Text.text) : 0
var ip4 = ip4Text.text ? parseInt(ip4Text.text) : 0
var cidr = cidrText.text ? parseInt(cidrText.text) : 0
var stip1 = ip1; var stip2 = ip2; var stip3 = ip3; var stip4 = ip4;
var enip1 = ip1; var enip2 = ip2; var enip3 = ip3; var enip4 = ip4;
var sm1=255; var sm2=255; var sm3=255;var sm4=255
console.log(ip1)
console.log(ip2)
console.log(ip3)
console.log(ip4)
//console.log("stip1" + stip1)
if (cidr < 8)
{
var x = Math.pow(2, (8 - cidr)) - 1
sm1 -= x
sm2 = 0
sm3 = 0
sm4 = 0
stip1 = sm1 & ip1
enip1 = stip1 | x
stip2 = 0; stip3 = 0; stip4 = 0
enip2 = 255; enip3 = 255; enip4 = 255
} else if (cidr < 16)
{
var x = Math.pow(2, (16 - cidr)) - 1
sm2 -= x
sm3 = 0
sm4 = 0
stip2 = sm2 & ip2
enip2 = stip2 | x
stip3 = 0; stip4 = 0
enip3 = 255; enip4 = 255
} else if (cidr < 24)
{
var x = Math.pow(2, (24 - cidr)) - 1
sm3 -= x
sm4 = 0
stip3 = sm3 & ip3
enip3 = stip3 | x
stip4 = 0
enip4 = 255
} else if (cidr < 32)
{
var x = Math.pow(2, (32 - cidr)) - 1
sm4 -= x
stip4 = sm4 & ip4
enip4 = stip4 | x
}
switch(type)
{
case "start":
if (hexButton.hex == true) {
return stip1.toString(16) + "." + stip2.toString(16) + "." + stip3.toString(16) + "." + stip4.toString(16)
}
console.log(cidr)
console.log(stip1)
console.log(stip2)
console.log(stip3)
console.log(stip4)
var result = stip1 + "." + stip2 + "." + stip3 + "." +
stip4;
return result
case "end" :
if (hexButton.hex == true) {
return enip1.toString(16) + "." + enip2.toString(16) + "." + enip3.toString(16) + "." + enip4.toString(16);
}
return enip1 + "." + enip2 + "." + enip3 + "." + enip4
case "subnet" :
if (hexButton.hex == true) {
return sm1.toString(16) + "." + sm2.toString(16) + "." + sm3.toString(16) + "." + sm4.toString(16);
}
return sm1 + "." + sm2 + "." + sm3 + "." + sm4
default:
return "oops"
}
}
Page {
id:pageView
//title: i18n.tr("IP Calc")
header: PageHeader {
id: pageHeader
title: i18n.tr("IP Address Calculator")
StyleHints {
foregroundColor: UbuntuColors.orange
backgroundColor: UbuntuColors.porcelain
dividerColor: UbuntuColors.slate
}
}
Column {
id: pageLayout
anchors {
//fill: parent
// margins: root.margins
top: pageHeader.bottom
topMargin: 10
left: parent.left
leftMargin: 20
}
//spacing: units.gu(5)
Row {
spacing: units.gu(1)
// anchors.topMargin: 5
TextField {
id:ip1Text
objectName: "ip1Text"
validator: IntValidator {bottom: 0; top: 255}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
Label {
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "."
}
TextField {
id:ip2Text
objectName: "ip2Text"
validator: IntValidator {bottom: 0; top: 255}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
Label {
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "."
}
TextField {
id:ip3Text
objectName: "ip3Text"
validator: IntValidator {bottom: 0; top: 255}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
Label {
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "."
}
TextField {
id:ip4Text
objectName: "ip4Text"
validator: IntValidator {bottom: 0; top: 255}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
Label {
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "/"
}
TextField {
id:cidrText
objectName: "cidrText"
validator: IntValidator {bottom: 0; top: 32}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
onAccepted: calButton.clicked()
}
}
Row {
Label {
id: startIP
property var addr: ""
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "Start IP Address:\t" + addr
}
}
Row {
Label {
id: endIP
property var addr: ""
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "End IP Address:\t" + addr
}
}
Row {
Label {
id: subnet
property var addr: ""
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "Subnet Mask: \t " + addr
}
}
}
Column {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
Row {
spacing: units.gu(2)
Button {
id: calButton
text: "Calculate"
color: UbuntuColors.orange
onClicked: { startIP.addr = getAddress("start");
endIP.addr = getAddress("end");
subnet.addr = getAddress("subnet"); }
}
Button {
id: hexButton
text: "Hex"
property bool hex: false
color: UbuntuColors.orange
//anchors.right: calButton.left
//anchors.bottom: parent.bottom
onClicked: {
if (hexButton.hex == false) {
hexButton.hex = true;
hexButton.text = "Dec"
} else {
hexButton.hex = false;
hexButton.text = "Hex";
}
startIP.addr = getAddress("start");
endIP.addr = getAddress("end");
subnet.addr = getAddress("subnet"); }
}
Button {
id: locButton
text: "Locate"
color: UbuntuColors.orange
}
}
}
}
}
** Affects: qtcreator (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
SDK bug tracking, which is subscribed to qtcreator in Ubuntu.
https://bugs.launchpad.net/bugs/1621704
Title:
Inconsistent javascript var values - Desktop vs Arm Kit - Qt 5.6
Status in qtcreator package in Ubuntu:
New
Bug description:
Hi all,
I'm working on a simple Ubuntu phone app with Qt Creator 3.5.1
I should mention I'm running ubuntu-sdk on Linux Mint 18 Sarah.Kernel
version #37-Ubuntu SMP
After recently (9/7) updating the Build Kits (UbuntuSDK for armhf (GCC
ubuntu-sdk-15.04-vivid)) && (UbuntuSDK for i386 (GCC ubuntu-
sdk-15.04-vivid)) I am getting some bad javascript variable values.
When building and running the app with the Desktop Kit, I'm getting
different javascript var values (which are incorrect) than when
building and running on a phone with the armhf kit.
In the below function getAddress(type) the variables stip1, stip2,
stip3, stip4 return inconsitent values.
Example output:
(Desktop)
input: 192.168.127.64/26
Start IP Address: 192.168.64.64
(Arm Kit on Phone)
input: 192.168.127.64/26
Start IP Address: 192.168.127.64 <-- correct
Thanks,
Bob
Main.qml code:
import QtQuick 2.4
import Ubuntu.Components 1.3
/*!
\brief MainView with a Label and Button elements.
*/
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
id:root
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "ipcalc.bob"
// useDeprecatedToolbar: false
width: units.gu(100)
height: units.gu(75)
property real margins: units.gu(2)
function getAddress(type) {
var ip1 = ip1Text.text ? parseInt(ip1Text.text) : 0
var ip2 = ip2Text.text ? parseInt(ip2Text.text) : 0
var ip3 = ip3Text.text ? parseInt(ip3Text.text) : 0
var ip4 = ip4Text.text ? parseInt(ip4Text.text) : 0
var cidr = cidrText.text ? parseInt(cidrText.text) : 0
var stip1 = ip1; var stip2 = ip2; var stip3 = ip3; var stip4 = ip4;
var enip1 = ip1; var enip2 = ip2; var enip3 = ip3; var enip4 = ip4;
var sm1=255; var sm2=255; var sm3=255;var sm4=255
console.log(ip1)
console.log(ip2)
console.log(ip3)
console.log(ip4)
//console.log("stip1" + stip1)
if (cidr < 8)
{
var x = Math.pow(2, (8 - cidr)) - 1
sm1 -= x
sm2 = 0
sm3 = 0
sm4 = 0
stip1 = sm1 & ip1
enip1 = stip1 | x
stip2 = 0; stip3 = 0; stip4 = 0
enip2 = 255; enip3 = 255; enip4 = 255
} else if (cidr < 16)
{
var x = Math.pow(2, (16 - cidr)) - 1
sm2 -= x
sm3 = 0
sm4 = 0
stip2 = sm2 & ip2
enip2 = stip2 | x
stip3 = 0; stip4 = 0
enip3 = 255; enip4 = 255
} else if (cidr < 24)
{
var x = Math.pow(2, (24 - cidr)) - 1
sm3 -= x
sm4 = 0
stip3 = sm3 & ip3
enip3 = stip3 | x
stip4 = 0
enip4 = 255
} else if (cidr < 32)
{
var x = Math.pow(2, (32 - cidr)) - 1
sm4 -= x
stip4 = sm4 & ip4
enip4 = stip4 | x
}
switch(type)
{
case "start":
if (hexButton.hex == true) {
return stip1.toString(16) + "." + stip2.toString(16) + "." + stip3.toString(16) + "." + stip4.toString(16)
}
console.log(cidr)
console.log(stip1)
console.log(stip2)
console.log(stip3)
console.log(stip4)
var result = stip1 + "." + stip2 + "." + stip3 + "." +
stip4;
return result
case "end" :
if (hexButton.hex == true) {
return enip1.toString(16) + "." + enip2.toString(16) + "." + enip3.toString(16) + "." + enip4.toString(16);
}
return enip1 + "." + enip2 + "." + enip3 + "." + enip4
case "subnet" :
if (hexButton.hex == true) {
return sm1.toString(16) + "." + sm2.toString(16) + "." + sm3.toString(16) + "." + sm4.toString(16);
}
return sm1 + "." + sm2 + "." + sm3 + "." + sm4
default:
return "oops"
}
}
Page {
id:pageView
//title: i18n.tr("IP Calc")
header: PageHeader {
id: pageHeader
title: i18n.tr("IP Address Calculator")
StyleHints {
foregroundColor: UbuntuColors.orange
backgroundColor: UbuntuColors.porcelain
dividerColor: UbuntuColors.slate
}
}
Column {
id: pageLayout
anchors {
//fill: parent
// margins: root.margins
top: pageHeader.bottom
topMargin: 10
left: parent.left
leftMargin: 20
}
//spacing: units.gu(5)
Row {
spacing: units.gu(1)
// anchors.topMargin: 5
TextField {
id:ip1Text
objectName: "ip1Text"
validator: IntValidator {bottom: 0; top: 255}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
Label {
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "."
}
TextField {
id:ip2Text
objectName: "ip2Text"
validator: IntValidator {bottom: 0; top: 255}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
Label {
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "."
}
TextField {
id:ip3Text
objectName: "ip3Text"
validator: IntValidator {bottom: 0; top: 255}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
Label {
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "."
}
TextField {
id:ip4Text
objectName: "ip4Text"
validator: IntValidator {bottom: 0; top: 255}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
}
Label {
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "/"
}
TextField {
id:cidrText
objectName: "cidrText"
validator: IntValidator {bottom: 0; top: 32}
maximumLength: 3
height: units.gu(5)
width: units.gu(6)
verticalAlignment: Text.AlignBottom
font.pixelSize: FontUtils.sizeToPixels("medium")
inputMethodHints: Qt.ImhFormattedNumbersOnly
onAccepted: calButton.clicked()
}
}
Row {
Label {
id: startIP
property var addr: ""
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "Start IP Address:\t" + addr
}
}
Row {
Label {
id: endIP
property var addr: ""
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "End IP Address:\t" + addr
}
}
Row {
Label {
id: subnet
property var addr: ""
height: units.gu(5)
textSize: Label.Large
verticalAlignment: Text.AlignBottom
text: "Subnet Mask: \t " + addr
}
}
}
Column {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
Row {
spacing: units.gu(2)
Button {
id: calButton
text: "Calculate"
color: UbuntuColors.orange
onClicked: { startIP.addr = getAddress("start");
endIP.addr = getAddress("end");
subnet.addr = getAddress("subnet"); }
}
Button {
id: hexButton
text: "Hex"
property bool hex: false
color: UbuntuColors.orange
//anchors.right: calButton.left
//anchors.bottom: parent.bottom
onClicked: {
if (hexButton.hex == false) {
hexButton.hex = true;
hexButton.text = "Dec"
} else {
hexButton.hex = false;
hexButton.text = "Hex";
}
startIP.addr = getAddress("start");
endIP.addr = getAddress("end");
subnet.addr = getAddress("subnet"); }
}
Button {
id: locButton
text: "Locate"
color: UbuntuColors.orange
}
}
}
}
}
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qtcreator/+bug/1621704/+subscriptions