diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index c97b665..bb31f43 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -253,6 +253,7 @@ static void
 gcm_picker_measure_cb (GtkWidget *widget, gpointer data)
 {
 	gboolean ret;
+        gboolean is_locked;
 	CdColorXYZ *tmp = NULL;
 	GError *error = NULL;
 
@@ -270,6 +271,8 @@ gcm_picker_measure_cb (GtkWidget *widget, gpointer data)
 		goto out;
 	}
 
+        is_locked = TRUE;
+
 	/* get color */
 	tmp = cd_sensor_get_sample_sync (sensor,
 					 CD_SENSOR_CAP_LCD,
@@ -296,21 +299,23 @@ gcm_picker_measure_cb (GtkWidget *widget, gpointer data)
 	}
 #endif
 
-	/* unlock */
-	ret = cd_sensor_unlock_sync (sensor,
-				     NULL,
-				     &error);
-	if (!ret) {
-		g_warning ("failed to lock: %s", error->message);
-		g_error_free (error);
-		goto out;
+out:
+        if (is_locked) {
+	        error = NULL;
+	        /* unlock */
+	        if (!cd_sensor_unlock_sync (sensor,
+		 		            NULL,
+				            &error)) {
+		        g_warning ("failed to unlock: %s", error->message);
+		        g_error_free (error);
+		}
 	}
 
-	gcm_picker_refresh_results ();
-	gcm_picker_got_results ();
-out:
-	if (tmp != NULL)
+        if (tmp != NULL) {
+	        gcm_picker_refresh_results ();
+	        gcm_picker_got_results ();
 		cd_color_xyz_free (tmp);
+	}
 	return;
 }
 
