Skip to content

Commit 4ace1ad

Browse files
Cryorislava
authored andcommitted
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
1 parent 94c0215 commit 4ace1ad

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

matplotlibcpp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,9 @@ inline bool fignum_exists(long number)
11161116

11171117
inline void figure_size(size_t w, size_t h)
11181118
{
1119+
// Make sure interpreter is initialised
1120+
detail::_interpreter::get();
1121+
11191122
const size_t dpi = 100;
11201123
PyObject* size = PyTuple_New(2);
11211124
PyTuple_SetItem(size, 0, PyFloat_FromDouble((double)w / dpi));

0 commit comments

Comments
 (0)