[gtk+] mir: don't crash when querying infos for an invalid monitor
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] mir: don't crash when querying infos for an invalid monitor
- Date: Thu, 13 Nov 2014 01:08:10 +0000 (UTC)
commit 0d024c2df87c636c419577c0b9046815a16792b5
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Thu Nov 13 02:07:46 2014 +0100
mir: don't crash when querying infos for an invalid monitor
gdk/mir/gdkmirscreen.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/gdk/mir/gdkmirscreen.c b/gdk/mir/gdkmirscreen.c
index 9d6d82f..6911c06 100644
--- a/gdk/mir/gdkmirscreen.c
+++ b/gdk/mir/gdkmirscreen.c
@@ -302,7 +302,8 @@ gdk_mir_screen_get_monitor_width_mm (GdkScreen *screen,
gint monitor_num)
{
g_printerr ("gdk_mir_screen_get_monitor_width_mm (%d)\n", monitor_num);
- return get_output (screen, monitor_num)->physical_width_mm;
+ MirDisplayOutput *output = get_output (screen, monitor_num);
+ return output ? output->physical_width_mm : 0;
}
static gint
@@ -310,7 +311,8 @@ gdk_mir_screen_get_monitor_height_mm (GdkScreen *screen,
gint monitor_num)
{
g_printerr ("gdk_mir_screen_get_monitor_height_mm (%d)\n", monitor_num);
- return get_output (screen, monitor_num)->physical_height_mm;
+ MirDisplayOutput *output = get_output (screen, monitor_num);
+ return output ? output->physical_height_mm : 0;
}
static gchar *
@@ -331,11 +333,19 @@ gdk_mir_screen_get_monitor_geometry (GdkScreen *screen,
MirDisplayMode *mode;
output = get_output (screen, monitor_num);
- mode = &output->modes[output->current_mode];
- dest->x = output->position_x;
- dest->y = output->position_y;
- dest->width = mode->horizontal_resolution;
- dest->height = mode->vertical_resolution;
+
+ if (output)
+ {
+ mode = &output->modes[output->current_mode];
+ dest->x = output->position_x;
+ dest->y = output->position_y;
+ dest->width = mode->horizontal_resolution;
+ dest->height = mode->vertical_resolution;
+ }
+ else
+ {
+ *dest = {0, 0, 0, 0};
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]