From: Clément DAVID Date: Thu, 6 Jul 2017 10:41:07 +0000 (+0200) Subject: * Bug #15207 fixed : `xcos(scs_m)` did not work for sub-systems. X-Git-Tag: 6.0.1~259 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=8ba60855ed1cdf800c914c22dfd478e655d3891b * Bug #15207 fixed : `xcos(scs_m)` did not work for sub-systems. Change-Id: I657da9558bf9b52da1b9457dc83ea82e0133fd9c --- diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 963b133..d03b9ff 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -387,6 +387,7 @@ the [development mailing list](dev@lists.scilab.org) for a particular toolbox. * [#15185](http://bugzilla.scilab.org/show_bug.cgi?id=15185): "Region to Superblock" did not restore broken links. * [#15188](http://bugzilla.scilab.org/show_bug.cgi?id=15188): Failed to load hdf5_is_file function. * [#15205](http://bugzilla.scilab.org/show_bug.cgi?id=15205): `get_scicos_version` returned the previous version. +* [#15207](http://bugzilla.scilab.org/show_bug.cgi?id=15207): `xcos(scs_m)` did not work for sub-systems. ### Bugs fixed in 6.0.0: * [#592](http://bugzilla.scilab.org/show_bug.cgi?id=592): `linspace(a, b, n<=0)` returned `b` instead of `[]` diff --git a/scilab/modules/xcos/sci_gateway/cpp/sci_Xcos.cpp b/scilab/modules/xcos/sci_gateway/cpp/sci_Xcos.cpp index 114fc72..4dcf8f3 100644 --- a/scilab/modules/xcos/sci_gateway/cpp/sci_Xcos.cpp +++ b/scilab/modules/xcos/sci_gateway/cpp/sci_Xcos.cpp @@ -103,7 +103,12 @@ types::Function::ReturnValue sci_Xcos(types::typed_list &in, int _iRetCount, typ if (in.size() == 1 && in[0]->isUserType()) { const model::BaseObject* o = view_scilab::Adapters::instance().descriptor(in[0]); - if (o == nullptr || o->kind() != DIAGRAM) + if (o == nullptr) + { + Scierror(77, _("%s: Wrong type for input argument #%d: ""%s"" expected.\n"), funname, 1, "diagram"); + return types::Function::Error; + } + if (o->kind() != DIAGRAM && o->kind() != BLOCK) { Scierror(77, _("%s: Wrong type for input argument #%d: ""%s"" expected.\n"), funname, 1, "diagram"); return types::Function::Error; diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java index 55b3540..e79dae1 100644 --- a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java +++ b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/Xcos.java @@ -498,10 +498,10 @@ public final class Xcos { /* * Allocate and setup a new diagram */ - diag = new XcosDiagram(controller, currentId, Kind.DIAGRAM, ""); + diag = new XcosDiagram(controller, currentId, controller.getKind(currentId), ""); diag.installListeners(); - root = new ScicosObjectOwner(controller, diag.getUID(), Kind.DIAGRAM); + root = findRoot(controller, diag); addDiagram(root, diag); /* diff --git a/scilab/modules/xcos/tests/unit_tests/xcos.tst b/scilab/modules/xcos/tests/unit_tests/xcos.tst index d8c5531..cdc8c54 100644 --- a/scilab/modules/xcos/tests/unit_tests/xcos.tst +++ b/scilab/modules/xcos/tests/unit_tests/xcos.tst @@ -2,36 +2,36 @@ // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) 2009 - DIGITEO // Copyright (C) 2012 - Scilab Enterprises - Clement DAVID +// Copyright (C) 2017 - ESI Group - Clement DAVID // // This file is distributed under the same license as the Scilab package. // ============================================================================ -// <-- TEST WITH GRAPHIC --> -// <-- NOT FIXED --> - -// libs are not loaded at startup -if isdef("BIGSOM_f") then pause, end +// <-- TEST WITH XCOS --> +// <-- INTERACTIVE TEST --> // we launch xcos then libs should be loaded xcos(); -sleep(500); -if ~isdef("BIGSOM_f") then pause, end // we launch xcos with an xcos demo file xcos(SCI + "/modules/xcos/demos/Simple_Demo.zcos"); -sleep(500); // we launch xcos with an xcos demo file with full path resolution xcos("SCI/modules/xcos/demos/Simple_Demo.zcos"); -sleep(500); // we launch xcos with cosf file xcos(SCI + "/modules/scicos/palettes/Branching.cosf"); -sleep(500); // we launch xcos with a scs_m instance scs_m = scicos_diagram(); scs_m.objs($+1) = BIGSOM_f("define"); xcos(scs_m); -sleep(500); + +// we launch xcos with a full scs_m +importXcosDiagram(SCI+"/modules/xcos/demos/Discrete-KalmanFilter.zcos"); +xcos(scs_m); + +// we launch xcos with a scs_m subsystem +assert_checkequal(typeof(scs_m.objs(1).model.rpar), "diagram"); +xcos(scs_m.objs(1).model.rpar);