From 9f6d213e849a24f0bb1b3772d886d99c679c8a1f Mon Sep 17 00:00:00 2001 From: Vincent COUVERT Date: Fri, 24 Aug 2012 15:22:28 +0200 Subject: [PATCH] * Bug #11685 fixed - gcbo variable was not defined when executing functions set as "closerequestfcn" and "resizefcn" properties. Change-Id: I0753575a7bf4a93f9de3ff63479e96e925cf81a7 --- scilab/CHANGES_5.4.X | 3 ++ .../modules/gui/bridge/tab/SwingScilabTab.java | 7 ++-- .../modules/gui/graphicWindow/PanelLayout.java | 6 +++- .../modules/gui/tests/nonreg_tests/bug_11685.tst | 37 ++++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 scilab/modules/gui/tests/nonreg_tests/bug_11685.tst diff --git a/scilab/CHANGES_5.4.X b/scilab/CHANGES_5.4.X index d5ffe19..2b10d00 100644 --- a/scilab/CHANGES_5.4.X +++ b/scilab/CHANGES_5.4.X @@ -128,6 +128,9 @@ Bug Fixes * Bugs #11666, #11667 and #11670 to 11676 fixed - Add examples in the signal processing help pages. +* Bug #11685 fixed - gcbo variable was not defined when executing functions set + as "closerequestfcn" and "resizefcn" properties. + * Bug #11686 fixed - An error occurred when clicking outside of an uicontextmenu area. * Bug #11697 fixed - ATOMS modules ar enow listed in the "Toolboxes" menu when diff --git a/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabTab.java b/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabTab.java index 838ea81..c614b6c 100644 --- a/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabTab.java +++ b/scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabTab.java @@ -57,7 +57,6 @@ import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import org.flexdock.docking.DockingConstants; -import org.flexdock.docking.DockingManager; import org.flexdock.docking.DockingPort; import org.flexdock.docking.activation.ActiveDockableTracker; import org.flexdock.docking.event.DockingEvent; @@ -329,7 +328,11 @@ public class SwingScilabTab extends View implements SwingViewObject, SimpleTab, public int canClose() { String closeRequestFcn = (String) GraphicController.getController().getProperty(getId(), __GO_CLOSEREQUESTFCN__); if (!closeRequestFcn.equals("")) { - InterpreterManagement.requestScilabExec(closeRequestFcn + ";fire_closing_finished()"); + String closeCommand = "if exists(\"gcbo\") then %oldgcbo = gcbo; end;" + + "gcbo = getcallbackobject(\"" + getId() + "\");" + + closeRequestFcn + ";fire_closing_finished();" + + ";if exists(\"%oldgcbo\") then gcbo = %oldgcbo; else clear gcbo; end;"; + InterpreterManagement.requestScilabExec(closeCommand); return -1; } else { closeAction.actionPerformed(null); diff --git a/scilab/modules/gui/src/java/org/scilab/modules/gui/graphicWindow/PanelLayout.java b/scilab/modules/gui/src/java/org/scilab/modules/gui/graphicWindow/PanelLayout.java index 224d5ca..eb5e8b4 100644 --- a/scilab/modules/gui/src/java/org/scilab/modules/gui/graphicWindow/PanelLayout.java +++ b/scilab/modules/gui/src/java/org/scilab/modules/gui/graphicWindow/PanelLayout.java @@ -65,7 +65,11 @@ public class PanelLayout implements LayoutManager, Serializable { String figureIdentifier = ((SwingScilabCanvas) parent).getFigure().getIdentifier(); String resizeFcn = (String) GraphicController.getController().getProperty(figureIdentifier, GraphicObjectProperties.__GO_RESIZEFCN__); if (resizeFcn != null && !resizeFcn.equals("")) { - InterpreterManagement.requestScilabExec(resizeFcn); + String resizeCommand = "if exists(\"gcbo\") then %oldgcbo = gcbo; end;" + + "gcbo = getcallbackobject(\"" + figureIdentifier + "\");" + + resizeFcn + + ";if exists(\"%oldgcbo\") then gcbo = %oldgcbo; else clear gcbo; end;"; + InterpreterManagement.requestScilabExec(resizeCommand); } /* Here you can perform the layout of UI object. */ diff --git a/scilab/modules/gui/tests/nonreg_tests/bug_11685.tst b/scilab/modules/gui/tests/nonreg_tests/bug_11685.tst new file mode 100644 index 0000000..c4c78b2 --- /dev/null +++ b/scilab/modules/gui/tests/nonreg_tests/bug_11685.tst @@ -0,0 +1,37 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Scilab Enterprises - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 11685 --> +// <-- TEST WITH GRAPHIC --> +// <-- INTERACTIVE TEST --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/11685 +// +// <-- Short Description --> +// gcbo variable was not defined when executing functions set +// as "closerequestfcn" and "resizefcn" properties. + +function resizeMe() + disp(gcbo); +endfunction +function closeMe() + disp(gcbo); + delete(gcbo) +endfunction + +f = figure(); +f.resizefcn = "resizeMe"; +f.closerequestfcn = "closeMe"; + +// Resize the figure & check that gcbo is displayed in the console + +// Click on the top-right cross of the figure to close it +// - check that gcbo is displayed in the console +// - check that the figure is closed + + -- 1.7.9.5