Keep track of the windows and hooks used by a thread to properly
refuse to change the thread desktop when it's in use.
diff --git a/server/hook.c b/server/hook.c
index c3a0244..0830450 100644
--- a/server/hook.c
+++ b/server/hook.c
@@ -125,6 +125,7 @@
hook->thread = thread ? (struct thread *)grab_object( thread ) : NULL;
hook->index = index;
list_add_head( &table->hooks[index], &hook->chain );
+ if (thread) thread->desktop_users++;
return hook;
}
@@ -133,7 +134,12 @@
{
free_user_handle( hook->handle );
if (hook->module) free( hook->module );
- if (hook->thread) release_object( hook->thread );
+ if (hook->thread)
+ {
+ assert( hook->thread->desktop_users > 0 );
+ hook->thread->desktop_users--;
+ release_object( hook->thread );
+ }
if (hook->process) release_object( hook->process );
release_object( hook->owner );
list_remove( &hook->chain );