Re: ~100% CPU usage



Hi,

On Mon, 2002-08-26 at 18:49, Jeroen Zwartepoorte wrote:
> Hi all,
> 
> It seems the ~100 CPU usage bug is still here (with the new glue stuff
> in gnome-build and only the project-manager & document-manager plugins
> loaded (and the "anjuta2" project loaded)).
> 
> Now, i've had this happen several times before and as before i've
> attached gdb to the process and did a bt. Every time i do this, i get a
> trace containing anjuta_window_save_layout_to_file in
> anjuta2/src/window.c. This is run from an idle handler afaik. Could this
> somehow be causing the large CPU usage?

I've checked and I had a patch sleeping in my source tree for a long
time now.  The problem is the idle handler doesn't return a boolean
value, and thus is never removed from the main loop.  The attached patch
fixes that.

May I commit?

See you,
Gustavo


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/anjuta2/ChangeLog,v
retrieving revision 1.221
diff -u -r1.221 ChangeLog
--- ChangeLog	14 Jul 2002 17:08:36 -0000	1.221
+++ ChangeLog	27 Aug 2002 02:12:11 -0000
@@ -1,3 +1,11 @@
+2002-08-26  Gustavo Giráldez  <gustavo giraldez gmx net>
+
+	* src/window.c (anjuta_window_save_layout_to_file): Change
+	prototype to return gboolean and return FALSE so the idle handler
+	is removed after saving layout.
+	(about_cmd): Set converted to TRUE, since the names are already in
+	UTF8 in the source.
+
 2002-07-14  Jeroen Zwartepoorte  <jeroen xs4all nl>
 
 	* plugins/document-manager/anjuta-document-manager.c:
Index: src/window.c
===================================================================
RCS file: /cvs/gnome/anjuta2/src/window.c,v
retrieving revision 1.63
diff -u -r1.63 window.c
--- src/window.c	14 Jul 2002 17:08:38 -0000	1.63
+++ src/window.c	27 Aug 2002 02:12:12 -0000
@@ -41,7 +41,6 @@
 #include <libanjuta/libanjuta.h>
 #include <gconf/gconf-client.h>
 
-
 #define ANJUTA_WINDOW_STATE_PREFIX         "/apps/anjuta2/state"
 #define ANJUTA_WINDOW_STATE_WIDTH_KEY      ANJUTA_WINDOW_STATE_PREFIX "/width" 
 #define ANJUTA_WINDOW_STATE_HEIGHT_KEY     ANJUTA_WINDOW_STATE_PREFIX "/height" 
@@ -59,15 +58,15 @@
 /* ---- Private prototypes ----- */
 
 /* Prototypes */
-static void anjuta_window_drag_recv           (GtkWidget         *widget,
-					       GdkDragContext    *context,
-					       gint               x,
-					       gint               y,
-					       GtkSelectionData  *seldata,
-					       guint              info,
-					       guint              time,
-					       gpointer           data);
-static void anjuta_window_save_layout_to_file (AnjutaWindow      *window);
+static void     anjuta_window_drag_recv           (GtkWidget         *widget,
+						   GdkDragContext    *context,
+						   gint               x,
+						   gint               y,
+						   GtkSelectionData  *seldata,
+						   guint              info,
+						   guint              time,
+						   gpointer           data);
+static gboolean anjuta_window_save_layout_to_file (AnjutaWindow      *window);
 
 gpointer parent_class;
 
@@ -186,7 +185,7 @@
 	static GtkWidget *about = NULL;
 
 	/* Convert names in the about box to utf8 */
-	static gboolean converted = FALSE;
+	static gboolean converted = TRUE;
 	if (!converted) {
 		int i;
  		for (i = 0; i < G_N_ELEMENTS (authors) - 1; i++) {
@@ -290,11 +289,13 @@
 	if (!strcmp (pspec->name, "dirty")) {
 		gboolean dirty;
 		g_object_get (object, "dirty", &dirty, NULL);
-		if (dirty)
+		if (dirty) {
 			/* user_data is the AnjutaWindow */
 			g_idle_add (
 				(GSourceFunc) anjuta_window_save_layout_to_file,
 				user_data);
+			
+		}
 	}
 }
 
@@ -599,7 +600,7 @@
 }
 #endif
 
-static void
+static gboolean
 anjuta_window_save_layout_to_file (AnjutaWindow *window)
 {
 	char *dir;
@@ -610,7 +611,7 @@
 		mkdir (dir, 0755);
 		if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) {
 			anjuta_dialog_error ("Could not create .anjuta2 directory.");
-			return;
+			return FALSE;
 		}
 	}
 	g_free (dir);
@@ -618,6 +619,8 @@
 	filename = gnome_util_prepend_user_home (".anjuta2/layout.xml");
 	if (!gdl_dock_layout_save_to_file (window->layout_manager, filename))
 		anjuta_dialog_error ("Could not save layout.");
+
+	return FALSE;
 }
 
 void


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