← All bug reports

FS#2624CamToolDialog: Input validation does not work as expected

Type
Bug
Status
Closed
Resolution
Fixed
Category
QCAD/CAM
Severity
Low
Priority
Low
Reported version
3.31.2
Operating system
All
Reported
2025-01-06 by Deejay
Closed
2025-01-07 by andrew
Votes
1

Hi,

I found the following issue while modifing the postprocessor script. I am running QCAD/CAM 3.31.2.-Pro on Linux 64 bit.

When adding or editing the CAM tools, the CamToolDialog does not correctly validate the user input (in file CamToolDialog.js).
There are two issues:

1. The function CamToolDialog.prototype.validate does not call this.validateToolName(msgs, false) and ResourceDialog.prototype.validate.call(this, valid, msgs) correctly.

Example: Start with an empty CAM tool list. Add one tool with tool name "1" as suggested by the dialog (the other values not relevant).
Click the 'Add tool'-button again. The dialog suggests "2" as tool number. Change the tool number to "1". Below the input fields, there appears an error message "Tool already exists".
But it is still possible to click the OK button. The previously set values are overwritten without notice. Expected behaviour is that the OK button is disabled as long as the error (dublicate tool) occurs.

Suggested fix:
In file CamToolDialog.js in the function CamToolDialog.prototype.validate (lines 106 and following):
Change

valid = valid && this.validateToolName(msgs, false);
valid = valid && ResourceDialog.prototype.validate.call(this, valid, msgs);

to

valid = valid & this.validateToolName(msgs, false);
valid = valid & ResourceDialog.prototype.validate.call(this, valid, msgs);

Explanation: && is logical AND. If the first operand is false, the second operand is not evaluated...
In this case, the bitwise AND must be used.

Workaround until the bug is fixed:
Overwrite the CamToolDialog.prototype.validate in your postprocessor script with the fix given above.

2. When the CamToolDialog is created and shown, the validation function needs to be called. Otherwise the user can create a new tool with empty (invalid) values.

Example: Click on the 'Add tool'-button to open the CAMToolDialog. Initially, the values for tool diameter, speeds and feeds are empty. But the OK button is enabled.
By clicking OK, the invalid / empty values are taken for the new tool without error.

Suggested fix:
The validation function should be called once after the dialog has been created / shown. This should show the according error messages and disable the OK button.

Workaround until the bug is fixed:
Overwrite the function CamToolDialog.prototype.afterShow in your postprocessor script and call the according validate function:

CamToolDialog.prototype.afterShow = function() {
	CamToolDialog.prototype.validate.call(this);
	return true;
}

Please let me know if you need more details.
Regards,
Deejay

Comments (1)

CVH 2025-01-06

May I remark that you are fiddling in Proprietary code.

Knowing that you can have a glimpse in QCAD Pro and QCAD/CAM code.
Still ...
It would be better to keep this info and those in your forum topics between you and Andrew.

Regards,
CVH

Closure comment

The correct implementation is:
valid = valid && this.validateToolName(msgs, false);
valid = ResourceDialog.prototype.validate.call(this, valid, msgs);