* Bug #11685 fixed - gcbo variable was not defined when executing functions set 01/8801/2
Vincent COUVERT [Fri, 24 Aug 2012 13:22:28 +0000 (15:22 +0200)]
                     as "closerequestfcn" and "resizefcn" properties.

Change-Id: I0753575a7bf4a93f9de3ff63479e96e925cf81a7

scilab/CHANGES_5.4.X
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/tab/SwingScilabTab.java
scilab/modules/gui/src/java/org/scilab/modules/gui/graphicWindow/PanelLayout.java
scilab/modules/gui/tests/nonreg_tests/bug_11685.tst [new file with mode: 0644]

index d5ffe19..2b10d00 100644 (file)
@@ -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
index 838ea81..c614b6c 100644 (file)
@@ -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);
index 224d5ca..eb5e8b4 100644 (file)
@@ -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 (file)
index 0000000..c4c78b2
--- /dev/null
@@ -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
+
+