Define destructor for Scripting
This commit is contained in:
parent
bb0071e8ca
commit
724b35be95
2 changed files with 9 additions and 6 deletions
|
@ -30,8 +30,9 @@ class Scripting
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Scripting(MainWindow *mainWindow);
|
Scripting(MainWindow *mainWindow);
|
||||||
static void stop();
|
~Scripting();
|
||||||
static void init(MainWindow *mainWindow);
|
static void init(MainWindow *mainWindow);
|
||||||
|
static void stop();
|
||||||
static void populateGlobalObject(MainWindow *mainWindow);
|
static void populateGlobalObject(MainWindow *mainWindow);
|
||||||
static QJSEngine *getEngine();
|
static QJSEngine *getEngine();
|
||||||
static void invokeAction(int actionIndex);
|
static void invokeAction(int actionIndex);
|
||||||
|
|
|
@ -24,11 +24,6 @@ const QMap<CallbackType, QString> callbackFunctions = {
|
||||||
Scripting *instance = nullptr;
|
Scripting *instance = nullptr;
|
||||||
|
|
||||||
void Scripting::stop() {
|
void Scripting::stop() {
|
||||||
if (!instance) return;
|
|
||||||
instance->engine->setInterrupted(true);
|
|
||||||
qDeleteAll(instance->imageCache);
|
|
||||||
delete instance->engine;
|
|
||||||
delete instance->scriptUtility;
|
|
||||||
delete instance;
|
delete instance;
|
||||||
instance = nullptr;
|
instance = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +49,13 @@ Scripting::Scripting(MainWindow *mainWindow) {
|
||||||
this->scriptUtility = new ScriptUtility(mainWindow);
|
this->scriptUtility = new ScriptUtility(mainWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Scripting::~Scripting() {
|
||||||
|
this->engine->setInterrupted(true);
|
||||||
|
qDeleteAll(this->imageCache);
|
||||||
|
delete this->engine;
|
||||||
|
delete this->scriptUtility;
|
||||||
|
}
|
||||||
|
|
||||||
void Scripting::loadModules(QStringList moduleFiles) {
|
void Scripting::loadModules(QStringList moduleFiles) {
|
||||||
for (QString filepath : moduleFiles) {
|
for (QString filepath : moduleFiles) {
|
||||||
QString validPath = Project::getExistingFilepath(filepath);
|
QString validPath = Project::getExistingFilepath(filepath);
|
||||||
|
|
Loading…
Reference in a new issue