[PATCH weston] window: don't call output configure uninitialised

Pekka Paalanen ppaalanen at gmail.com
Mon Oct 15 02:06:53 PDT 2012


Callbacks registered via display_set_output_configure_handler() are
promised to be called when we know the current mode for the output. If
the following order of events happens:
1. toytoolkit binds to a wl_output global
2. application registers an output configure handler
3. the wl_output.mode events are received

Then in step 2 we would call the callback with uninitialised output
informations, giving it a 0x0 size.

To avoid such race, do not call the callback from
display_set_output_configure_handler() if the output has 0x0 size.

The wl_output.mode event will be received later, and that will trigger
the right call to the callback.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 clients/window.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 13363f8..9f44e64 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -3550,9 +3550,14 @@ display_set_output_configure_handler(struct display *display,
 	if (!handler)
 		return;
 
-	wl_list_for_each(output, &display->output_list, link)
+	wl_list_for_each(output, &display->output_list, link) {
+		if (output->allocation.width == 0 &&
+		    output->allocation.height == 0)
+			continue;
+
 		(*display->output_configure_handler)(output,
 						     display->user_data);
+	}
 }
 
 void
-- 
1.7.8.6



More information about the wayland-devel mailing list