diff --git a/src/octave_file_io.cpp b/src/octave_file_io.cpp index 99dae0a..36482a2 100644 --- a/src/octave_file_io.cpp +++ b/src/octave_file_io.cpp @@ -57,12 +57,20 @@ public: static octave_file_io_intf* get_instance () { static octave_file_io_intf instance; + std::cerr << "ADDRESS OF INSTANCE: " << &instance << std::endl; return &instance; } octave_file_io_intf (octave_file_io_intf const&) = delete; void operator=(octave_file_io_intf const&) = delete; - + + void cleanup (void) + { + std::cerr << "CLEANUP for object: " << this << std::endl; + interp->shutdown (); + delete interp; + } + octave::interpreter *interp; std::string filename; octave_io_mode current_mode; @@ -93,8 +101,7 @@ octave_file_io_intf::~octave_file_io_intf () // FIXME : we are not shutting down and freeing the interpreter as this causes // a crash with Octave 6.0.91, the following should be uncommented as soon as // the issue is fixed, see https://savannah.gnu.org/bugs/?59228 - //interp->shutdown (); - //delete interp; + std::cerr << "octave_file_io_intf DESTRUCTOR for object: " << this << std::endl; } //--------------------------------------------------------------------- @@ -152,6 +159,13 @@ octave_io_close (void) return 0; } +void +octave_io_cleanup (void) +{ + octave_file_io_intf* io_intf = octave_file_io_intf::get_instance (); + io_intf->cleanup (); +} + int octave_load (const char* varname, octave_value &data) { diff --git a/src/octave_file_io.h b/src/octave_file_io.h index 33aa62a..690ced7 100644 --- a/src/octave_file_io.h +++ b/src/octave_file_io.h @@ -34,6 +34,9 @@ octave_io_open (const char*, const octave_io_mode, octave_io_mode*); int octave_io_close (void); +void +octave_io_cleanup (void); + int octave_load (const char*, octave_value&); diff --git a/test/io_test_par.cpp b/test/io_test_par.cpp index 6431801..426b6d4 100644 --- a/test/io_test_par.cpp +++ b/test/io_test_par.cpp @@ -122,5 +122,9 @@ int main (int argc, char **argv) MPI_Finalize (); + + octave_io_cleanup (); + + std::cerr << "MAIN IS DONE" << std::endl; return (0); }