Make sure a thread has a queue as soon as it creates a window.

This commit is contained in:
Alexandre Julliard 2005-04-26 14:31:33 +00:00
parent 1b54881209
commit d70a253f40
3 changed files with 26 additions and 10 deletions

View file

@ -282,7 +282,7 @@ struct hook_table *get_queue_hooks( struct thread *thread )
void set_queue_hooks( struct thread *thread, struct hook_table *hooks )
{
struct msg_queue *queue = thread->queue;
if (!queue) queue = create_msg_queue( thread, NULL );
if (!queue && !(queue = create_msg_queue( thread, NULL ))) return;
if (queue->hooks) release_object( queue->hooks );
queue->hooks = hooks;
}
@ -828,6 +828,13 @@ static int check_queue_input_window( struct msg_queue *queue, user_handle_t wind
return ret;
}
/* make sure the specified thread has a queue */
int init_thread_queue( struct thread *thread )
{
if (thread->queue) return 1;
return (create_msg_queue( thread, NULL ) != NULL);
}
/* attach two thread input data structures */
int attach_thread_input( struct thread *thread_from, struct thread *thread_to )
{

View file

@ -61,6 +61,7 @@ extern struct hook_table *get_queue_hooks( struct thread *thread );
extern void set_queue_hooks( struct thread *thread, struct hook_table *hooks );
extern void inc_queue_paint_count( struct thread *thread, int incr );
extern void queue_cleanup_window( struct thread *thread, user_handle_t win );
extern int init_thread_queue( struct thread *thread );
extern int attach_thread_input( struct thread *thread_from, struct thread *thread_to );
extern void post_message( user_handle_t win, unsigned int message,
unsigned int wparam, unsigned int lparam );

View file

@ -338,13 +338,8 @@ static struct window *create_window( struct window *parent, struct window *owner
release_class( class );
return NULL;
}
if (!(win->handle = alloc_user_handle( win, USER_WINDOW ))) goto failed;
if (!(win->handle = alloc_user_handle( win, USER_WINDOW )))
{
release_class( class );
free( win );
return NULL;
}
win->parent = parent;
win->owner = owner ? owner->handle : 0;
win->thread = current;
@ -368,13 +363,26 @@ static struct window *create_window( struct window *parent, struct window *owner
list_init( &win->children );
list_init( &win->unlinked );
/* if parent belongs to a different thread, attach the two threads */
if (parent && parent->thread && parent->thread != current)
{
if (!attach_thread_input( current, parent->thread )) goto failed;
}
else /* otherwise just make sure that the thread has a message queue */
{
if (!current->queue && !init_thread_queue( current )) goto failed;
}
/* put it on parent unlinked list */
if (parent) list_add_head( &parent->unlinked, &win->entry );
/* if parent belongs to a different thread, attach the two threads */
if (parent && parent->thread && parent->thread != current)
attach_thread_input( current, parent->thread );
return win;
failed:
if (win->handle) free_user_handle( win->handle );
release_class( class );
free( win );
return NULL;
}
/* destroy all windows belonging to a given thread */