[gnome-system-monitor] Disable priority changed handler while setting current priority.



commit c00d94f3bfe2186428ef30e922042a555b7dc03a
Author: Robert Roth <robert roth off gmail com>
Date:   Wed Jan 4 01:56:27 2012 +0200

    Disable priority changed handler while setting current priority.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=667227

 src/callbacks.cpp   |    4 +++-
 src/interface.cpp   |   19 +++++++++++++++++++
 src/interface.h     |    1 +
 src/procactions.cpp |    3 ++-
 4 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/callbacks.cpp b/src/callbacks.cpp
index 5608241..bdad606 100644
--- a/src/callbacks.cpp
+++ b/src/callbacks.cpp
@@ -347,8 +347,10 @@ cb_row_selected (GtkTreeSelection *selection, gpointer data)
             value = VERY_LOW_PRIORITY;
 
         GtkRadioAction* normal = GTK_RADIO_ACTION(gtk_action_group_get_action(procdata->action_group, "Normal"));
-
+        block_priority_changed_handlers(procdata, TRUE);
         gtk_radio_action_set_current_value(normal, value);
+        block_priority_changed_handlers(procdata, FALSE);
+
     }
     update_sensitivity(procdata);
 }
diff --git a/src/interface.cpp b/src/interface.cpp
index 3573edd..9410369 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -809,6 +809,25 @@ update_sensitivity(ProcData *data)
     }
 }
 
+void
+block_priority_changed_handlers(ProcData *data, bool block)
+{
+    gint i;
+    if (block) {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_block_by_func(action, (gpointer)cb_renice, data);
+        }
+    } else {
+        for (i = 0; i != G_N_ELEMENTS(priority_menu_entries); ++i) {
+            GtkRadioAction *action = GTK_RADIO_ACTION(gtk_action_group_get_action(data->action_group,
+                                             priority_menu_entries[i].name));
+            g_signal_handlers_unblock_by_func(action, (gpointer)cb_renice, data);
+        }
+    }
+}
+
 static void
 cb_toggle_tree (GtkAction *action, gpointer data)
 {
diff --git a/src/interface.h b/src/interface.h
index bf18a5e..8cd32ab 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -26,6 +26,7 @@
 
 void            create_main_window (ProcData *data);
 void            update_sensitivity (ProcData *data);
+void            block_priority_changed_handlers(ProcData *data, bool block);
 void            do_popup_menu(ProcData *data, GdkEventButton *event);
 GtkWidget *     make_title_label (const char *text);
 
diff --git a/src/procactions.cpp b/src/procactions.cpp
index d966fb4..a359d43 100644
--- a/src/procactions.cpp
+++ b/src/procactions.cpp
@@ -47,7 +47,8 @@ renice_single_process (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter
 
     if (!info)
         return;
-
+    if (info->nice == args->nice_value)
+        return;
     error = setpriority (PRIO_PROCESS, info->pid, args->nice_value);
 
     /* success */



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