X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_mouse.c;h=e92be5b92fe0f8a716bf8876070aa6b4f1845284;hp=b6229cf4a8a7f2bf5bc88026989352d30385a813;hb=1c2ec25b8186b7973aeb06ec4da6b63656e12f7d;hpb=d736364fc09f481a38861dcb44b43d15b94af528 diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c index b6229cf4..e92be5b9 100644 --- a/ncurses/base/lib_mouse.c +++ b/ncurses/base/lib_mouse.c @@ -79,7 +79,7 @@ #include -MODULE_ID("$Id: lib_mouse.c,v 1.97 2008/08/16 18:55:01 tom Exp $") +MODULE_ID("$Id: lib_mouse.c,v 1.98 2008/09/20 21:26:19 tom Exp $") #include #include @@ -150,7 +150,7 @@ make an error #define LIBGPM_SONAME "libgpm.so" #endif -#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(obj, #name)) +#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(SP->_dlopen_gpm, #name)) #endif /* USE_GPM_SUPPORT */ @@ -415,6 +415,15 @@ enable_gpm_mouse(SCREEN *sp, int enable) } result = FALSE; } +#ifdef HAVE_LIBDL + if (!result && (SP->_dlopen_gpm != 0)) { + T(("unload GPM library")); + SP->_mouse_gpm_found = FALSE; + SP->_mouse_gpm_loaded = FALSE; + dlclose(SP->_dlopen_gpm); + SP->_dlopen_gpm = 0; + } +#endif returnBool(result); } #endif /* USE_GPM_SUPPORT */ @@ -431,15 +440,13 @@ initialize_mousetype(SCREEN *sp) if (allow_gpm_mouse()) { if (!sp->_mouse_gpm_loaded) { #ifdef HAVE_LIBDL - void *obj; - - if ((obj = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) { + if ((SP->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) { if (GET_DLSYM(gpm_fd) == 0 || GET_DLSYM(Gpm_Open) == 0 || GET_DLSYM(Gpm_Close) == 0 || GET_DLSYM(Gpm_GetEvent) == 0) { T(("GPM initialization failed: %s", dlerror())); - dlclose(obj); + dlclose(SP->_dlopen_gpm); } else { sp->_mouse_gpm_found = TRUE; }