Exception

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
sramp
Active Member
Posts: 26
Joined: Mon Dec 02, 2013 4:15 pm

Exception

Post by sramp » Wed Dec 04, 2013 6:09 pm

Hello,
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.
8	    TestDialog.prototype.beginEvent.call(this);
Following my TestDialog.js source code ... that's a lazy copy of PersistentWidgets without persistence.
include("../WidgetFactory.js");
include("../TestQCAD.js");
function TestDialog(guiAction) {
    TestQCAD.call(this, guiAction);
}
TestDialog.prototype = new TestQCAD();
TestDialog.prototype.beginEvent = function() {
    TestDialog.prototype.beginEvent.call(this);
    // 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:
        this.terminate();
        return;
    }
     
    
    this.terminate();
};
TestDialog.init = function(basePath) {
    var action = new RGuiAction(qsTr("&Test Dialog"),
        RMainWindowQt.getMainWindow());
    action.setRequiresDocument(true);
    action.setScriptFile(basePath + "/TestDialog.js");
    action.setSortOrder(10);
    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/QCAD-Pro.app/Contents/Resources/scripts/WidgetFactory.js:371: TypeError: Result of expression 'widget' [undefined] is not an object.
371	        };
Thanks in advance.
Kind Regards
sramp

User avatar
andrew
Site Admin
Posts: 9036
Joined: Fri Mar 30, 2007 6:07 am

Re: Exception

Post by andrew » Wed Dec 04, 2013 6:22 pm

sramp wrote:
TestDialog.prototype.beginEvent = function() {
    TestDialog.prototype.beginEvent.call(this);
    ...
}
The line TestDialog.prototype.beginEvent.call(this); 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() {
    TestQCAD.prototype.beginEvent.call(this);
    ...
}

sramp
Active Member
Posts: 26
Joined: Mon Dec 02, 2013 4:15 pm

Re: Exception

Post by sramp » Wed Dec 04, 2013 7:14 pm

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.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”