From 4340031b3d50aa12b3211800f038958159fb9ce7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20DAVID?= Date: Thu, 5 Jan 2012 09:21:36 +0100 Subject: [PATCH 1/1] * Bug #6733 fixed - Each call to xcos created an empty diagram. Change-Id: I11f83a9da0c2e7f746abdf394616ddbfe0ae6be8 --- scilab/CHANGES_5.4.X | 2 ++ .../src/java/org/scilab/modules/xcos/Xcos.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/scilab/CHANGES_5.4.X b/scilab/CHANGES_5.4.X index c0353f4..2e373fb 100644 --- a/scilab/CHANGES_5.4.X +++ b/scilab/CHANGES_5.4.X @@ -28,6 +28,8 @@ Xcos - SELECT_m - Selector block - NEGTOPOS_f - Threshold negative to positive +* Bug #6733 fixed - Each call to xcos created an empty diagram. + * Bug #8744 fixed - Solving the initialization problem more than once crash Scilab. 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 d8c5c73..03bef4e 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 @@ -414,14 +414,19 @@ public final class Xcos { if (filename != null && filename.exists()) { configuration.addToRecentFiles(filename); + } - /* - * looking for an already opened diagram - */ - final Collection diags = diagrams.get(filename); - if (diags != null && !diags.isEmpty()) { - diag = diags.iterator().next(); - } + /* + * looking for an already opened diagram + */ + final Collection diags = diagrams.get(filename); + if (diags != null && !diags.isEmpty()) { + diag = diags.iterator().next(); + } + // if unsaved and empty, reuse it. Allocate otherwise. + if (filename == null && diag != null && + diag.getModel().getChildCount(diag.getDefaultParent()) > 0) { + diag = null; } if (diag == null) { -- 1.7.9.5