Device objects exist after being removed

The track device objects seem to exists after being removed, when the renoise.Track.devices_observable is banged. Is this a special case by purpose? It seems a bit inconsistent to how the API is behaving normally.

  1. add a device to track 1
  2. run code as tool
  3. delete the device
  4. the device name is written when it should return an error
function add_device_notifier(track_idx, device_idx)

  local device_obj = renoise.song():track(track_idx):device(device_idx)

  local notifier_func = function(event)
    -- this should return an error when device is removed,
    -- if the object is meant to be garbled before the
    -- observable is banged. the object still exists here.
    oprint(device_obj.name)
  end

  renoise.song():track(track_idx).devices_observable:add_notifier(notifier_func)

end

add_device_notifier(1, 2)

The device may be destroyed AFTER the event, so it actually might be a “before_remove” event. This makes a lot of sense.

Also, I need the target device object in the event in my case, or the track num and device num. Is it possible that you add it, @taktik ?

EDIT: But it seems the object already is destroyed, so above was a wrong assumption.

Hmm… the same seems to be true for track objects. This is not how I remember the API at all, but maybe I’ve learnt something new.

Strange, here the object is already removed. Which makes it impossible for me to use event.index then.

Because it’s not available/fetchabe (returnable) as an object from renoise.Song, but it’s not yet garbage collected as an object.

EDIT: this is an explanation of how it works now.

Of course the reference is addable. It is just a reference. Inside a “before_remove” event. Very common world standard :stuck_out_tongue: