diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 3a2e9ff03..b5bdf0543 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -41,9 +41,6 @@ public: , m_queue( queue ) , m_jobIndex( 0 ) { -#ifdef WITH_PYTHON - new CalamaresPython::Helper( this ); -#endif } void setJobs( const JobList& jobs ) diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index 4f2f30e76..f274ac276 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -231,7 +231,9 @@ Helper::Helper( QObject* parent ) } Helper::~Helper() -{} +{ + s_instance = nullptr; +} boost::python::dict diff --git a/src/libcalamares/PythonHelper.h b/src/libcalamares/PythonHelper.h index e552a869d..d48e5eaab 100644 --- a/src/libcalamares/PythonHelper.h +++ b/src/libcalamares/PythonHelper.h @@ -48,7 +48,6 @@ class Helper : public QObject { Q_OBJECT public: - explicit Helper( QObject* parent = nullptr ); virtual ~Helper(); boost::python::dict createCleanNamespace(); @@ -57,6 +56,7 @@ public: private: friend Helper* Calamares::PythonJob::helper(); + explicit Helper( QObject* parent = nullptr ); static Helper* s_instance; boost::python::object m_mainModule; diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index faf2fa72d..a9fe4463e 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -381,8 +381,10 @@ PythonJob::emitProgress( qreal progressValue ) CalamaresPython::Helper* PythonJob::helper() { - return CalamaresPython::Helper::s_instance; - + auto ptr = CalamaresPython::Helper::s_instance; + if (!ptr) + ptr = new CalamaresPython::Helper; + return ptr; }