SF.net SVN: geany-plugins:[2199] trunk/geany-plugins/debugger/src

cesspit at users.sourceforge.net cesspit at xxxxx
Fri Sep 16 13:47:04 UTC 2011


Revision: 2199
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=2199&view=rev
Author:   cesspit
Date:     2011-09-16 13:47:03 +0000 (Fri, 16 Sep 2011)
Log Message:
-----------
debugger: preventing multiple config saving operations when performing enabling/disabling/removing several breaks from breakpoints panel, refactoring

Modified Paths:
--------------
    trunk/geany-plugins/debugger/src/bptree.c
    trunk/geany-plugins/debugger/src/breakpoints.c
    trunk/geany-plugins/debugger/src/breakpoints.h
    trunk/geany-plugins/debugger/src/btnpanel.c
    trunk/geany-plugins/debugger/src/callbacks.c
    trunk/geany-plugins/debugger/src/dconfig.c
    trunk/geany-plugins/debugger/src/dconfig.h
    trunk/geany-plugins/debugger/src/debug.c
    trunk/geany-plugins/debugger/src/debug.h
    trunk/geany-plugins/debugger/src/dpaned.c
    trunk/geany-plugins/debugger/src/markers.c
    trunk/geany-plugins/debugger/src/plugin.c
    trunk/geany-plugins/debugger/src/stree.c
    trunk/geany-plugins/debugger/src/tpage.c

Modified: trunk/geany-plugins/debugger/src/bptree.c
===================================================================
--- trunk/geany-plugins/debugger/src/bptree.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/bptree.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -35,7 +35,6 @@
 
 #include "geanyplugin.h"
 
-#include "breakpoint.h"
 #include "breakpoints.h"
 #include "bptree.h"
 #include "utils.h"
@@ -85,21 +84,6 @@
 move_to_line_cb on_break_clicked = NULL;
 
 /* 
- * traversed comparing functions
- */
-static gboolean compare_path_references(gpointer key, gpointer value, gpointer user_data)
-{
-	GtkTreeRowReference *being_clicked = (GtkTreeRowReference*)user_data;
-	GtkTreeRowReference *compared = (GtkTreeRowReference*)value;
-	
-	return !gtk_tree_path_compare (
-		gtk_tree_row_reference_get_path(being_clicked),
-		gtk_tree_row_reference_get_path(compared)
-	);
-		
-}
-
-/* 
  * gets tree row reference for an unsected row at the same depth
  */
 GtkTreeRowReference* get_unselected_sibling(GtkTreePath *path)
@@ -350,48 +334,18 @@
 	gboolean current_state = gtk_cell_renderer_toggle_get_active(cell_renderer);
 
     /* check if this is a file row */
