From 958cb3e71026ec925b10ef425c82cdad9df24813 Mon Sep 17 00:00:00 2001 From: Vincent COUVERT Date: Tue, 18 Sep 2012 12:01:16 +0200 Subject: [PATCH] * Bug #11657 fixed - Setting the callback_type property of an uicontrol was not taken into account. Change-Id: I6371e4aa589ad5fdd4618a95e9044ee738c81a90 --- scilab/CHANGES_5.4.X | 3 + .../getHandleProperty/set_callback_type_property.c | 11 +++- .../org/scilab/modules/gui/SwingViewWidget.java | 7 ++- .../gui/tests/nonreg_tests/bug_11657.dia.ref | 58 ++++++++++++++++++++ .../modules/gui/tests/nonreg_tests/bug_11657.tst | 27 +++++++++ 5 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 scilab/modules/gui/tests/nonreg_tests/bug_11657.dia.ref create mode 100644 scilab/modules/gui/tests/nonreg_tests/bug_11657.tst diff --git a/scilab/CHANGES_5.4.X b/scilab/CHANGES_5.4.X index 09f6fec..e6dc998 100644 --- a/scilab/CHANGES_5.4.X +++ b/scilab/CHANGES_5.4.X @@ -66,6 +66,9 @@ Bug Fixes * Bug #11558 fixed - Typo in helptools module fixed. +* Bug #11657 fixed - Setting the callback_type property of an uicontrol was not + taken into account. + * Bug #11684 fixed - mfft failed due to MKL fftw library restrictions. * Bug #11688 fixed - The example in example_run help page failed. diff --git a/scilab/modules/graphics/src/c/getHandleProperty/set_callback_type_property.c b/scilab/modules/graphics/src/c/getHandleProperty/set_callback_type_property.c index f791a8f..94b4ba6 100644 --- a/scilab/modules/graphics/src/c/getHandleProperty/set_callback_type_property.c +++ b/scilab/modules/graphics/src/c/getHandleProperty/set_callback_type_property.c @@ -33,7 +33,7 @@ int set_callback_type_property(void* _pvCtx, char* pobjUID, size_t stackPointer, int valueType, int nbRow, int nbCol ) { BOOL status = FALSE; - double callbackType = 0.0; + int callbackType = 0; if ( !( valueType == sci_matrix ) ) { @@ -46,7 +46,14 @@ int set_callback_type_property(void* _pvCtx, char* pobjUID, size_t stackPointer, return SET_PROPERTY_ERROR; } - callbackType = getDoubleFromStack(stackPointer); + callbackType = (int) getDoubleFromStack(stackPointer); + + /* Check the value */ + if (callbackType < -1 || callbackType > 2) + { + Scierror(999, _("Wrong value for '%s' property: %d, %d, %d or %d expected.\n"), "callback_type", -1, 0, 1, 2); + return SET_PROPERTY_ERROR; + } status = setGraphicObjectProperty(pobjUID, __GO_CALLBACKTYPE__, &callbackType, jni_int, 1); diff --git a/scilab/modules/gui/src/java/org/scilab/modules/gui/SwingViewWidget.java b/scilab/modules/gui/src/java/org/scilab/modules/gui/SwingViewWidget.java index 03e23a9..5f7a8c9 100644 --- a/scilab/modules/gui/src/java/org/scilab/modules/gui/SwingViewWidget.java +++ b/scilab/modules/gui/src/java/org/scilab/modules/gui/SwingViewWidget.java @@ -48,6 +48,7 @@ import java.awt.Color; import java.awt.Font; import org.scilab.modules.graphic_objects.graphicController.GraphicController; +import org.scilab.modules.graphic_objects.graphicObject.CallBack; import org.scilab.modules.gui.bridge.checkbox.SwingScilabCheckBox; import org.scilab.modules.gui.bridge.listbox.SwingScilabListBox; import org.scilab.modules.gui.bridge.popupmenu.SwingScilabPopupMenu; @@ -102,7 +103,11 @@ public final class SwingViewWidget { uiControl.setCallback(CommonCallBack.createCallback((String) value, cbType, uid)); } else if (property.equals(__GO_CALLBACKTYPE__)) { String cbString = (String) GraphicController.getController().getProperty(uid, __GO_CALLBACK__); - uiControl.setCallback(CommonCallBack.createCallback(cbString, (Integer) value, uid)); + if ((Integer) value == CallBack.UNTYPED) { /* Deactivate callback */ + uiControl.setCallback(null); + } else { + uiControl.setCallback(CommonCallBack.createCallback(cbString, (Integer) value, uid)); + } } else if (property.equals(__GO_CHILDREN__)) { /* Nothing to do */ } else if (property.equals(__GO_UI_ENABLE__)) { diff --git a/scilab/modules/gui/tests/nonreg_tests/bug_11657.dia.ref b/scilab/modules/gui/tests/nonreg_tests/bug_11657.dia.ref new file mode 100644 index 0000000..567b07b --- /dev/null +++ b/scilab/modules/gui/tests/nonreg_tests/bug_11657.dia.ref @@ -0,0 +1,58 @@ +// ============================================================================= +// 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 11657 --> +// <-- TEST WITH GRAPHIC --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/11657 +// +// <-- Short Description --> +// Setting the callback_type property of an uicontrol was not taken into account. +c = uicontrol(gcf(),"style","checkbox","string","Test","position", .. + [10,400,100,15],"callback","disp(""Hello"")") + c = + +Handle of type "uicontrol" with properties: +=========================================== +Parent: Figure +Children: [] +BackgroundColor = [0.8,0.8,0.8] +Enable = "on" +FontAngle = normal +FontName = helvetica +FontSize = 10 +FontUnits = points +FontWeight = normal +ForegroundColor = [0,0,0] +HorizontalAlignment = center +ListboxTop = [] +Max = 1 +Min = 0 +Position = [10,400,100,15] +Relief = flat +SliderStep = [0.01,0.1] +String = "Test" +Style = checkbox +TooltipString = "" +Units = pixels +Value = 0 +VerticalAlignment = middle +Visible = "on" +Callback = disp("Hello") +Callback_Type = 0 +Handle_Visible = "on" +Userdata = [] +Tag = +assert_checkequal(c.callback_type, 0); +c.callback_type = -1; +callbackType = -1 +assert_checkequal(c.callback_type, -1); +refMsg = msprintf(_("Wrong value for ''%s'' property: %d, %d, %d or %d expected.\n"), "callback_type", -1, 0, 1, 2); +assert_checkerror("c;c.callback_type = 10;", refMsg); +callbackType = 10 +delete(gcf()); diff --git a/scilab/modules/gui/tests/nonreg_tests/bug_11657.tst b/scilab/modules/gui/tests/nonreg_tests/bug_11657.tst new file mode 100644 index 0000000..152eb28 --- /dev/null +++ b/scilab/modules/gui/tests/nonreg_tests/bug_11657.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// 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 11657 --> +// <-- TEST WITH GRAPHIC --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/11657 +// +// <-- Short Description --> +// Setting the callback_type property of an uicontrol was not taken into account. + +c = uicontrol(gcf(),"style","checkbox","string","Test","position", .. + [10,400,100,15],"callback","disp(""Hello"")") +assert_checkequal(c.callback_type, 0); + +c.callback_type = -1; +assert_checkequal(c.callback_type, -1); + +refMsg = msprintf(_("Wrong value for ''%s'' property: %d, %d, %d or %d expected.\n"), "callback_type", -1, 0, 1, 2); +assert_checkerror("c;c.callback_type = 10;", refMsg); + +delete(gcf()); \ No newline at end of file -- 1.7.9.5