Commit d70a253f authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent 1b548812
...@@ -282,7 +282,7 @@ struct hook_table *get_queue_hooks( struct thread *thread ) ...@@ -282,7 +282,7 @@ struct hook_table *get_queue_hooks( struct thread *thread )
void set_queue_hooks( struct thread *thread, struct hook_table *hooks ) void set_queue_hooks( struct thread *thread, struct hook_table *hooks )
{ {
struct msg_queue *queue = thread->queue; 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 ); if (queue->hooks) release_object( queue->hooks );
queue->hooks = hooks; queue->hooks = hooks;
} }
...@@ -828,6 +828,13 @@ static int check_queue_input_window( struct msg_queue *queue, user_handle_t wind ...@@ -828,6 +828,13 @@ static int check_queue_input_window( struct msg_queue *queue, user_handle_t wind
return ret; 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 */ /* attach two thread input data structures */
int attach_thread_input( struct thread *thread_from, struct thread *thread_to ) int attach_thread_input( struct thread *thread_from, struct thread *thread_to )
{ {
......
...@@ -61,6 +61,7 @@ extern struct hook_table *get_queue_hooks( struct thread *thread ); ...@@ -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 set_queue_hooks( struct thread *thread, struct hook_table *hooks );
extern void inc_queue_paint_count( struct thread *thread, int incr ); extern void inc_queue_paint_count( struct thread *thread, int incr );
extern void queue_cleanup_window( struct thread *thread, user_handle_t win ); 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 int attach_thread_input( struct thread *thread_from, struct thread *thread_to );
extern void post_message( user_handle_t win, unsigned int message, extern void post_message( user_handle_t win, unsigned int message,
unsigned int wparam, unsigned int lparam ); unsigned int wparam, unsigned int lparam );
......
...@@ -338,13 +338,8 @@ static struct window *create_window( struct window *parent, struct window *owner ...@@ -338,13 +338,8 @@ static struct window *create_window( struct window *parent, struct window *owner
release_class( class ); release_class( class );
return NULL; 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->parent = parent;
win->owner = owner ? owner->handle : 0; win->owner = owner ? owner->handle : 0;
win->thread = current; win->thread = current;
...@@ -368,13 +363,26 @@ static struct window *create_window( struct window *parent, struct window *owner ...@@ -368,13 +363,26 @@ static struct window *create_window( struct window *parent, struct window *owner
list_init( &win->children ); list_init( &win->children );
list_init( &win->unlinked ); 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 */ /* put it on parent unlinked list */
if (parent) list_add_head( &parent->unlinked, &win->entry ); 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; 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 */ /* destroy all windows belonging to a given thread */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment