Commit efed03ba2eee58b0d22f1d41f083ab3b523a8efe
1 parent
004109bc
Exists in
master
and in
5 other branches
Reforma do sistema de actions aparentemente ok, teste por memory leaks saiu com 0
Showing
5 changed files
with
21 additions
and
144 deletions
Show diff stats
Makefile.in
| ... | ... | @@ -82,6 +82,13 @@ $(BINDIR)/Debug/lib/@DLLPREFIX@3270@DLLEXT@: src/lib3270/* src/include/lib3270/* |
| 82 | 82 | run: $(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT) |
| 83 | 83 | @PATH="$(BINDIR)/Debug/lib:$(PATH)" "$(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT)" |
| 84 | 84 | |
| 85 | +memchk: $(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT) | |
| 86 | +ifeq ($(VALGRIND),no) | |
| 87 | + @PATH="$(BINDIR)/Debug/lib:$(PATH)" "$(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT)" | |
| 88 | +else | |
| 89 | + @PATH="$(BINDIR)/Debug/lib:$(PATH)" G_DEBUG=gc-friendly G_SLICE=always-malloc \$(VALGRIND) --leak-check=full --suppressions=src/gtk/valgrind.suppression --gen-suppressions=all $(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT) | |
| 90 | +endif | |
| 91 | + | |
| 85 | 92 | #---[ Targets ]---------------------------------------------------------------- |
| 86 | 93 | |
| 87 | 94 | tgz: $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz | ... | ... |
src/gtk/actions.c
| ... | ... | @@ -39,7 +39,6 @@ |
| 39 | 39 | |
| 40 | 40 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 41 | 41 | |
| 42 | -/* | |
| 43 | 42 | static void lib3270_action(GtkAction *action, GtkWidget *widget) |
| 44 | 43 | { |
| 45 | 44 | int (*call)(H3270 *h) = (int (*)(H3270 *h)) g_object_get_data(G_OBJECT(action),"lib3270_call"); |
| ... | ... | @@ -83,7 +82,7 @@ static void paste_action(GtkAction *action, GtkWidget *widget) |
| 83 | 82 | v3270_paste_clipboard(GTK_V3270(widget)); |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | -void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) | |
| 85 | +static void connect_standard_action(GtkAction *action, GtkWidget *widget, const gchar *name) | |
| 87 | 86 | { |
| 88 | 87 | #undef DECLARE_LIB3270_ACTION |
| 89 | 88 | #undef DECLARE_LIB3270_CLEAR_SELECTION_ACTION |
| ... | ... | @@ -150,7 +149,7 @@ void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, |
| 150 | 149 | // Not-found, disable action |
| 151 | 150 | gtk_action_set_sensitive(action,FALSE); |
| 152 | 151 | } |
| 153 | -*/ | |
| 152 | + | |
| 154 | 153 | |
| 155 | 154 | static void lib3270_toggle_action(GtkToggleAction *action,GtkWidget *widget) |
| 156 | 155 | { |
| ... | ... | @@ -161,29 +160,6 @@ static void lib3270_toggle_action(GtkToggleAction *action,GtkWidget *widget) |
| 161 | 160 | lib3270_set_toggle(GTK_V3270(widget)->host,toggle,gtk_toggle_action_get_active(action)); |
| 162 | 161 | } |
| 163 | 162 | |
| 164 | -/* | |
| 165 | -void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) | |
| 166 | -{ | |
| 167 | - LIB3270_TOGGLE toggle = lib3270_get_toggle_id(id); | |
| 168 | - | |
| 169 | - if(toggle != -1) | |
| 170 | - { | |
| 171 | - GtkAction **list = (GtkAction **) g_object_get_data(G_OBJECT(widget),"toggle_actions"); | |
| 172 | - list[toggle] = action; | |
| 173 | - g_object_set_data(G_OBJECT(action),"toggle_id",(gpointer) toggle); | |
| 174 | - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),(lib3270_get_toggle(GTK_V3270(widget)->host,toggle) != 0)); | |
| 175 | - g_signal_connect(action,"toggled",G_CALLBACK(lib3270_toggle_action),widget); | |
| 176 | - return; | |
| 177 | - } | |
| 178 | - | |
| 179 | - trace("Action %s with toggle %s on widget %p",gtk_action_get_name(action),id,widget); | |
| 180 | - | |
| 181 | - // Not found, disable action | |
| 182 | - gtk_action_set_sensitive(action,FALSE); | |
| 183 | -} | |
| 184 | -*/ | |
| 185 | - | |
| 186 | -/* | |
| 187 | 163 | static void selection_move_action(GtkAction *action, GtkWidget *widget) |
| 188 | 164 | { |
| 189 | 165 | trace("Action %s activated on widget %p dir=%d",gtk_action_get_name(action),widget,g_object_get_data(G_OBJECT(action),"direction")); |
| ... | ... | @@ -197,7 +173,7 @@ static void cursor_move_action(GtkAction *action, GtkWidget *widget) |
| 197 | 173 | lib3270_move_cursor(GTK_V3270(widget)->host,(LIB3270_DIRECTION) (flags & 0x03), (flags & 0x80) ); |
| 198 | 174 | } |
| 199 | 175 | |
| 200 | -void ui_connect_target_action(GtkAction *action, GtkWidget *widget, const gchar *target, unsigned short flags, GError **error) | |
| 176 | +static void connect_move_action(GtkAction *action, GtkWidget *widget, const gchar *target, unsigned short flags, GError **error) | |
| 201 | 177 | { |
| 202 | 178 | int f; |
| 203 | 179 | |
| ... | ... | @@ -219,14 +195,13 @@ void ui_connect_target_action(GtkAction *action, GtkWidget *widget, const gchar |
| 219 | 195 | } |
| 220 | 196 | else |
| 221 | 197 | { |
| 222 | - *error = g_error_new( g_quark_from_static_string(PACKAGE_NAME), | |
| 198 | + *error = g_error_new( ERROR_DOMAIN, | |
| 223 | 199 | ENOENT, |
| 224 | 200 | _( "Unexpected target \"%s\""), |
| 225 | 201 | target); |
| 226 | 202 | } |
| 227 | 203 | |
| 228 | 204 | } |
| 229 | -*/ | |
| 230 | 205 | |
| 231 | 206 | static void action_pfkey(GtkAction *action, GtkWidget *widget) |
| 232 | 207 | { |
| ... | ... | @@ -254,52 +229,6 @@ static void action_reset_toggle(GtkAction *action, GtkWidget *widget) |
| 254 | 229 | lib3270_set_toggle(GTK_V3270(widget)->host,id,0); |
| 255 | 230 | } |
| 256 | 231 | |
| 257 | -/* | |
| 258 | - | |
| 259 | -static void action_reselect(GtkAction *action, GtkWidget *widget) | |
| 260 | -{ | |
| 261 | - lib3270_reselect(GTK_V3270(widget)->host); | |
| 262 | -} | |
| 263 | - | |
| 264 | -static void action_unfullscreen(GtkAction *action, GtkWidget *widget) | |
| 265 | -{ | |
| 266 | - lib3270_set_toggle(GTK_V3270(widget)->host,LIB3270_TOGGLE_FULL_SCREEN,0); | |
| 267 | -} | |
| 268 | - | |
| 269 | -static void action_pastnext(GtkAction *action, GtkWidget *widget) | |
| 270 | -{ | |
| 271 | - lib3270_pastenext(GTK_V3270(widget)->host); | |
| 272 | -} | |
| 273 | - | |
| 274 | -void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst) | |
| 275 | -{ | |
| 276 | -// trace("action(%d): %p",ix,action); | |
| 277 | - | |
| 278 | - switch(ix) | |
| 279 | - { | |
| 280 | - case ACTION_PASTENEXT: | |
| 281 | - g_signal_connect(action,"activate",G_CALLBACK(action_pastnext),widget); | |
| 282 | - break; | |
| 283 | - | |
| 284 | - case ACTION_FULLSCREEN: | |
| 285 | - g_signal_connect(action,"activate",G_CALLBACK(action_fullscreen),widget); | |
| 286 | - break; | |
| 287 | - | |
| 288 | - case ACTION_UNFULLSCREEN: | |
| 289 | - g_signal_connect(action,"activate",G_CALLBACK(action_unfullscreen),widget); | |
| 290 | - break; | |
| 291 | - | |
| 292 | - case ACTION_RESELECT: | |
| 293 | - g_signal_connect(action,"activate",G_CALLBACK(action_reselect),widget); | |
| 294 | - break; | |
| 295 | - | |
| 296 | - default: | |
| 297 | - g_warning("Action \"%s\" has unexpected id %d",gtk_action_get_name(action),ix); | |
| 298 | - gtk_action_set_sensitive(action,FALSE); | |
| 299 | - } | |
| 300 | - } | |
| 301 | -*/ | |
| 302 | - | |
| 303 | 232 | GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash, const gchar **names, const gchar **values, GError **error) |
| 304 | 233 | { |
| 305 | 234 | static const gchar *actionname[ACTION_COUNT] = { "pastenext", |
| ... | ... | @@ -439,6 +368,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
| 439 | 368 | { |
| 440 | 369 | case ACTION_TYPE_DEFAULT: |
| 441 | 370 | action = gtk_action_new(nm,NULL,NULL,NULL); |
| 371 | + connect_standard_action(action,widget,nm); | |
| 442 | 372 | break; |
| 443 | 373 | |
| 444 | 374 | case ACTION_TYPE_TOGGLE: |
| ... | ... | @@ -451,6 +381,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
| 451 | 381 | |
| 452 | 382 | case ACTION_TYPE_MOVE: |
| 453 | 383 | action = gtk_action_new(nm,NULL,NULL,NULL); |
| 384 | + connect_move_action(action,widget,attr,flags,error); | |
| 454 | 385 | break; |
| 455 | 386 | |
| 456 | 387 | case ACTION_TYPE_PFKEY: |
| ... | ... | @@ -489,7 +420,6 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
| 489 | 420 | } |
| 490 | 421 | |
| 491 | 422 | g_hash_table_insert(hash,nm,action); |
| 492 | - g_free(nm); | |
| 493 | 423 | |
| 494 | 424 | return action; |
| 495 | 425 | } | ... | ... |
src/include/lib3270/action_table.h
src/lib3270/paste.c
| ... | ... | @@ -277,23 +277,23 @@ LIB3270_EXPORT int lib3270_paste(H3270 *h, const unsigned char *str) |
| 277 | 277 | return 0; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | -LIB3270_EXPORT int lib3270_pastenext(H3270 *h) | |
| 280 | +LIB3270_ACTION(pastenext) | |
| 281 | 281 | { |
| 282 | 282 | char * ptr; |
| 283 | 283 | int rc; |
| 284 | 284 | |
| 285 | - CHECK_SESSION_HANDLE(h); | |
| 285 | + CHECK_SESSION_HANDLE(hSession); | |
| 286 | 286 | |
| 287 | - if(!(lib3270_connected(h) && h->paste_buffer)) | |
| 287 | + if(!(lib3270_connected(hSession) && hSession->paste_buffer)) | |
| 288 | 288 | { |
| 289 | - lib3270_ring_bell(h); | |
| 289 | + lib3270_ring_bell(hSession); | |
| 290 | 290 | return 0; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - ptr = h->paste_buffer; | |
| 294 | - h->paste_buffer = NULL; | |
| 293 | + ptr = hSession->paste_buffer; | |
| 294 | + hSession->paste_buffer = NULL; | |
| 295 | 295 | |
| 296 | - rc = lib3270_paste(h,(unsigned char *) ptr); | |
| 296 | + rc = lib3270_paste(hSession,(unsigned char *) ptr); | |
| 297 | 297 | |
| 298 | 298 | free(ptr); |
| 299 | 299 | return rc; | ... | ... |
valgrind.suppression
| ... | ... | @@ -1,61 +0,0 @@ |
| 1 | -{ | |
| 2 | - libfontconfig.so.Addr4 | |
| 3 | - Memcheck:Addr4 | |
| 4 | - obj:/usr/lib/libfontconfig.so.* | |
| 5 | -} | |
| 6 | - | |
| 7 | -{ | |
| 8 | - libfontconfig.so.malloc | |
| 9 | - Memcheck:Leak | |
| 10 | - fun:malloc | |
| 11 | - obj:/usr/lib/libfontconfig.so.* | |
| 12 | -} | |
| 13 | - | |
| 14 | -{ | |
| 15 | - libglib-calloc | |
| 16 | - Memcheck:Leak | |
| 17 | - fun:calloc | |
| 18 | - obj:/usr/lib/libglib-* | |
| 19 | -} | |
| 20 | - | |
| 21 | -{ | |
| 22 | - g_type_register_fundamental | |
| 23 | - Memcheck:Leak | |
| 24 | - ... | |
| 25 | - fun:g_type_register_fundamental | |
| 26 | -} | |
| 27 | - | |
| 28 | -{ | |
| 29 | - g_vfs_get_file_for_path | |
| 30 | - Memcheck:Leak | |
| 31 | - ... | |
| 32 | - fun:g_vfs_get_file_for_path | |
| 33 | -} | |
| 34 | - | |
| 35 | -{ | |
| 36 | - g_type_register_static | |
| 37 | - Memcheck:Leak | |
| 38 | - ... | |
| 39 | - fun:g_type_register_static | |
| 40 | -} | |
| 41 | - | |
| 42 | -{ | |
| 43 | - libxcb.so.malloc | |
| 44 | - Memcheck:Leak | |
| 45 | - ... | |
| 46 | - obj:/usr/lib/libxcb.so.* | |
| 47 | -} | |
| 48 | - | |
| 49 | -{ | |
| 50 | - gtk_module_init | |
| 51 | - Memcheck:Leak | |
| 52 | - ... | |
| 53 | - obj:/usr/lib/libgtk-* | |
| 54 | -} | |
| 55 | - | |
| 56 | -{ | |
| 57 | - g_type_create_instance | |
| 58 | - Memcheck:Leak | |
| 59 | - ... | |
| 60 | - obj:/usr/lib/libgobject-* | |
| 61 | -} |