-    GtkTreeRowReference *path_reference = gtk_tree_row_reference_new(model, tree_path);
-    if(g_hash_table_find(files, compare_path_references, (gpointer)path_reference))
+    if(1 == gtk_tree_path_get_depth(tree_path))
     {
-		GtkTreeIter child;
-		gtk_tree_model_iter_children(model, &child, &iter);
-
 		gchar *file;
 		gtk_tree_model_get (
 			model,
 			&iter,
 			FILEPATH, &file,
 			-1);
-		
-		dconfig_set_modifyable(FALSE);
-		do
-		{
-			gboolean enabled;
-			gtk_tree_model_get (
-				model,
-				&child,
-				ENABLED, &enabled,
-				-1);
-			
-			if (!current_state ^ enabled)
-			{
-				int line;
-				gtk_tree_model_get (
-					model,
-					&child,
-					LINE, &line,
-					-1);
-				breaks_switch(file, line);
-			}
-		}
-		while(gtk_tree_model_iter_next(model, &child));
 
-		gtk_tree_store_set(store, &iter, ENABLED, !current_state, -1);
+		breaks_set_enabled_for_file(file, !current_state);
 
 		g_free(file);
-
-		dconfig_set_modifyable(TRUE);
-		dconfig_set_changed();
 	}
 	else
 	{
@@ -400,15 +354,12 @@
 
 		gchar *file;
 		int line;
-		gboolean parent_enabed;
 
 		gtk_tree_model_get (
 			model,
 			&parent_iter,
 			FILEPATH, &file,
-			ENABLED, &parent_enabed,
 			-1);
-
 		gtk_tree_model_get (
 			model,
 			&iter,
@@ -417,15 +368,6 @@
 			
 		breaks_switch(file, line);
 		
-		if (current_state && parent_enabed)
-		{
-			gtk_tree_store_set(store, &parent_iter, ENABLED, FALSE, -1);
-		}
-		else if (!current_state && !parent_enabed)
-		{
-			update_file_node(&parent_iter);
-		}
-		
 		g_free(file);
 	}
 
@@ -437,6 +379,10 @@
  */
 static gboolean on_key_pressed(GtkWidget *widget, GdkEvent *event, gpointer user_data)
 {
+	/* do not process event is page is readonly (debug is running) */
+	if (readonly)
+		return FALSE;
+
     guint keyval = ((GdkEventKey*)event)->keyval;
 
 	/* get selected rows */
@@ -448,9 +394,6 @@
 	{
 		/* "delete selected rows" */
 
-		/* get references to rows to keep references actual when altering model */
-		GList *references = NULL;
-
 		/* get new selection */
 		GtkTreeRowReference *new_selection = NULL;
 		GtkTreePath *first_path = (GtkTreePath*)rows->data;
@@ -469,107 +412,72 @@
 			gtk_tree_path_free(file_path);
 		}
 		
+		/* collect GList of breakpoints to remove
+		if file row is met - add all unselected breaks to the list as well */
 		GList *iter = rows;
+		GList *breaks = NULL;
 		while (iter)
 		{
 			GtkTreePath *path = (GtkTreePath*)iter->data;
-			references = g_list_append(references, gtk_tree_row_reference_new(model, path));
-			iter = iter->next;
-		}
-		
-		/* remove break rows leaving file rows for the next step */
-		dconfig_set_modifyable(FALSE);
-		iter = references;
-		while (iter)
-		{
-			GtkTreeRowReference *reference = (GtkTreeRowReference*)iter->data;
-			if (gtk_tree_row_reference_valid(reference))
-			{
-				GtkTreePath *path = gtk_tree_row_reference_get_path(reference);
-				if (gtk_tree_path_get_depth(path) > 1)
-				{
-					GtkTreeIter titer, piter;
-					gtk_tree_model_get_iter(model, &titer, path);
-					gtk_tree_model_iter_parent(model, &piter, &titer);
-					
-					gchar *filename = NULL;
-					gtk_tree_model_get(model, &piter, FILEPATH, &filename, -1);
-
-					gint line;
-					gtk_tree_model_get(model, &titer, LINE, &line, -1);
-
-					breaks_remove(filename, line);
-					
-					g_free(filename);
-				}
-			}
 			
-			iter = iter->next;
-		}
-		
-		/* remove file rows and children if exist */
-		iter = references;
-		while (iter)
-		{
-			GtkTreeRowReference *reference = (GtkTreeRowReference*)iter->data;
-			if (gtk_tree_row_reference_valid(reference))
+			GtkTreeIter titer;
+			gtk_tree_model_get_iter(model, &titer, path);
+			
+			if (1 == gtk_tree_path_get_depth(path))
 			{
-				GtkTreePath *path = gtk_tree_row_reference_get_path(reference);
-				if (1 == gtk_tree_path_get_depth(path))
+				GtkTreeIter citer;
+				gtk_tree_model_iter_children(model, &citer, &titer);
+				
+				do
 				{
-					GtkTreeIter child, parent;
-					gtk_tree_model_get_iter(model, &parent, path);
-
-					gchar *filename = NULL;
-					gtk_tree_model_get(model, &parent, FILEPATH, &filename, -1);
-
-					GList *child_references = NULL;
-					if(gtk_tree_model_iter_children(model, &child, &parent))
+					if (!gtk_tree_selection_iter_is_selected(selection, &citer))
 					{
-						/* collect all child nodes references */
-						do
-						{
-							GtkTreePath *child_path = gtk_tree_model_get_path(model, &child);
-							child_references = g_list_append(child_references, gtk_tree_row_reference_new(model, child_path));
-							gtk_tree_path_free(child_path);
-						}
-						while(gtk_tree_model_iter_next(model, &child));
-					}
-
-					/* traverse through refernces, removing breakpoints */
-					GList *citer = child_references;
-					while(citer)
-					{
-						GtkTreePath *child_path = gtk_tree_row_reference_get_path((GtkTreeRowReference*)citer->data);
-						GtkTreeIter child_iter;
-						gtk_tree_model_get_iter(model, &child_iter, child_path);
-						
+						gchar *file = NULL;
 						gint line;
-						gtk_tree_model_get(model, &child_iter, LINE, &line, -1);
 
-						breaks_remove(filename, line);
+						gtk_tree_model_get(model, &titer, FILEPATH, &file, -1);
+						gtk_tree_model_get(model, &citer, LINE, &line, -1);
 
-						citer = citer->next;
+						breakpoint *bp = breaks_lookup_breakpoint(file, line);
+						
+						breaks = g_list_append(breaks, bp);
+						
+						g_free(file);
 					}
-					
-					/* free children references list */
-					g_list_foreach (child_references, (GFunc)gtk_tree_row_reference_free, NULL);
-					g_list_free (child_references);
-
-					g_free(filename);
 				}
+				while(gtk_tree_model_iter_next(model, &citer));
 			}
-			
+			else
+			{
+				GtkTreeIter piter;
+				gtk_tree_model_iter_parent(model, &piter, &titer);
+				
+				gchar *file = NULL;
+				gtk_tree_model_get(model, &piter, FILEPATH, &file, -1);
+
+				gint line;
+				gtk_tree_model_get(model, &titer, LINE, &line, -1);
+
+				breakpoint *bp = breaks_lookup_breakpoint(file, line);
+				
+				breaks = g_list_append(breaks, bp);
+				
+				g_free(file);
+			}
 			iter = iter->next;
 		}
+		
+		if (1 == g_list_length(breaks))
+		{
+			breakpoint *bp = (breakpoint*)breaks->data;
+			g_list_free(breaks);
+			breaks_remove(bp->file, bp->line);
+		}
+		else
+		{
+			breaks_remove_list(breaks);
+		}
 
-		/* free rows list */
-		g_list_foreach (references, (GFunc)gtk_tree_row_reference_free, NULL);
-		g_list_free (references);
-
-		dconfig_set_modifyable(TRUE);
-		dconfig_set_changed(TRUE);
-
 		if (new_selection)
 		{
 			/* get path to select */

Modified: trunk/geany-plugins/debugger/src/breakpoints.c
===================================================================
--- trunk/geany-plugins/debugger/src/breakpoints.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/breakpoints.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -30,7 +30,6 @@
 #include "geanyplugin.h"
 extern GeanyFunctions	*geany_functions;
 
-#include "breakpoint.h"
 #include "breakpoints.h"
 #include "utils.h"
 #include "markers.h"
@@ -85,36 +84,82 @@
 }
 
 /*
- * Helper functions
+ * functions to perform markers and tree vew operation when breakpoint
+ * is finally updated/added/removed
  */
-
-/*
- * Remove breakpoint while iterating through GTree.
- * arguments:
- * 		bp - breakpoint
- */
-void handle_break_remove(breakpoint* bp, gboolean success);
-void breaks_remove_internal(breakpoint *bp)
+static void on_add(breakpoint *bp)
 {
-	handle_break_remove(bp, TRUE);
+	/* add to breakpoints tab */
+	bptree_add_breakpoint(bp);
+	/* add marker */
+	markers_add_breakpoint(bp);
 }
+static void on_remove(breakpoint *bp)
+{
+	/* remove marker */
+	markers_remove_breakpoint(bp);
+	/* remove from breakpoints tab */
+	bptree_remove_breakpoint(bp);
+	/* remove from internal storage */
+	GTree *tree = g_hash_table_lookup(files, bp->file);
+	g_tree_remove(tree, GINT_TO_POINTER(bp->line));
+}
+static void on_set_hits_count(breakpoint *bp)
+{
+	bptree_set_hitscount(bp);
+	markers_remove_breakpoint(bp);
+	markers_add_breakpoint(bp);
+}
+static void on_set_condition(breakpoint* bp)
+{
+	/* set condition in breaks tree */
+	bptree_set_condition(bp);
+	markers_remove_breakpoint(bp);
+	markers_add_breakpoint(bp);
+}
+static void on_switch(breakpoint *bp)
+{
+	/* remove old and set new marker */
+	markers_remove_breakpoint(bp);
+	markers_add_breakpoint(bp);
+	
+	/* set checkbox in breaks tree */
+	bptree_set_enabled(bp);
+}
+static void on_set_enabled_list(GList *breaks, gboolean enabled)
+{
+	GList *iter = breaks;
+	while (iter)
+	{
+		breakpoint *bp = (breakpoint*)iter->data;
+		
+		if (bp->enabled ^ enabled)
+		{
+			bp->enabled = enabled;
+			
+			/* remove old and set new marker */
+			markers_remove_breakpoint(bp);
+			markers_add_breakpoint(bp);
+			
+			/* set checkbox in breaks tree */
+			bptree_set_enabled(bp);
+		}
+		iter = iter->next;
+	}
+}
+static void on_remove_list(GList *list)
+{
+	GList *iter;
+	for (iter = list; iter; iter = iter->next)
+	{
+		on_remove((breakpoint*)iter->data);
+	}
+}
 
 /*
- * lookup for breakpoint
- * arguments:
- * 		file - breakpoints filename
- * 		line - breakpoints line
+ * Helper functions
  */
-breakpoint* lookup_breakpoint(const gchar* file, int line)
-{
-	breakpoint* bp = NULL;
-	GTree* tree = NULL;
-	if ( (tree = (GTree*)g_hash_table_lookup(files, file)) )
-		bp = g_tree_lookup(tree, GINT_TO_POINTER(line));
 
-	return bp;
-}
-
 /*
  * compare pointers as integers
  * return value similar to strcmp
@@ -129,92 +174,50 @@
 }
 
 /*
- * Handlers for breakpoints activities.
- * Are called directly from breaks_set_... functions
- * or from async_callback if break was set asyncronously.
- * 
+ * functions that are called when a breakpoint is altered while debuginng session is active.
+ * Therefore, these functions try to alter break in debug session first and if successful -
+ * do what on_... do or simply call on_... function directly
  */
-
-/*
- * handles new break creation
- * arguments:
- * 		bp		- breakpoint to handle
- * 		success - success of operation
- */
-void handle_break_new(breakpoint* bp, gboolean success)
+static void breaks_add_debug(breakpoint* bp)
 {
-	if (success)
+	if (debug_set_break(bp, BSA_NEW_BREAK))
 	{
-		/* add to breakpoints tab */
-		bptree_add_breakpoint(bp);
-		/* add marker */
-		markers_add_breakpoint(bp);
+		/* add markers, update treeview */
+		on_add(bp);
 		/* mark config for saving */
 		dconfig_set_changed();
 	}
 	else
 		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
 }
-
-/*
- * handles break removing
- * arguments:
- * 		bp		- breakpoint to handle
- * 		success - success of operation
- */
-void handle_break_remove(breakpoint* bp, gboolean success)
+static void breaks_remove_debug(breakpoint* bp)
 {
-	if (success)
+	if (debug_remove_break(bp))
 	{
-		/* remove marker */
-		markers_remove_breakpoint(bp);
-		/* remove from breakpoints tab */
-		bptree_remove_breakpoint(bp);
-		/* remove from internal storage */
-		GTree *tree = g_hash_table_lookup(files,bp->file);
-		g_tree_remove(tree, GINT_TO_POINTER(bp->line));
-
+		/* remove markers, update treeview */
+		on_remove(bp);
 		/* mark config for saving */
 		dconfig_set_changed();
 	}
 	else
 		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
 }
-
-/*
- * handles breakpoints hits count set
- * arguments:
- * 		bp		- breakpoint to handle
- * 		success - success of operation
- */
-void handle_hitscount_set(breakpoint* bp, gboolean success)
+static void breaks_set_hits_count_debug(breakpoint* bp)
 {
-	if (success)
+	if (debug_set_break(bp, BSA_UPDATE_HITS_COUNT))
 	{
-		bptree_set_hitscount(bp);
-		markers_remove_breakpoint(bp);
-		markers_add_breakpoint(bp);
+		on_set_hits_count(bp);
 		/* mark config for saving */
 		dconfig_set_changed();
 	}
 	else
 		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
 }
-
-/*
- * handles breakpoints condition set
- * arguments:
- * 		bp		- breakpoint to handle
- * 		success - success of operation
- */
-void handle_condition_set(breakpoint* bp, gboolean success)
+static void breaks_set_condition_debug(breakpoint* bp)
 {
-	if (success)
+	if (debug_set_break(bp, BSA_UPDATE_CONDITION))
 	{
-		/* set condition in breaks tree */
-		bptree_set_condition(bp);
-		markers_remove_breakpoint(bp);
-		markers_add_breakpoint(bp);
+		on_set_condition(bp);
 		/* mark config for saving */
 		dconfig_set_changed();
 	}
@@ -228,55 +231,80 @@
 		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
 	}
 }
+static void breaks_switch_debug(breakpoint* bp)
+{
+	if (debug_set_break(bp, BSA_UPDATE_ENABLE))
+	{
+		on_switch(bp);
+		/* mark config for saving */
+		dconfig_set_changed();
+	}
+	else
+	{
+		bp->enabled = !bp->enabled;
+		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
+	}
+}
+static void breaks_set_disabled_list_debug(GList *list)
+{
+	GList *iter;
+	for (iter = list; iter; iter = iter->next)
+	{
+		breakpoint *bp = (breakpoint*)iter->data;
+		if (bp->enabled)
+		{
+			bp->enabled = FALSE;
+			if (debug_set_break(bp, BSA_UPDATE_ENABLE))
+			{
+				on_switch(bp);
+			}
+			else
+			{
+				bp->enabled = TRUE;
+			}
+		}
+	}
+	g_list_free(list);
 
-/*
- * handles breakpoints enabled/disabled switch
- * arguments:
- * 		bp		- breakpoint to handle
- * 		success - success of operation
- */
-void handle_switch(breakpoint* bp, gboolean success)
+	dconfig_set_changed(TRUE);
+}
+static void breaks_set_enabled_list_debug(GList *list)
 {
-	/* remove old and set new marker */
-	markers_remove_breakpoint(bp);
-	markers_add_breakpoint(bp);
+	GList *iter;
+	for (iter = list; iter; iter = iter->next)
+	{
+		breakpoint *bp = (breakpoint*)iter->data;
+		if (!bp->enabled)
+		{
+			bp->enabled = TRUE;
+			if (debug_set_break(bp, BSA_UPDATE_ENABLE))
+			{
+				on_switch(bp);
+			}
+			else
+			{
+				bp->enabled = FALSE;
+			}
+		}
+	}
+	g_list_free(list);
 
-	/* set checkbox in breaks tree */
-	bptree_set_enabled(bp);
-
-	/* mark config for saving */
-	dconfig_set_changed();
+	dconfig_set_changed(TRUE);
 }
+static void breaks_remove_list_debug(GList *list)
+{
+	GList *iter;
+	for (iter = list; iter; iter = iter->next)
+	{
+		breakpoint *bp = (breakpoint*)iter->data;
+		if (debug_remove_break(bp))
+		{
+			on_remove((breakpoint*)iter->data);
+		}
+	}
+	g_list_free(list);
 
-/*
- * Async action callback.
- * Called from debug module, when debugging session is interrupted
- * and ready to perform action specified by "bsa" with "bp" breakpoint
- * (activity type is passed to debug module when calling its "request_interrupt" function
- * and then is passed to "async_callback")
- * arguments:
- * 		bp	- breakpoint to handle
- * 		bsa	- type of activity (remove/add/change property)
- */
-void async_callback(breakpoint* bp, break_set_activity bsa)
-{
-	/* perform requested operation */
-	gboolean success = BSA_REMOVE == bsa ? debug_remove_break(bp) : debug_set_break(bp, bsa);
-	
-	/* handle relevant case */
-	if (BSA_REMOVE == bsa)
-		handle_break_remove(bp, success);
-	else if (BSA_NEW_BREAK == bsa)
-		handle_break_new(bp, success);
-	else if (BSA_UPDATE_ENABLE == bsa)
-		handle_switch(bp, success);
-	else if (BSA_UPDATE_HITS_COUNT == bsa)
-		handle_hitscount_set(bp, success);
-	else if (BSA_UPDATE_CONDITION == bsa)
-		handle_condition_set(bp, success);
-	
-	/* resume debug session */
-	debug_run();
+	dconfig_set_changed(TRUE);
 }
 
 /*
@@ -341,7 +369,7 @@
 	/* allocate memory */
 	breakpoint* bp = break_new_full(file, line, condition, enabled, hitscount);
 	
-	/* check whether GTree for this file exists and create if not*/
+	/* check whether GTree for this file exists and create if doesn't */
 	GTree *tree;
 	if (!(tree = g_hash_table_lookup(files, bp->file)))
 	{
@@ -355,10 +383,15 @@
 
 	/* handle creation instantly if debugger is idle or stopped
 	and request debug module interruption overwise */
-	if (DBS_IDLE == state || DBS_STOPPED == state)
-		handle_break_new(bp, DBS_IDLE == state || debug_set_break(bp, BSA_NEW_BREAK));
+	if (DBS_IDLE == state)
+	{
+		on_add(bp);
+		dconfig_set_changed(TRUE);
+	}
+	else if (DBS_STOPPED == state)
+		breaks_add_debug(bp);
 	else if (DBS_STOP_REQUESTED != state)
-		debug_request_interrupt(async_callback, bp, BSA_NEW_BREAK);
+		debug_request_interrupt((bs_callback)breaks_add_debug, (gpointer)bp);
 }
 
 /*
@@ -377,28 +410,91 @@
 
 	/* lookup for breakpoint */
 	breakpoint* bp = NULL;
-	if (!(bp = lookup_breakpoint(file, line)))
+	if (!(bp = breaks_lookup_breakpoint(file, line)))
 		return;
 
 	/* handle removing instantly if debugger is idle or stopped
 	and request debug module interruption overwise */
-	if (DBS_IDLE == state || DBS_STOPPED == state)
-		handle_break_remove(bp, DBS_IDLE == state || debug_remove_break(bp));
+	if (DBS_IDLE == state)
+	{
+		on_remove(bp);
+		dconfig_set_changed(TRUE);
+	}
+	else if (DBS_STOPPED == state)
+		breaks_remove_debug(bp);
 	else if (DBS_STOP_REQUESTED != state)
-		debug_request_interrupt(async_callback, bp, BSA_REMOVE);
+		debug_request_interrupt((bs_callback)breaks_remove_debug, (gpointer)bp);
 }
 
 /*
+ * Remove all breakpoints in the list.
+ * arguments:
+ * 		list - list f breakpoints
+ */
+void breaks_remove_list(GList *list)
+{
+	/* do not process async break manipulation on modules
+	that do not support async interuppt */
+	enum dbs state = debug_get_state();
+	if (DBS_RUNNING == state &&  !debug_supports_async_breaks())
+		return;
+
+	/* handle removing instantly if debugger is idle or stopped
+	and request debug module interruption overwise */
+	if (DBS_IDLE == state)
+	{
+		on_remove_list(list);
+		g_list_free(list);
+		
+		dconfig_set_changed(TRUE);
+	}
+	else if (DBS_STOPPED == state)
+		breaks_remove_list_debug(list);
+	else if (DBS_STOP_REQUESTED != state)
+		debug_request_interrupt((bs_callback)breaks_remove_list_debug, (gpointer)list);
+}
+
+/*
  * Removes all breakpoints.
  * arguments:
  */
 void breaks_remove_all()
 {
-	g_hash_table_foreach(files, hash_table_foreach_call_function, (gpointer)breaks_remove_internal);
+	g_hash_table_foreach(files, hash_table_foreach_call_function, (gpointer)on_remove);
 	g_hash_table_remove_all(files);
 }
 
 /*
+ * sets all breakpoints fo the file enabled or disabled.
+ * arguments:
+ * 		file - list of breakpoints
+ * 		enabled - anble or disable breakpoints
+ */
+void breaks_set_enabled_for_file(const const char *file, gboolean enabled)
+{
+	/* do not process async break manipulation on modules
+	that do not support async interuppt */
+	enum dbs state = debug_get_state();
+	if (DBS_RUNNING == state &&  !debug_supports_async_breaks())
+		return;
+
+	GList *breaks = breaks_get_for_document(file);
+
+	/* handle switching instantly if debugger is idle or stopped
+	and request debug module interruption overwise */
+	if (DBS_IDLE == state)
+	{
+		on_set_enabled_list(breaks, enabled);
+		g_list_free(breaks);
+		dconfig_set_changed(TRUE);
+	}
+	else if (DBS_STOPPED == state)
+		enabled ? breaks_set_enabled_list_debug(breaks) : breaks_set_disabled_list_debug(breaks);
+	else if (DBS_STOP_REQUESTED != state)
+		debug_request_interrupt((bs_callback)(enabled ? breaks_set_enabled_list_debug : breaks_set_disabled_list_debug), (gpointer)breaks);
+}
+
+/*
  * Switch breakpoints state.
  * arguments:
  * 		file - breakpoints filename
@@ -414,7 +510,7 @@
 
 	/* lookup for breakpoint */
 	breakpoint* bp = NULL;
-	if (!(bp = lookup_breakpoint(file, line)))
+	if (!(bp = breaks_lookup_breakpoint(file, line)))
 		return;
 	
 	/* change activeness */
@@ -422,10 +518,15 @@
 	
 	/* handle switching instantly if debugger is idle or stopped
 	and request debug module interruption overwise */
-	if (DBS_IDLE == state || DBS_STOPPED == state)
-		handle_switch(bp, state == DBS_IDLE || debug_set_break(bp, BSA_UPDATE_ENABLE));
+	if (DBS_IDLE == state)
+	{
+		on_switch(bp);
+		dconfig_set_changed(TRUE);
+	}
+	else if (DBS_STOPPED == state)
+		breaks_switch_debug(bp);
 	else if (DBS_STOP_REQUESTED != state)
-		debug_request_interrupt(async_callback, bp, BSA_UPDATE_ENABLE);
+		debug_request_interrupt((bs_callback)breaks_switch_debug, (gpointer)bp);
 }
 
 /*
@@ -435,7 +536,7 @@
  * 		line - breakpoints line
  * 		count - breakpoints hitscount
  */
