Page 1 of 1


Posted: Wed Dec 04, 2013 6:09 pm
by sramp
I'm coding my first trials with qcad scripting, but I'm encountering problems. I hope somebody can point me in the right direction.
I'm using qcad-pro with a MacOS 1.7.5.
As first trial I have added to the tutorial Menus and Tool Bars a new item called TestDialog.
TestDialog should simply display a dialog made with QtDesigner ( very simple dialog, few buttons and some labels).
MyAction command works fine, while my new command TestDialog, dies silently.
Starting qcad with the -enable-script-debugger I can se that I'm getting an exception :

Code: Select all

Uncaught exception at scripts/TestQCAD/TestDialog/TestDialog.js:8: RangeError: Maximum call stack size exceeded.

Following my TestDialog.js source code ... that's a lazy copy of PersistentWidgets without persistence.

function TestDialog(guiAction) {, guiAction);
TestDialog.prototype = new TestQCAD();
TestDialog.prototype.beginEvent = function() {;
// Create the dialog from the .ui file using the helper
// function WidgetFactory.createWidget().

var dialog = WidgetFactory.createWidget("../TestQCAD/TestDialog","TestDialog.ui");

// Display and execute the dialog:
if (!dialog.exec()) {

// User hit cancel:

TestDialog.init = function(basePath) {
var action = new RGuiAction(qsTr("&Test Dialog"),
action.setScriptFile(basePath + "/TestDialog.js");
EAction.addGuiActionTo(action, TestQCAD, true, false, false);

BTW I've tried to run the PersistentWidgets starting qcad enabling xdata, but I get another exception :

Code: Select all

Uncaught exception at /Applications/ TypeError: Result of expression 'widget' [undefined] is not an object.
371           };

Thanks in advance.
Kind Regards

Re: Exception

Posted: Wed Dec 04, 2013 6:22 pm
by andrew
sramp wrote:
TestDialog.prototype.beginEvent = function() {;

The line; calls the same function beginEvent recursively.

The idea of that line is to call the beginEvent function of the base class (in this case TestQCAD):

TestDialog.prototype.beginEvent = function() {;

Re: Exception

Posted: Wed Dec 04, 2013 7:14 pm
by sramp
Hi Andrew,
thanks for the prompt reply.
You're right, it's a stupid error of mine.
Sorry for the noise.
After fixing a bad path, everything works fine.