From b2a078feca3252ce8b5fc8e1b54aaf32e0126fdb Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@gmail.com> Date: Thu, 27 Sep 2018 09:29:12 +0100 Subject: [PATCH] Remove static qualifier on module imports Marking them static causes their destruction to happen on program exit and after Py_Finalize has been called resulting in a segfault on Python 3 --- qt/widgets/mplcpp/src/Colormap.cpp | 2 +- qt/widgets/mplcpp/src/Colors.cpp | 2 +- qt/widgets/mplcpp/src/Figure.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qt/widgets/mplcpp/src/Colormap.cpp b/qt/widgets/mplcpp/src/Colormap.cpp index 14f5fc8261e..e1da71ebf63 100644 --- a/qt/widgets/mplcpp/src/Colormap.cpp +++ b/qt/widgets/mplcpp/src/Colormap.cpp @@ -19,7 +19,7 @@ Colormap::Colormap(Python::Object obj) * @return A reference to the matplotlib.cm module */ Python::Object cmModule() { - static Python::Object cmModule{ + Python::Object cmModule{ Python::NewRef(PyImport_ImportModule("matplotlib.cm"))}; return cmModule; } diff --git a/qt/widgets/mplcpp/src/Colors.cpp b/qt/widgets/mplcpp/src/Colors.cpp index e716eea88e1..9122de96d55 100644 --- a/qt/widgets/mplcpp/src/Colors.cpp +++ b/qt/widgets/mplcpp/src/Colors.cpp @@ -12,7 +12,7 @@ namespace { * @return A reference to the matplotlib.colors module */ Python::Object colorsModule() { - static Python::Object colorsModule{ + Python::Object colorsModule{ Python::NewRef(PyImport_ImportModule("matplotlib.colors"))}; return colorsModule; } diff --git a/qt/widgets/mplcpp/src/Figure.cpp b/qt/widgets/mplcpp/src/Figure.cpp index eee54ab144a..5e1fb6f3a5d 100644 --- a/qt/widgets/mplcpp/src/Figure.cpp +++ b/qt/widgets/mplcpp/src/Figure.cpp @@ -6,7 +6,7 @@ namespace MplCpp { namespace { Python::Object newFigure(bool tightLayout = true) { - static Python::Object figureModule{ + Python::Object figureModule{ Python::NewRef(PyImport_ImportModule("matplotlib.figure"))}; auto fig = figureModule.attr("Figure")(); if (tightLayout) { -- GitLab