justin = { main feed , music , code , askjf , pubkey };
Ask Justin Frankel
No reasonable question unanswered since 2009!

Suggested topics: programming, music, sleep, coffee, etc.

Note: please do not ask questions about REAPER features, bugs or scheduling, use the forums instead.


Name: Ask: Human (enter yes):
[back to index] | [unreplied] | [replied] | [recent comments] | [all]

Question: Some functions like SetOnlyTrackSelected (invoked from C++ plug-in) make REAPER crash when called with a MediaTrack* that points to an already deleted track. Others don't. 1) Is it good practice to always check with ValidatePtr2 if unsure about the object's existence? 2) Is this check very cheap? 3) Is this check safe to perform in audio thread? 4) Is there a similar check for midi_Input*, midi_Output* and KbdSectionInfo*? 5) Thank you!
Asked by helgoboss (84.59.97.x) on April 16 2020, 7:23pm
Reply on April 16 2020, 8:19pm (edited at April 16 2020, 8:20pm):
    Ideally you shouldn't hang on to pointers longer than you need them -- for example, the user might delete a track and create a new track and the pointer could be the same and would validate, but point to the wrong track!

    ValidatePtr() is in general relatively cheap, but not necessarily, and generally safe from the audio thread, but also not necessarily (especially since in a race condition the pointer might become invalid after you checked it!).

Comment:
    Your Name:   -- Site Owner's Name:  (for human-verification)

    Comment:    

    
  
[back to index] | [unreplied] | [replied] | [recent comments] | [all]
Copyright 2024 Justin Frankel. | RSS