osxmidi / LinVst

Linux Windows vst wrapper/bridge
GNU General Public License v3.0
674 stars 41 forks source link

effEditGetRect always returns default coordinates if called on closed editor #148

Closed Spacechild1 closed 3 years ago

Spacechild1 commented 4 years ago

Hi, I've written a VST plugin host for Pd and SuperCollider (https://git.iem.at/pd/vstplugin/) and just got a bug report from a user of LinVst where the plugin window would be too small.

I think the problem boils down to this: https://github.com/osxmidi/LinVst/blob/416acfedf276ac0e5f37a143a294530c441d69e6/linvst.cpp#L550 On effEditGetRect, LinVst simply uses retRect and returns success, even if retRect hasn't been updated to the actual coordinates, which means it still has the default coordinates {0,0,200,500}.

I understand that LinVst can only get the actual rect after opening the plugin GUI and waiting for the server reply. But this means it should return 0 if the host calls effEditGetRect with the editor being closed, so the host knows that the rect is not really available (yet).

I guess I have to adapt my own code for edge cases like this anyway, but you might want to fix it nevertheless.

Thanks!

Spacechild1 commented 4 years ago

Alternatively, you could call audioMasterSizeWindow after the editor has been opened and when the actual window size is available.

osxmidi commented 4 years ago

I've changed the code to return 1 (true) from effEditGetRect only if the editor opens, otherwise it returns 0 (false).

Spacechild1 commented 4 years ago

cool, thanks!

osxmidi commented 4 years ago

If it doesn't work just let me know.

Spacechild1 commented 4 years ago

There's a small quirk left: although it returns 0 if the editor isn't open, it assigns the output pointer argument to an (empty) window rect. Instead, it shouldn't assign the pointer at all.

But it's not a big deal, I can work around it.