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);

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

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

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


Loading…
Cancel
Save