5959
6060#include "pdlua_gfx.h"
6161
62+ // function pointer type for signal_setmultiout (added with Pd 0.54)
6263typedef void (* t_signal_setmultiout )(t_signal * * , int );
6364static t_signal_setmultiout g_signal_setmultiout ;
6465
66+ // function pointer type for glist_getrtext/glist_findrtext (changes with Pd 0.56)
67+ typedef t_rtext * (* t_glist_rtext )(t_glist * , t_text * );
68+ static t_glist_rtext g_glist_getrtext ;
69+
6570// This used to be in s_stuff.h, but not anymore since 0.55.1test1.
6671int sys_trytoopenone (const char * dir , const char * name , const char * ext ,
6772 char * dirresult , char * * nameresult , unsigned int size , int bin );
@@ -1315,7 +1320,7 @@ static int pdlua_set_arguments(lua_State *L)
13151320 if (redraw ) {
13161321 // update the text in the object box; this makes sure that
13171322 // the arguments in the display are what we just set
1318- t_rtext * y = glist_findrtext (o -> canvas , x );
1323+ t_rtext * y = g_glist_getrtext (o -> canvas , x );
13191324 rtext_retext (y );
13201325 // redraw the object and its iolets (including incident
13211326 // cord lines), in case the object box size has changed
@@ -3042,7 +3047,7 @@ void pdlua_setup(void)
30423047#endif
30433048 post (luaversionStr );
30443049
3045- // multichannel handling copied from https://github.com/Spacechild1/vstplugin/blob/3f0ed8a800ea238bf204a2ead940b2d1324ac909/pd/src/vstplugin~.cpp#L4122-L4136
3050+ // compatibility handling copied from https://github.com/Spacechild1/vstplugin/blob/3f0ed8a800ea238bf204a2ead940b2d1324ac909/pd/src/vstplugin~.cpp#L4122-L4136
30463051#ifdef _WIN32
30473052 // get a handle to the module containing the Pd API functions.
30483053 // NB: GetModuleHandle("pd.dll") does not cover all cases.
@@ -3052,13 +3057,28 @@ void pdlua_setup(void)
30523057 (LPCSTR )& pd_typedmess , & module )) {
30533058 g_signal_setmultiout = (t_signal_setmultiout )(void * )GetProcAddress (
30543059 module , "signal_setmultiout" );
3060+ g_glist_getrtext = (t_glist_rtext )(void * )GetProcAddress (module , "glist_getrtext" );
3061+ if (!g_glist_getrtext )
3062+ g_glist_getrtext = (t_glist_rtext )(void * )GetProcAddress (module , "glist_findrtext" );
30553063 }
30563064#else
30573065 // search recursively, starting from the main program
30583066 g_signal_setmultiout = (t_signal_setmultiout )dlsym (
30593067 dlopen (NULL , RTLD_NOW ), "signal_setmultiout" );
3068+ g_glist_getrtext = (t_glist_rtext )dlsym (
3069+ dlopen (NULL , RTLD_NOW ), "glist_getrtext" );
3070+ if (!g_glist_getrtext )
3071+ g_glist_getrtext = (t_glist_rtext )dlsym (
3072+ dlopen (NULL , RTLD_NOW ), "glist_findrtext" );
30603073#endif
30613074
3075+ // check if g_glist_getrtext was loaded successfully
3076+ if (!g_glist_getrtext ) {
3077+ pd_error (NULL , "pdlua: failed to load pd's glist_getrtext/glist_findrtext functions" );
3078+ pd_error (NULL , "pdlua: loader will not be registered!" );
3079+ return ;
3080+ }
3081+
30623082 pdlua_proxyinlet_setup ();
30633083 PDLUA_DEBUG ("pdlua pdlua_proxyinlet_setup done" , 0 );
30643084 pdlua_proxyreceive_setup ();
0 commit comments