-void breaks_set_hits_count(char* file, int line, int count)
+void breaks_set_hits_count(const char* file, int line, int count)
 {
 	/* do not process async break manipulation on modules
 	that do not support async interuppt */
@@ -445,7 +546,7 @@
 
 	/* lookup for breakpoint */
 	breakpoint* bp = NULL;
-	if (!(bp = lookup_breakpoint(file, line)))
+	if (!(bp = breaks_lookup_breakpoint(file, line)))
 		return;
 	
 	/* change hits count */
@@ -453,10 +554,15 @@
 	
 	/* handle setting hits count instantly if debugger is idle or stopped
 	and request debug module interruption overwise */
-	if (state == DBS_IDLE || state == DBS_STOPPED)
-		handle_hitscount_set(bp, state == DBS_IDLE || debug_set_break(bp, BSA_UPDATE_HITS_COUNT));
+	if (state == DBS_IDLE)
+	{
+		on_set_hits_count(bp);
+		dconfig_set_changed(TRUE);
+	}
+	else if(state == DBS_STOPPED)
+		breaks_set_hits_count_debug(bp);
 	else if (state != DBS_STOP_REQUESTED)
-		debug_request_interrupt(async_callback, bp, BSA_UPDATE_HITS_COUNT);
+		debug_request_interrupt((bs_callback)breaks_set_hits_count_debug, (gpointer)bp);
 }
 
 /*
@@ -466,7 +572,7 @@
  * 		line - breakpoints line
  * 		condition - breakpoints line
  */
