changeset 25320:2ad00275b79b

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Thu, 26 Apr 2018 21:58:16 -0400
parents bb43ec3a304e (current diff) 56201aad3462 (diff)
children 089852fc8929
files libinterp/octave-value/ov-classdef.cc test/module.mk
diffstat 7 files changed, 88 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-classdef.cc	Thu Apr 26 06:49:06 2018 -0400
+++ b/libinterp/octave-value/ov-classdef.cc	Thu Apr 26 21:58:16 2018 -0400
@@ -1804,6 +1804,47 @@
 
 handle_cdef_object::~handle_cdef_object (void)
 {
+  octave::unwind_protect frame;
+
+  // Clear interrupts.
+  frame.protect_var (octave_interrupt_state);
+  octave_interrupt_state = 0;
+
+  // Disallow quit().
+  frame.protect_var (quit_allowed);
+  quit_allowed = false;
+
+  interpreter_try (frame);
+
+  try
+    {
+      // Call classdef "delete()" method on object
+      get_class ().delete_object (get_class ());
+    }
+  catch (const octave::interrupt_exception&)
+    {
+      octave::interpreter::recover_from_exception ();
+
+      warning ("interrupt occurred in handle class delete method");
+    }
+  catch (const octave::execution_exception&)
+    {
+      std::string msg = last_error_message ();
+      warning ("error caught while executing handle class delete method:\n%s\n",
+               msg.c_str ());
+
+    }
+  catch (const octave::exit_exception&)
+    {
+      // This shouldn't happen since we disabled quit above.
+      warning ("exit disabled while executing handle class delete method");
+    }
+  catch (...) // Yes, the black hole.  We're in a d-tor.
+    {
+      // This shouldn't happen, in theory.
+      warning ("internal error: unhandled exception in handle class delete method");
+    }
+
 #if DEBUG_TRACE
   std::cerr << "deleting " << get_class ().get_name ()
             << " object (handle)" << std::endl;
--- a/libinterp/parse-tree/pt-eval.h	Thu Apr 26 06:49:06 2018 -0400
+++ b/libinterp/parse-tree/pt-eval.h	Thu Apr 26 21:58:16 2018 -0400
@@ -309,11 +309,13 @@
 
         case RT_VALUE:
           retval = m_expr_result_value;
+          m_expr_result_value = octave_value ();
           break;
 
         case RT_VALUE_LIST:
           retval = (m_expr_result_value_list.empty ()
                     ? octave_value () : m_expr_result_value_list(0));
+          m_expr_result_value_list = octave_value_list ();
           break;
         }
 
@@ -338,10 +340,12 @@
 
         case RT_VALUE:
           retval = ovl (m_expr_result_value);
+          m_expr_result_value = octave_value ();
           break;
 
         case RT_VALUE_LIST:
           retval = m_expr_result_value_list;
+          m_expr_result_value_list = octave_value_list ();
           break;
         }
 
--- a/scripts/sparse/eigs.m	Thu Apr 26 06:49:06 2018 -0400
+++ b/scripts/sparse/eigs.m	Thu Apr 26 21:58:16 2018 -0400
@@ -1430,7 +1430,11 @@
 %! opts.maxit = 10;
 %! warning ("off", "Octave:eigs:UnconvergedEigenvalues", "local");
 %! d = eigs (A, 10, "sm", opts);
-%! assert (d(10), NaN+1i*NaN);
+%! if (isreal (d))
+%!   assert (d(10), NaN);
+%! else
+%!   assert (d(10), NaN +1i*NaN);
+%! endif
 %!testif HAVE_ARPACK
 %! A = toeplitz ([0, 1, zeros(1, 8)], [0, -1, zeros(1, 8)]);
 %! A = kron (A, eye (10)) + kron (eye (10), A);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-46497/bug-46497.tst	Thu Apr 26 21:58:16 2018 -0400
@@ -0,0 +1,24 @@
+## Copyright (C) 2017 Piotr Held
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or
+## (at your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+%!test
+%! global __bug46497_global__
+%! __bug46497_global__ = 'test_bug46497';
+%! a = class_bug46497 ();
+%! a = [];
+%! assert(__bug46497_global__,'deleted');
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-46497/class_bug46497.m	Thu Apr 26 21:58:16 2018 -0400
@@ -0,0 +1,8 @@
+classdef class_bug46497 < handle
+  methods
+    function delete (self)
+      global __bug46497_global__
+      __bug46497_global__ = 'deleted';
+    endfunction
+  endmethods
+endclassdef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-46497/module.mk	Thu Apr 26 21:58:16 2018 -0400
@@ -0,0 +1,5 @@
+bug_46497_TEST_FILES = \
+  %reldir%/bug-46497.tst \
+  %reldir%/class_bug46497.m
+
+TEST_FILES += $(bug_46497_TEST_FILES)
--- a/test/module.mk	Thu Apr 26 06:49:06 2018 -0400
+++ b/test/module.mk	Thu Apr 26 21:58:16 2018 -0400
@@ -56,6 +56,7 @@
 include %reldir%/bug-38691/module.mk
 include %reldir%/bug-41723/module.mk
 include %reldir%/bug-44940/module.mk
+include %reldir%/bug-46497/module.mk
 include %reldir%/bug-46660/module.mk
 include %reldir%/bug-49379/module.mk
 include %reldir%/bug-50014/module.mk