aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2006-11-30 18:14:48 +0000
committerChristian Grothoff <christian@grothoff.org>2006-11-30 18:14:48 +0000
commitc6a6e23b1d504c53f1ee7f751b0d9e509ad648a7 (patch)
tree91594e2ad5c790f11b6cafded4a3518b8f0d785c
parent316efb02c11676c2c52783f9f9e3931b7c5b76c6 (diff)
downloadgnunet-gtk-c6a6e23b1d504c53f1ee7f751b0d9e509ad648a7.tar.gz
gnunet-gtk-c6a6e23b1d504c53f1ee7f751b0d9e509ad648a7.zip
fixes
-rw-r--r--src/common/iterators.c60
-rw-r--r--src/include/gnunetgtk_common.h9
-rw-r--r--src/plugins/fs/download.c10
-rw-r--r--src/plugins/fs/namespace.c39
-rw-r--r--src/plugins/fs/search.c6
5 files changed, 105 insertions, 19 deletions
diff --git a/src/common/iterators.c b/src/common/iterators.c
index d7441753..b1a54826 100644
--- a/src/common/iterators.c
+++ b/src/common/iterators.c
@@ -27,6 +27,7 @@
27#include "gnunetgtk_common.h" 27#include "gnunetgtk_common.h"
28#include <GNUnet/gnunet_util_crypto.h> 28#include <GNUnet/gnunet_util_crypto.h>
29#include <glib.h> 29#include <glib.h>
30
30/** 31/**
31 * Identical to "gtk_tree_selection_selected_foreach", 32 * Identical to "gtk_tree_selection_selected_foreach",
32 * except that modifications of the underlying model 33 * except that modifications of the underlying model
@@ -75,3 +76,62 @@ void ggc_tree_selection_selected_foreach(GtkTreeSelection *selection,
75 size, 76 size,
76 0); 77 0);
77} 78}
79
80typedef struct {
81 GtkTreeRowReference ** refs;
82 unsigned int pos;
83 unsigned int size;
84} CollectData;
85
86static gboolean
87collectAllRows(GtkTreeModel * model,
88 GtkTreePath * path,
89 GtkTreeIter * iter,
90 gpointer cls) {
91 CollectData * cd = cls;
92
93 if (cd->size == cd->pos)
94 GROW(cd->refs,
95 cd->size,
96 cd->size * 2 + 4);
97 cd->refs[cd->pos++] = gtk_tree_row_reference_new(model,
98 path);
99 return FALSE;
100}
101
102
103/**
104 * Identical to "gtk_tree_model_foreach",
105 * except that modifications of the underlying model
106 * during the iteration are tolerated.
107 */
108void ggc_tree_model_foreach(GtkTreeModel * model,
109 GtkTreeSelectionForeachFunc func,
110 gpointer data) {
111 unsigned int i;
112 GtkTreePath * path;
113 GtkTreeIter iter;
114 CollectData cd;
115
116 memset(&cd,
117 0,
118 sizeof(CollectData));
119 gtk_tree_model_foreach(model,
120 &collectAllRows,
121 &cd);
122 for (i=0;i<cd.pos;i++) {
123 path = gtk_tree_row_reference_get_path(cd.refs[i]);
124 gtk_tree_row_reference_free(cd.refs[i]);
125 if (TRUE == gtk_tree_model_get_iter(model,
126 &iter,
127 path))
128 func(model,
129 path,
130 &iter,
131 data);
132 gtk_tree_path_free(path);
133 }
134 GROW(cd.refs,
135 cd.size,
136 0);
137}
diff --git a/src/include/gnunetgtk_common.h b/src/include/gnunetgtk_common.h
index e1e3011a..fbae950d 100644
--- a/src/include/gnunetgtk_common.h
+++ b/src/include/gnunetgtk_common.h
@@ -151,4 +151,13 @@ void ggc_tree_selection_selected_foreach(GtkTreeSelection *selection,
151 GtkTreeSelectionForeachFunc func, 151 GtkTreeSelectionForeachFunc func,
152 gpointer data); 152 gpointer data);
153 153
154/**
155 * Identical to "gtk_tree_model_foreach",
156 * except that modifications of the underlying model
157 * during the iteration are tolerated.
158 */
159void ggc_tree_model_foreach(GtkTreeModel * model,
160 GtkTreeSelectionForeachFunc func,
161 gpointer data);
162
154#endif 163#endif
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c
index 7f243a3c..bdae8406 100644
--- a/src/plugins/fs/download.c
+++ b/src/plugins/fs/download.c
@@ -409,10 +409,11 @@ check_pending(const char * filename,
409 -1); 409 -1);
410 if ( (name != NULL) && 410 if ( (name != NULL) &&
411 (0 == strcmp(name, filename)) ) { 411 (0 == strcmp(name, filename)) ) {
412 FREE(name); 412 free(name);
413 return SYSERR; 413 return SYSERR;
414 } 414 }
415 FREENONNULL(name); 415 if (name != NULL)
416 free(name);
416 if (SYSERR == check_pending(filename, 417 if (SYSERR == check_pending(filename,
417 &iter)) 418 &iter))
418 return SYSERR; 419 return SYSERR;
@@ -533,7 +534,7 @@ initiateDownload(GtkTreeModel * model,
533 dirPath[0] = '\0'; 534 dirPath[0] = '\0';
534 dirPathLen = 0; 535 dirPathLen = 0;
535 while (gtk_tree_path_get_depth(dirTreePath) > 1) { 536 while (gtk_tree_path_get_depth(dirTreePath) > 1) {
536 const char * dirname; 537 char * dirname;
537 char * new; 538 char * new;
538 539
539 if (! gtk_tree_path_up(dirTreePath)) 540 if (! gtk_tree_path_up(dirTreePath))
@@ -555,6 +556,7 @@ initiateDownload(GtkTreeModel * model,
555 strcat(new, dirPath); 556 strcat(new, dirPath);
556 FREE(dirPath); 557 FREE(dirPath);
557 dirPath = new; 558 dirPath = new;
559 free(dirname);
558 } 560 }
559 gtk_tree_path_free(dirTreePath); 561 gtk_tree_path_free(dirTreePath);
560 562
@@ -733,7 +735,7 @@ clearCompletedDownloadCallback(GtkTreeModel * model,
733 735
734void on_clearCompletedDownloadsButton_clicked_fs(void * unused, 736void on_clearCompletedDownloadsButton_clicked_fs(void * unused,
735 GtkWidget * clearButton) { 737 GtkWidget * clearButton) {
736 gtk_tree_model_foreach(GTK_TREE_MODEL(download_summary), 738 ggc_tree_model_foreach(GTK_TREE_MODEL(download_summary),
737 &clearCompletedDownloadCallback, 739 &clearCompletedDownloadCallback,
738 NULL); 740 NULL);
739} 741}
diff --git a/src/plugins/fs/namespace.c b/src/plugins/fs/namespace.c
index faf02567..47f55a0b 100644
--- a/src/plugins/fs/namespace.c
+++ b/src/plugins/fs/namespace.c
@@ -1031,9 +1031,12 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1031 GE_BREAK(ectx, 0); 1031 GE_BREAK(ectx, 0);
1032 UNREF(metaXML); 1032 UNREF(metaXML);
1033 metaXML = NULL; 1033 metaXML = NULL;
1034 FREENONNULL(last); 1034 if (last != NULL)
1035 FREENONNULL(next); 1035 free(last);
1036 FREENONNULL(freq); 1036 if (next != NULL)
1037 free(next);
1038 if (freq != NULL)
1039 free(freq);
1037 return; 1040 return;
1038 } 1041 }
1039 if (OK == enc2hash(last, 1042 if (OK == enc2hash(last,
@@ -1066,9 +1069,12 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1066 GE_BREAK(ectx, 0); 1069 GE_BREAK(ectx, 0);
1067 UNREF(metaXML); 1070 UNREF(metaXML);
1068 metaXML = NULL; 1071 metaXML = NULL;
1069 FREENONNULL(last); 1072 if (last != NULL)
1070 FREENONNULL(next); 1073 free(last);
1071 FREENONNULL(freq); 1074 if (next != NULL)
1075 free(next);
1076 if (freq != NULL)
1077 free(freq);
1072 return; 1078 return;
1073 } 1079 }
1074 hash2enc(&nextId, 1080 hash2enc(&nextId,
@@ -1148,9 +1154,12 @@ void on_namespaceUpdateButton_clicked_fs(GtkWidget * dummy1,
1148 gtk_widget_destroy(dialog); 1154 gtk_widget_destroy(dialog);
1149 UNREF(metaXML); 1155 UNREF(metaXML);
1150 metaXML = NULL; 1156 metaXML = NULL;
1151 FREENONNULL(last); 1157 if (last != NULL)
1152 FREENONNULL(next); 1158 free(last);
1153 FREENONNULL(freq); 1159 if (next != NULL)
1160 free(next);
1161 if (freq != NULL)
1162 free(freq);
1154 DEBUG_END(); 1163 DEBUG_END();
1155} 1164}
1156 1165
@@ -1248,8 +1257,10 @@ void on_namespaceRatingSpinButton_changed_fs(GtkWidget * dummy,
1248 gtk_widget_set_sensitive(spin, 1257 gtk_widget_set_sensitive(spin,
1249 FALSE); 1258 FALSE);
1250 } 1259 }
1251 FREENONNULL(description); 1260 if (description != NULL)
1252 FREENONNULL(encStr); 1261 free(description);
1262 if (encStr != NULL)
1263 free(encStr);
1253 DEBUG_END(); 1264 DEBUG_END();
1254} 1265}
1255 1266
@@ -1324,8 +1335,10 @@ void on_searchNamespaceComboBoxEntry_changed_fs(GtkWidget * dummy,
1324 gtk_widget_set_sensitive(spin, 1335 gtk_widget_set_sensitive(spin,
1325 FALSE); 1336 FALSE);
1326 } 1337 }
1327 FREENONNULL(descStr); 1338 if (descStr != NULL)
1328 FREENONNULL(encStr); 1339 free(descStr);
1340 if (encStr != NULL)
1341 free(encStr);
1329 DEBUG_END(); 1342 DEBUG_END();
1330} 1343}
1331 1344
diff --git a/src/plugins/fs/search.c b/src/plugins/fs/search.c
index 916504a5..dcf513e1 100644
--- a/src/plugins/fs/search.c
+++ b/src/plugins/fs/search.c
@@ -551,8 +551,10 @@ void on_fssearchbutton_clicked_fs(gpointer dummy2,
551 } 551 }
552 FREE(ustring); 552 FREE(ustring);
553 } 553 }
554 FREENONNULL(descStr); 554 if (descStr != NULL)
555 FREENONNULL(ns); 555 free(descStr);
556 if (ns != NULL)
557 free(ns);
556 } 558 }
557 if (uri == NULL) 559 if (uri == NULL)
558 uri = ECRS_parseCharKeywordURI(ectx, searchString); 560 uri = ECRS_parseCharKeywordURI(ectx, searchString);