-void breaks_set_condition(char* file, int line, char* condition)
+void breaks_set_condition(const char* file, int line, const char* condition)
 {
 	/* do not process async break manipulation on modules
 	that do not support async interuppt */
@@ -476,7 +582,7 @@
 
 	/* lookup for breakpoint */
 	breakpoint* bp = NULL;
-	if (!(bp = lookup_breakpoint(file, line)))
+	if (!(bp = breaks_lookup_breakpoint(file, line)))
 		return;
 	
 	/* change condition */
@@ -484,10 +590,15 @@
 	
 	/* handle setting condition instantly if debugger is idle or stopped
 	and request debug module interruption overwise */
-	if (state == DBS_IDLE || state == DBS_STOPPED)
-		handle_condition_set(bp, DBS_IDLE == state || debug_set_break(bp, BSA_UPDATE_CONDITION));
+	if (state == DBS_IDLE)
+	{
+		on_set_condition(bp);
+		dconfig_set_changed(TRUE);
+	}
+	else if (state == DBS_STOPPED)
+		breaks_set_condition_debug(bp);
 	else if (state != DBS_STOP_REQUESTED)
-		debug_request_interrupt(async_callback, bp, BSA_UPDATE_CONDITION);
+		debug_request_interrupt((bs_callback)breaks_set_condition_debug, (gpointer)bp);
 }
 
 /*
@@ -497,7 +608,7 @@
  * 		line_from - old line number
  * 		line_to - new line number
  */
