MCPcopy Create free account
hub / github.com/DISTRHO/DPF / unref_edit_controller

Function unref_edit_controller

distrho/src/DistrhoPluginVST3.cpp:3597–3637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3595 }
3596
3597 static uint32_t V3_API unref_edit_controller(void* const self)
3598 {
3599 dpf_edit_controller** const controllerptr = static_cast<dpf_edit_controller**>(self);
3600 dpf_edit_controller* const controller = *controllerptr;
3601
3602 if (const int refcount = --controller->refcounter)
3603 {
3604 d_debug("dpf_edit_controller::unref => %p | refcount %i", self, refcount);
3605 return refcount;
3606 }
3607
3608 #if DPF_VST3_USES_SEPARATE_CONTROLLER
3609 /**
3610 * Some hosts will have unclean instances of a few of the controller child classes at this point.
3611 * We check for those here, going through the whole possible chain to see if it is safe to delete.
3612 * If not, we add this controller to the `gControllerGarbage` global which will take care of it during unload.
3613 */
3614
3615 bool unclean = false;
3616
3617 if (dpf_comp2ctrl_connection_point* const point = controller->connectionComp2Ctrl)
3618 {
3619 if (const int refcount = point->refcounter)
3620 {
3621 unclean = true;
3622 d_stderr("DPF warning: asked to delete controller while component connection point still active (refcount %d)", refcount);
3623 }
3624 }
3625
3626 if (unclean)
3627 return handleUncleanController(controllerptr);
3628
3629 d_debug("dpf_edit_controller::unref => %p | refcount is zero, deleting everything now!", self);
3630
3631 delete controller;
3632 delete controllerptr;
3633 #else
3634 d_debug("dpf_edit_controller::unref => %p | refcount is zero, deletion will be done by component later", self);
3635 #endif
3636 return 0;
3637 }
3638
3639 // ----------------------------------------------------------------------------------------------------------------
3640 // v3_plugin_base

Callers

nothing calls this directly

Calls 3

d_debugFunction · 0.85
d_stderrFunction · 0.85
handleUncleanControllerFunction · 0.85

Tested by

no test coverage detected