[brasero] Make results returned by BraseroIO be serialized for each objects



commit 0b4e46915b0e0d7614b91b019bc8faed83b0074e
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Wed Jun 3 13:50:06 2009 +0200

    Make results returned by BraseroIO be serialized for each objects
    Prevent BraseroDataDisc to show multiple dialog boxes at the same time.
---
 libbrasero-utils/brasero-io.c |   34 ++++++++++++++++++++++++++++------
 libbrasero-utils/brasero-io.h |    3 +++
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/libbrasero-utils/brasero-io.c b/libbrasero-utils/brasero-io.c
index a27ae5f..35113e3 100644
--- a/libbrasero-utils/brasero-io.c
+++ b/libbrasero-utils/brasero-io.c
@@ -317,6 +317,8 @@ brasero_io_job_result_free (BraseroIOJobResult *result)
  * Used to return the results
  */
 
+#define NUMBER_OF_RESULTS	25
+
 static gboolean
 brasero_io_return_result_idle (gpointer callback_data)
 {
@@ -325,6 +327,8 @@ brasero_io_return_result_idle (gpointer callback_data)
 	BraseroIOJobResult *result;
 	BraseroIOPrivate *priv;
 	guint results_id;
+	GSList *iter;
+	GSList *next;
 	int i;
 
 	priv = BRASERO_IO_PRIVATE (self);
@@ -339,15 +343,29 @@ brasero_io_return_result_idle (gpointer callback_data)
 
 	/* Return several results at a time that can be a huge speed gain.
 	 * What should be the value that provides speed and responsiveness? */
-	for (i = 0; priv->results && i < 25; i ++) {
-		result = priv->results->data;
+	for (i = 0, iter = priv->results; iter && i < NUMBER_OF_RESULTS; iter = next) {
+		BraseroIOJobBase *base;
+
+		result = iter->data;
+		next = iter->next;
+
+		/* Make sure another result is not returned for this base. This 
+		 * is to avoid BraseroDataDisc showing multiple dialogs for 
+		 * various problems; like one dialog for joliet, one for deep,
+		 * and one for name collision. */
+		if (result->base->in_use)
+			continue;
+
 		priv->results = g_slist_remove (priv->results, result);
 
+		base = (BraseroIOJobBase *) result->base;
+		base->in_use = TRUE;
+
 		g_mutex_unlock (priv->lock);
 
 		data = result->callback_data;
 		if (result->uri || result->info || result->error)
-			result->base->callback (result->base->object,
+			result->base->callback (base->object,
 						result->error,
 						result->uri,
 						result->info,
@@ -355,15 +373,19 @@ brasero_io_return_result_idle (gpointer callback_data)
 
 		/* Else this is just to call destroy () for callback data */
 		brasero_io_unref_result_callback_data (data,
-						       result->base->object,
-						       result->base->destroy,
+						       base->object,
+						       base->destroy,
 						       FALSE);
+
 		brasero_io_job_result_free (result);
 
 		g_mutex_lock (priv->lock);
+
+		i ++;
+		base->in_use = FALSE;
 	}
 
-	if (!priv->results_id && priv->results) {
+	if (!priv->results_id && iter && i >= NUMBER_OF_RESULTS) {
 		/* There are still results and no idle call is scheduled so we
 		 * have to restart ourselves to make sure we empty the queue */
 		priv->results_id = results_id;
diff --git a/libbrasero-utils/brasero-io.h b/libbrasero-utils/brasero-io.h
index 80e47bc..6255f02 100644
--- a/libbrasero-utils/brasero-io.h
+++ b/libbrasero-utils/brasero-io.h
@@ -111,6 +111,9 @@ struct _BraseroIOJobBase {
 	BraseroIOResultCallback callback;
 	BraseroIODestroyCallback destroy;
 	BraseroIOProgressCallback progress;
+
+	/* Whether we are returning something for this base */
+	guint in_use:1;
 };
 typedef struct _BraseroIOJobBase BraseroIOJobBase;
 



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