-void breaks_move_to_line(char* file, int line_from, int line_to)
+void breaks_move_to_line(const char* file, int line_from, int line_to)
 {
 	/* first look for the tree for the given file */
 	GTree *tree = NULL;
@@ -546,7 +657,7 @@
  * arguments:
  * 		file - file name to get breaks for 
  */
-GList *breaks_get_for_document(const char* file)
+GList* breaks_get_for_document(const char* file)
 {
 	GList *breaks = NULL;
 	GTree *tree = g_hash_table_lookup(files, file);
@@ -558,6 +669,22 @@
 }
 
 /*
+ * lookup for breakpoint
+ * arguments:
+ * 		file - breakpoints filename
+ * 		line - breakpoints line
+ */
+breakpoint* breaks_lookup_breakpoint(const gchar* file, int line)
+{
+	breakpoint* bp = NULL;
+	GTree* tree = NULL;
+	if ( (tree = (GTree*)g_hash_table_lookup(files, file)) )
+		bp = g_tree_lookup(tree, GINT_TO_POINTER(line));
+
+	return bp;
+}
+
+/*
  * Gets all breakpoints
  * arguments:
  */

Modified: trunk/geany-plugins/debugger/src/breakpoints.h
===================================================================
--- trunk/geany-plugins/debugger/src/breakpoints.h	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/breakpoints.h	2011-09-16 13:47:03 UTC (rev 2199)
@@ -19,6 +19,8 @@
  *      MA 02110-1301, USA.
  */
 
+#include "breakpoint.h"
+
 typedef enum _break_state {
 	BS_NOT_SET,
 	BS_ENABLED,
@@ -31,12 +33,14 @@
 void			breaks_destroy();
 void			breaks_add(const char* file, int line, char* condition, int enable, int hitscount);
 void			breaks_remove(const char* file, int line);
+void			breaks_remove_list(GList *list);
 void			breaks_remove_all();
-void			breaks_switch(const char* file, int line);
-void			breaks_set_hits_count(char* file, int line, int count);
-void			breaks_set_condition(char* file, int line, char* condition);
-void			breaks_move_to_line(char* file, int line_from, int line_to);
-break_state	breaks_get_state(const char* file, int line);
+void			breaks_switch(const char *file, int line);
+void			breaks_set_hits_count(const char *file, int line, int count);
+void			breaks_set_condition(const char *file, int line, const char* condition);
+void			breaks_set_enabled_for_file(const const char *file, gboolean enabled);
+void			breaks_move_to_line(const char* file, int line_from, int line_to);
+break_state		breaks_get_state(const char* file, int line);
 GList*			breaks_get_for_document(const char* file);
 GList*			breaks_get_all();
-
+breakpoint*		breaks_lookup_breakpoint(const gchar* file, int line);

Modified: trunk/geany-plugins/debugger/src/btnpanel.c
===================================================================
--- trunk/geany-plugins/debugger/src/btnpanel.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/btnpanel.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -30,11 +30,10 @@
 extern GeanyPlugin		*geany_plugin;
 
 #include "gui.h"
-#include "breakpoint.h"
+#include "breakpoints.h"
 #include "debug.h"
 #include "dconfig.h"
 #include "tpage.h"
-#include "breakpoints.h"
 #include "watch_model.h"
 #include "wtree.h"
 #include "dpaned.h"

Modified: trunk/geany-plugins/debugger/src/callbacks.c
===================================================================
--- trunk/geany-plugins/debugger/src/callbacks.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/callbacks.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -27,7 +27,6 @@
 #include <string.h>
 
 #include "geanyplugin.h"
-#include "breakpoint.h"
 #include "breakpoints.h"
 #include "debug.h"
 #include "keys.h"
@@ -289,6 +288,8 @@
 						}
 						iter = iter->next;
 					}
