Browse Source

Increase ref counter of module JSON in ModuleWidget::pasteJsonAction() when giving shared ownership to history::ModuleChange action.

tags/v2.1.1
Andrew Belt 2 years ago
parent
commit
974fe13d2f
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      src/app/ModuleWidget.cpp

+ 3
- 1
src/app/ModuleWidget.cpp View File

@@ -506,13 +506,13 @@ bool ModuleWidget::pasteJsonAction(json_t* moduleJ) {
engine::Module::jsonStripIds(moduleJ); engine::Module::jsonStripIds(moduleJ);


json_t* oldModuleJ = toJson(); json_t* oldModuleJ = toJson();
DEFER({json_decref(oldModuleJ);});


try { try {
fromJson(moduleJ); fromJson(moduleJ);
} }
catch (Exception& e) { catch (Exception& e) {
WARN("%s", e.what()); WARN("%s", e.what());
json_decref(oldModuleJ);
return false; return false;
} }


@@ -520,7 +520,9 @@ bool ModuleWidget::pasteJsonAction(json_t* moduleJ) {
history::ModuleChange* h = new history::ModuleChange; history::ModuleChange* h = new history::ModuleChange;
h->name = "paste module preset"; h->name = "paste module preset";
h->moduleId = module->id; h->moduleId = module->id;
json_incref(oldModuleJ);
h->oldModuleJ = oldModuleJ; h->oldModuleJ = oldModuleJ;
json_incref(moduleJ);
h->newModuleJ = moduleJ; h->newModuleJ = moduleJ;
APP->history->push(h); APP->history->push(h);
return true; return true;


Loading…
Cancel
Save