Define destructor for Scripting

This commit is contained in:
GriffinR 2024-08-13 15:12:02 -04:00
parent bb0071e8ca
commit 724b35be95
2 changed files with 9 additions and 6 deletions

View file

@ -30,8 +30,9 @@ class Scripting
{
public:
Scripting(MainWindow *mainWindow);
static void stop();
~Scripting();
static void init(MainWindow *mainWindow);
static void stop();
static void populateGlobalObject(MainWindow *mainWindow);
static QJSEngine *getEngine();
static void invokeAction(int actionIndex);

View file

@ -24,11 +24,6 @@ const QMap<CallbackType, QString> callbackFunctions = {
Scripting *instance = nullptr;
void Scripting::stop() {
if (!instance) return;
instance->engine->setInterrupted(true);
qDeleteAll(instance->imageCache);
delete instance->engine;
delete instance->scriptUtility;
delete instance;
instance = nullptr;
}
@ -54,6 +49,13 @@ Scripting::Scripting(MainWindow *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) {
for (QString filepath : moduleFiles) {
QString validPath = Project::getExistingFilepath(filepath);