Some print monitors are very sensitive to loads/unloads being done in a quick succession like AddMonitor() does, and that even leads to crashes because the monitor I have here creates a thread on load and when the thread starts - the monitor dll is already unloaded. A solution to this is moving the monitor unloading to DeleteMonitor.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/localspl/provider.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/localspl/provider.c b/dlls/localspl/provider.c index 2b3f9bac6e..4f373392ae 100644 --- a/dlls/localspl/provider.c +++ b/dlls/localspl/provider.c @@ -1572,8 +1572,6 @@ static BOOL WINAPI fpAddMonitor(LPWSTR pName, DWORD Level, LPBYTE pMonitors) if ((pm = monitor_load(mi2w->pName, mi2w->pDLLName)) == NULL) res = FALSE;
- monitor_unload(pm); - RegCloseKey(hentry);
if (!res) @@ -1890,6 +1888,7 @@ static BOOL WINAPI fpConfigurePort(LPWSTR pName, HWND hWnd, LPWSTR pPortName)
static BOOL WINAPI fpDeleteMonitor(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pMonitorName) { + monitor_t *pm; HKEY hroot = NULL; LONG lres;
@@ -1910,6 +1909,18 @@ static BOOL WINAPI fpDeleteMonitor(LPWSTR pName, LPWSTR pEnvironment, LPWSTR pMo return FALSE; }
+ /* Unload the monitor if it's loaded */ + EnterCriticalSection(&monitor_handles_cs); + LIST_FOR_EACH_ENTRY(pm, &monitor_handles, monitor_t, entry) + { + if (pm->name && !lstrcmpW(pMonitorName, pm->name)) + { + monitor_unload(pm); + break; + } + } + LeaveCriticalSection(&monitor_handles_cs); + if(RegCreateKeyW(HKEY_LOCAL_MACHINE, monitorsW, &hroot) != ERROR_SUCCESS) { ERR("unable to create key %s\n", debugstr_w(monitorsW)); return FALSE;