Browse Source

Fix some segfaults when destroying environment.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
1dcaf6c1bc
3 changed files with 16 additions and 15 deletions
  1. +4
    -3
      src/gamepad.cpp
  2. +5
    -5
      src/patch.cpp
  3. +7
    -7
      src/plugin.cpp

+ 4
- 3
src/gamepad.cpp View File

@@ -12,6 +12,7 @@ struct Driver;


static const int DRIVER = -10;
static Driver* driver = NULL;


struct InputDevice : midi::InputDevice {
@@ -116,17 +117,17 @@ struct Driver : midi::Driver {
};


static Driver driver;


void init() {
midi::addDriver(DRIVER, &driver);
driver = new Driver;
midi::addDriver(DRIVER, driver);
}

void step() {
for (int i = 0; i < 16; i++) {
if (glfwJoystickPresent(i)) {
driver.devices[i].step();
driver->devices[i].step();
}
}
}


+ 5
- 5
src/patch.cpp View File

@@ -265,15 +265,15 @@ json_t* PatchManager::toJson() {
json_t* versionJ = json_string(APP_VERSION.c_str());
json_object_set_new(rootJ, "version", versionJ);

json_t* engineJ = APP->engine->toJson();
if (APP->scene) {
APP->scene->rack->mergeJson(engineJ);
}

// Merge with rootJ
json_t* engineJ = APP->engine->toJson();
json_object_update(rootJ, engineJ);
json_decref(engineJ);

if (APP->scene) {
APP->scene->rack->mergeJson(rootJ);
}

return rootJ;
}



+ 7
- 7
src/plugin.cpp View File

@@ -242,18 +242,18 @@ void init() {

void destroy() {
for (Plugin* plugin : plugins) {
// We must delete the plugin *before* freeing the library, because the vtable of Model subclasses are static in the plugin, and we need it for the virtual destructor.
void* handle = plugin->handle;
delete plugin;

// Free library handle
if (plugin->handle) {
if (handle) {
#if defined ARCH_WIN
FreeLibrary((HINSTANCE) plugin->handle);
FreeLibrary((HINSTANCE) handle);
#else
dlclose(plugin->handle);
dlclose(handle);
#endif
}

// For some reason this segfaults.
// It might be best to let them leak anyway, because "crash on exit" issues would occur with badly-written plugins.
// delete plugin;
}
plugins.clear();
}


Loading…
Cancel
Save