+					
+					dconfig_set_changed();
 
 					g_list_free(breaks);
 				}

Modified: trunk/geany-plugins/debugger/src/dconfig.c
===================================================================
--- trunk/geany-plugins/debugger/src/dconfig.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/dconfig.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -32,11 +32,10 @@
 extern GeanyPlugin		*geany_plugin;
 
 #include "dconfig.h"
-#include "breakpoint.h"
+#include "breakpoints.h"
 #include "debug.h"
 #include "watch_model.h"
 #include "wtree.h"
-#include "breakpoints.h"
 #include "tpage.h"
 #include "bptree.h"
 
@@ -110,14 +109,6 @@
 }
 
 /*
- * set "modifyable" flag that shows that a background thread have to save config
- */
-void dconfig_set_modifyable(gboolean newstate)
-{
-	modifyable = newstate;
-}
-
-/*
  * set "changed" flag to save it on "saving_thread" thread
  */
 void dconfig_set_changed()

Modified: trunk/geany-plugins/debugger/src/dconfig.h
===================================================================
--- trunk/geany-plugins/debugger/src/dconfig.h	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/dconfig.h	2011-09-16 13:47:03 UTC (rev 2199)
@@ -26,6 +26,5 @@
 gboolean 	dconfig_load(gchar *folder);
 
 void		dconfig_set_changed();
