Explorar o código

fix the figsize segfault bug

plt::figure_size is known to sometimes cause segfaults if called
without a preceding plt::figure
as suggested in the issues this is fixed by calling
detail::_interpreter::get() at the beginning of the function
jul %!s(int64=6) %!d(string=hai) anos
pai
achega
4ace1ad946
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      matplotlibcpp.h

+ 3 - 0
matplotlibcpp.h

@@ -1116,6 +1116,9 @@ inline bool fignum_exists(long number)
 
 inline void figure_size(size_t w, size_t h)
 {
+    // Make sure interpreter is initialised
+    detail::_interpreter::get();
+
     const size_t dpi = 100;
     PyObject* size = PyTuple_New(2);
     PyTuple_SetItem(size, 0, PyFloat_FromDouble((double)w / dpi));