Skip to content

Commit

Permalink
Define destructor for Scripting
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards committed Aug 13, 2024
1 parent bb0071e commit 724b35b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion include/scripting.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions src/scriptapi/scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down

0 comments on commit 724b35b

Please sign in to comment.