Skip to content

Fix for missing glist_findrtext in new Pd versions #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions pdlua.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@

#include "pdlua_gfx.h"

typedef void (*t_signal_setmultiout)(t_signal **, int);
static t_signal_setmultiout g_signal_setmultiout;
// function pointer type for signal_setmultiout (added with Pd 0.54)
typedef void (*t_signal_setmultiout_fn)(t_signal **, int);
static t_signal_setmultiout_fn g_signal_setmultiout;

// function pointer type for glist_getrtext/glist_findrtext (changes with Pd 0.56)
typedef t_rtext *(*t_glist_rtext_fn)(t_glist *, t_text *);
static t_glist_rtext_fn g_glist_getrtext = NULL;

// This used to be in s_stuff.h, but not anymore since 0.55.1test1.
int sys_trytoopenone(const char *dir, const char *name, const char* ext,
Expand Down Expand Up @@ -1315,7 +1320,7 @@ static int pdlua_set_arguments(lua_State *L)
if (redraw) {
// update the text in the object box; this makes sure that
// the arguments in the display are what we just set
t_rtext *y = glist_findrtext(o->canvas, x);
t_rtext *y = g_glist_getrtext(o->canvas, x);
rtext_retext(y);
// redraw the object and its iolets (including incident
// cord lines), in case the object box size has changed
Expand Down Expand Up @@ -3042,21 +3047,29 @@ void pdlua_setup(void)
#endif
post(luaversionStr);

// multichannel handling copied from https://github.com/Spacechild1/vstplugin/blob/3f0ed8a800ea238bf204a2ead940b2d1324ac909/pd/src/vstplugin~.cpp#L4122-L4136
// compatibility handling copied from https://github.com/Spacechild1/vstplugin/blob/3f0ed8a800ea238bf204a2ead940b2d1324ac909/pd/src/vstplugin~.cpp#L4122-L4136
#ifdef _WIN32
// get a handle to the module containing the Pd API functions.
// NB: GetModuleHandle("pd.dll") does not cover all cases.
HMODULE module;
if (GetModuleHandleEx(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCSTR)&pd_typedmess, &module)) {
g_signal_setmultiout = (t_signal_setmultiout)(void *)GetProcAddress(
g_signal_setmultiout = (t_signal_setmultiout_fn)(void *)GetProcAddress(
module, "signal_setmultiout");
g_glist_getrtext = (t_glist_rtext_fn)GetProcAddress(module, "glist_getrtext");
if (!g_glist_getrtext)
g_glist_getrtext = (t_glist_rtext_fn)GetProcAddress(module, "glist_findrtext");
}
#else
// search recursively, starting from the main program
g_signal_setmultiout = (t_signal_setmultiout)dlsym(
g_signal_setmultiout = (t_signal_setmultiout_fn)dlsym(
dlopen(NULL, RTLD_NOW), "signal_setmultiout");
g_glist_getrtext = (t_glist_rtext_fn)dlsym(
dlopen(NULL, RTLD_NOW), "glist_getrtext");
if (!g_glist_getrtext)
g_glist_getrtext = (t_glist_rtext_fn)dlsym(
dlopen(NULL, RTLD_NOW), "glist_findrtext");
#endif

pdlua_proxyinlet_setup();
Expand Down
Loading