Index: src/ov-dld-fcn.h =================================================================== RCS file: /cvs/octave/src/ov-dld-fcn.h,v retrieving revision 1.13 diff -c -p -r1.13 ov-dld-fcn.h *** src/ov-dld-fcn.h 12 Oct 2007 21:27:31 -0000 1.13 --- src/ov-dld-fcn.h 7 Jan 2008 13:55:53 -0000 *************** public: *** 65,70 **** --- 65,75 ---- bool is_builtin_function (void) const { return false; } bool is_dld_function (void) const { return true; } + + static octave_dld_function* create (octave_builtin::fcn ff, + const octave_shlib& shl, + const std::string& nm = std::string (), + const std::string& ds = std::string ()); private: Index: src/ov-dld-fcn.cc =================================================================== RCS file: /cvs/octave/src/ov-dld-fcn.cc,v retrieving revision 1.14 diff -c -p -r1.14 ov-dld-fcn.cc *** src/ov-dld-fcn.cc 12 Oct 2007 21:27:31 -0000 1.14 --- src/ov-dld-fcn.cc 7 Jan 2008 13:55:53 -0000 *************** octave_dld_function::time_parsed (void) *** 72,77 **** --- 72,94 ---- return sh_lib.time_loaded (); } + // Note: this is a wrapper around octave_dld_function constructor added in + // order to work around a MSVC limitation handling in virtual destructors + // that prevents to unload a dynamic module before *all* objects (of + // class using a virtual dtor) have been fully deleted; indeed, MSVC + // attaches auto-generated code (scalar deleting destructor) to objects + // created in a dynamic module, and this code will be executed in the + // dynamic module context at object deletion; unloading the dynamic + // module before objects have been deleted will make the "delete" code + // of objects to point to an invalid code segment. + octave_dld_function* + octave_dld_function::create (octave_builtin::fcn ff, const octave_shlib& shl, + const std::string& nm = std::string (), + const std::string& ds = std::string ()) + { + return new octave_dld_function (ff, shl, nm, ds); + } + /* ;;; Local Variables: *** ;;; mode: C++ *** Index: src/defun-int.h =================================================================== RCS file: /cvs/octave/src/defun-int.h,v retrieving revision 1.61 diff -c -p -r1.61 defun-int.h *** src/defun-int.h 28 Dec 2007 20:56:56 -0000 1.61 --- src/defun-int.h 7 Jan 2008 13:55:53 -0000 *************** typedef octave_function * (*octave_dld_f *** 120,126 **** \ if (! error_state) \ { \ ! octave_dld_function *fcn = new octave_dld_function (fname, shl, name, doc); \ \ if (relative) \ fcn->mark_relative (); \ --- 120,126 ---- \ if (! error_state) \ { \ ! octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \ \ if (relative) \ fcn->mark_relative (); \