QCAD Bugtracker

  • Status Closed
  • Percent Complete
    100%
  • Task Type Bug Report
  • Category QCAD/CAM
  • Assigned To
    Andrew
  • Operating System All
  • Severity Low
  • Priority Very Low
  • Reported Version 3.31.2
  • Due in Version Undecided
  • Due Date Undecided
  • Votes 1
  • Private
Attached to Project: QCAD Bugtracker
Opened by Daniel Jelkmann - 06.01.2025
Last edited by Andrew - 07.01.2025

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

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

Closed by  Andrew
07.01.2025 07:24
Reason for closing:  Fixed
Additional comments about closing:  

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

CVH commented on 06.01.2025 17:40

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

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing