[gnome-color-manager] trivial: do not allow an invalid window (self) to crash gcm_calibrate_dialog_set_window()



commit 061da38e6d25935d3982564b8de4b75f670dc43f
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 2 10:16:06 2010 +0000

    trivial: do not allow an invalid window (self) to crash gcm_calibrate_dialog_set_window()

 src/gcm-calibrate-dialog.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/gcm-calibrate-dialog.c b/src/gcm-calibrate-dialog.c
index 09f37ab..1f54e06 100644
--- a/src/gcm-calibrate-dialog.c
+++ b/src/gcm-calibrate-dialog.c
@@ -246,11 +246,20 @@ gcm_calibrate_dialog_set_window	(GcmCalibrateDialog *calibrate_dialog, GtkWindow
 {
 	GtkWidget *widget;
 	GcmCalibrateDialogPrivate *priv = calibrate_dialog->priv;
+
+	/* do nothing, we can't unparent */
+	if (window == NULL)
+		return;
+
+	/* ensure it's not the same thing */
 	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "dialog_calibrate"));
+	if (GTK_WINDOW (widget) == window) {
+		egg_warning ("trying to set parent to self!");
+		return;
+	}
 
-	/* run dialog */
-	if (window != NULL)
-		gtk_window_set_transient_for (GTK_WINDOW (widget), window);
+	/* make modal */
+	gtk_window_set_transient_for (GTK_WINDOW (widget), window);
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]