Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 02-15-2019, 06:19 AM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default ReaScript: ValidatePtr type "Window*", to prevent crashes [DONE!]

In WDL/swell, IsWindow is not implemented for Linux, and very slow in MacOS. The documentation states that the function is "probably best avoided"...

Since REAPER scripts are usually only interested in REAPER's own windows and child windows, a function that checks whether a pointer is a valid REAPER window would be sufficient -- and probably much faster, if REAPER maintains an updated and easy-to-check list of its own windows.

This can easily be implemented as a new pointer type, "Window*", for ValidatePtr.

EDIT: Changed ValidatePtr2 to ValidatePtr, since windows aren't project-specific.

Last edited by juliansader; 02-03-2021 at 04:08 PM.
juliansader is offline   Reply With Quote
Old 03-29-2019, 06:31 AM   #2
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

The js_ReaScriptAPI extension has implemented an IsWindow function that should be safe and reliable on macOS as well as Linux, but it may be a little slow.

EDIT: Actually, it takes barely a microsecond, so it's probably fast enough for almost any application.

Last edited by juliansader; 04-08-2019 at 03:27 AM.
juliansader is offline   Reply With Quote
Old 04-09-2019, 01:29 PM   #3
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

I recently discovered (thanks to Mespotine) that ValidatePtr actually already has the undocumented argument "HWND"!

Now the question is: Given that HWND is a hidden feature, is it actually reliable? In which situations is it reliable, and in which not?
juliansader is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.