-void		dconfig_set_modifyable(gboolean newstate);
 
 

Modified: trunk/geany-plugins/debugger/src/debug.c
===================================================================
--- trunk/geany-plugins/debugger/src/debug.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/debug.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -47,10 +47,9 @@
 extern GeanyData		*geany_data;
 
 #include "tpage.h"
-#include "breakpoint.h"
+#include "breakpoints.h"
 #include "debug.h"
 #include "utils.h"
-#include "breakpoints.h"
 #include "stree.h"
 #include "watch_model.h"
 #include "wtree.h"
@@ -92,8 +91,7 @@
  * after interruption
  */
 bs_callback			interrupt_cb = NULL;
-breakpoint*			interrupt_data = NULL;
-break_set_activity	interrupt_flags;
+gpointer			interrupt_data = NULL;
 
 /* flag to set when debug stop is requested while debugger is running.
  * Then this flag is set to TRUE, and debug_request_interrupt function is called
@@ -645,7 +643,7 @@
 	/* check for async activities pending */
 	if (interrupt_data)
 	{
-		interrupt_cb(interrupt_data, interrupt_flags);
+		interrupt_cb(interrupt_data);
 		interrupt_data = NULL;
 		return;
 	}
@@ -1240,11 +1238,10 @@
  * 		bp - breakpoint to deal with
  * 		flags - whar to do with breakpoint
  */
