[libcalamares] Enforce singleton-ness of CalamaresPython::Helper
- unset instance pointer on destruction - make constructor private, and the instance accessor should create an instance if there isn't one.
This commit is contained in:
parent
86b899566e
commit
abc6914528
@ -41,9 +41,6 @@ public:
|
||||
, m_queue( queue )
|
||||
, m_jobIndex( 0 )
|
||||
{
|
||||
#ifdef WITH_PYTHON
|
||||
new CalamaresPython::Helper( this );
|
||||
#endif
|
||||
}
|
||||
|
||||
void setJobs( const JobList& jobs )
|
||||
|
@ -231,7 +231,9 @@ Helper::Helper( QObject* parent )
|
||||
}
|
||||
|
||||
Helper::~Helper()
|
||||
{}
|
||||
{
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
|
||||
boost::python::dict
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user