-void debug_request_interrupt(bs_callback cb, breakpoint* bp, break_set_activity flags)
+void debug_request_interrupt(bs_callback cb, gpointer data)
 {
 	interrupt_cb = cb;
-	interrupt_flags = flags;
-	interrupt_data = bp;
+	interrupt_data = data;
 
 	active_module->request_interrupt();	
 }

Modified: trunk/geany-plugins/debugger/src/debug.h
===================================================================
--- trunk/geany-plugins/debugger/src/debug.h	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/debug.h	2011-09-16 13:47:03 UTC (rev 2199)
@@ -32,7 +32,7 @@
 };
 
 /* function type to execute on interrupt */
-typedef void (*bs_callback)(breakpoint*, break_set_activity);
+typedef void	(*bs_callback)(gpointer);
 
 void			debug_init();
 enum dbs		debug_get_state();
@@ -44,8 +44,8 @@
 void			debug_execute_until(const gchar *file, int line);
 gboolean		debug_set_break(breakpoint* bp, break_set_activity bsa);
 gboolean		debug_remove_break(breakpoint* bp);
-void			debug_request_interrupt(bs_callback cb, breakpoint* bp, break_set_activity flags);
-gchar*		debug_error_message();
+void			debug_request_interrupt(bs_callback cb, gpointer data);
+gchar*			debug_error_message();
 GList*			debug_get_modules();
 int				debug_get_module_index(const gchar *modulename);
 gboolean		debug_supports_async_breaks();

Modified: trunk/geany-plugins/debugger/src/dpaned.c
===================================================================
--- trunk/geany-plugins/debugger/src/dpaned.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/dpaned.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -34,7 +34,6 @@
 extern GeanyData		*geany_data;
 
 #include "tabs.h"
-#include "breakpoint.h"
 #include "breakpoints.h"
 #include "debug.h"
 #include "btnpanel.h"
@@ -115,7 +114,7 @@
 /*
  *	first allocation handler to properly set paned position
  */
-void on_size_allocate(GtkWidget *widget,GdkRectangle *allocation, gpointer   user_data)
+static void on_size_allocate(GtkWidget *widget,GdkRectangle *allocation, gpointer   user_data)
 {
 	DISCONNECT_ALLOCATED_PAGE_SIGNALS();
 

Modified: trunk/geany-plugins/debugger/src/markers.c
===================================================================
--- trunk/geany-plugins/debugger/src/markers.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/markers.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -29,7 +29,6 @@
 extern GeanyFunctions	*geany_functions;
 extern GeanyData		*geany_data;
 
-#include "breakpoint.h"
 #include "breakpoints.h"
 
 #include "xpm/breakpoint.xpm"

Modified: trunk/geany-plugins/debugger/src/plugin.c
===================================================================
--- trunk/geany-plugins/debugger/src/plugin.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/plugin.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -28,7 +28,6 @@
 #endif
 
 #include "geanyplugin.h"
-#include "breakpoint.h"
 #include "breakpoints.h"
 #include "callbacks.h"
 #include "debug.h"

Modified: trunk/geany-plugins/debugger/src/stree.c
===================================================================
--- trunk/geany-plugins/debugger/src/stree.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/stree.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -31,7 +31,6 @@
 
 #include "breakpoints.h"
 #include "utils.h"
-#include "breakpoint.h"
 #include "debug_module.h"
 
 #include "xpm/frame_current.xpm"

Modified: trunk/geany-plugins/debugger/src/tpage.c
===================================================================
--- trunk/geany-plugins/debugger/src/tpage.c	2011-09-15 15:23:09 UTC (rev 2198)
+++ trunk/geany-plugins/debugger/src/tpage.c	2011-09-16 13:47:03 UTC (rev 2199)
@@ -33,7 +33,6 @@
 extern GeanyFunctions	*geany_functions;
 extern GeanyData		*geany_data;
 
-#include "breakpoint.h"
 #include "breakpoints.h"
 #include "utils.h"
 #include "watch_model.h"

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Plugins-Commits mailing list