Commit 7bb1b77534ae033f407234395bc7a81866c04853
1 parent
d4f9d28b
Exists in
master
and in
4 other branches
Fixing cleanup segfaults.
Showing
6 changed files
with
73 additions
and
10 deletions
Show diff stats
src/objects/actions/abstract.c
| @@ -365,7 +365,11 @@ | @@ -365,7 +365,11 @@ | ||
| 365 | 365 | ||
| 366 | void pw3270_action_set_terminal_widget(GAction *object, GtkWidget *widget) { | 366 | void pw3270_action_set_terminal_widget(GAction *object, GtkWidget *widget) { |
| 367 | 367 | ||
| 368 | - g_return_if_fail(PW3270_IS_ACTION(object) && GTK_IS_V3270(widget)); | 368 | + g_return_if_fail(PW3270_IS_ACTION(object)); |
| 369 | + | ||
| 370 | + if(widget) { | ||
| 371 | + g_return_if_fail(GTK_IS_V3270(widget)); | ||
| 372 | + } | ||
| 369 | 373 | ||
| 370 | pw3270Action * action = PW3270_ACTION(object); | 374 | pw3270Action * action = PW3270_ACTION(object); |
| 371 | 375 | ||
| @@ -380,10 +384,6 @@ | @@ -380,10 +384,6 @@ | ||
| 380 | 384 | ||
| 381 | pw3270Action * action = PW3270_ACTION(object); | 385 | pw3270Action * action = PW3270_ACTION(object); |
| 382 | 386 | ||
| 383 | -// debug("%s(%s) action=%p terminal=%p",__FUNCTION__,pw3270_action_get_name(object),action,action->terminal); | ||
| 384 | - | ||
| 385 | -// debug("%s: terminal=%p",__FUNCTION__,action->terminal); | ||
| 386 | - | ||
| 387 | if(action && action->terminal) { | 387 | if(action && action->terminal) { |
| 388 | return PW3270_ACTION_GET_CLASS(object)->get_enabled(object,action->terminal); | 388 | return PW3270_ACTION_GET_CLASS(object)->get_enabled(object,action->terminal); |
| 389 | } | 389 | } |
src/objects/actions/clipboard.c
| @@ -68,7 +68,7 @@ | @@ -68,7 +68,7 @@ | ||
| 68 | .summary = N_( "Copy selected area to clipboard." ), | 68 | .summary = N_( "Copy selected area to clipboard." ), |
| 69 | .activate = NULL, | 69 | .activate = NULL, |
| 70 | 70 | ||
| 71 | - .group = LIB3270_ACTION_GROUP_SELECTED, | 71 | + .group = LIB3270_ACTION_GROUP_SELECTION, |
| 72 | .activatable = lib3270_has_selection | 72 | .activatable = lib3270_has_selection |
| 73 | 73 | ||
| 74 | }; | 74 | }; |
| @@ -93,7 +93,7 @@ | @@ -93,7 +93,7 @@ | ||
| 93 | .summary = N_( "Cut selected area." ), | 93 | .summary = N_( "Cut selected area." ), |
| 94 | .activate = NULL, | 94 | .activate = NULL, |
| 95 | 95 | ||
| 96 | - .group = LIB3270_ACTION_GROUP_SELECTED, | 96 | + .group = LIB3270_ACTION_GROUP_SELECTION, |
| 97 | .activatable = lib3270_has_selection | 97 | .activatable = lib3270_has_selection |
| 98 | 98 | ||
| 99 | }; | 99 | }; |
src/objects/actions/lib3270/action.c
| @@ -60,8 +60,13 @@ | @@ -60,8 +60,13 @@ | ||
| 60 | 60 | ||
| 61 | static gboolean get_enabled(GAction *action, GtkWidget *terminal) { | 61 | static gboolean get_enabled(GAction *action, GtkWidget *terminal) { |
| 62 | 62 | ||
| 63 | - if(terminal) | ||
| 64 | - return PW3270_LIB3270_ACTION(action)->definition->activatable(v3270_get_session(terminal)) > 0 ? TRUE : FALSE; | 63 | + if(terminal) { |
| 64 | + | ||
| 65 | + H3270 * hSession = v3270_get_session(terminal); | ||
| 66 | + if(hSession) | ||
| 67 | + return PW3270_LIB3270_ACTION(action)->definition->activatable(hSession) > 0 ? TRUE : FALSE; | ||
| 68 | + | ||
| 69 | + } | ||
| 65 | 70 | ||
| 66 | return FALSE; | 71 | return FALSE; |
| 67 | 72 | ||
| @@ -134,6 +139,7 @@ | @@ -134,6 +139,7 @@ | ||
| 134 | } | 139 | } |
| 135 | 140 | ||
| 136 | static gboolean bg_notify_enabled(GAction *action) { | 141 | static gboolean bg_notify_enabled(GAction *action) { |
| 142 | + debug("Action %s was notified (%s)",g_action_get_name(action),g_action_get_enabled(action) ? "Enabled" : "Disabled"); | ||
| 137 | pw3270_action_notify_enabled(action); | 143 | pw3270_action_notify_enabled(action); |
| 138 | return FALSE; | 144 | return FALSE; |
| 139 | } | 145 | } |
src/objects/actions/private.h
| @@ -91,6 +91,7 @@ | @@ -91,6 +91,7 @@ | ||
| 91 | // Internal actions | 91 | // Internal actions |
| 92 | G_GNUC_INTERNAL GAction * pw3270_connect_action_new(void); | 92 | G_GNUC_INTERNAL GAction * pw3270_connect_action_new(void); |
| 93 | G_GNUC_INTERNAL GAction * pw3270_copy_action_new(void); | 93 | G_GNUC_INTERNAL GAction * pw3270_copy_action_new(void); |
| 94 | + G_GNUC_INTERNAL GAction * pw3270_cut_action_new(void); | ||
| 94 | G_GNUC_INTERNAL GAction * pw3270_paste_action_new(void); | 95 | G_GNUC_INTERNAL GAction * pw3270_paste_action_new(void); |
| 95 | 96 | ||
| 96 | #endif // PRIVATE_H_INCLUDED | 97 | #endif // PRIVATE_H_INCLUDED |
src/objects/window/terminal.c
| @@ -87,6 +87,34 @@ | @@ -87,6 +87,34 @@ | ||
| 87 | return FALSE; | 87 | return FALSE; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | + static void on_terminal_destroy(GtkWidget *terminal, GtkWindow * window) { | ||
| 91 | + | ||
| 92 | + if(gtk_window_get_default_widget(window) != terminal) { | ||
| 93 | + return; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + gtk_window_set_default(window,NULL); | ||
| 97 | + pw3270_window_set_subtitle(GTK_WIDGET(window), _("Disconnected from host")); | ||
| 98 | + | ||
| 99 | + // Update actions | ||
| 100 | + size_t ix; | ||
| 101 | + gchar ** actions = g_action_group_list_actions(G_ACTION_GROUP(window)); | ||
| 102 | + | ||
| 103 | + for(ix = 0; actions[ix]; ix++) { | ||
| 104 | + | ||
| 105 | + GAction * action = g_action_map_lookup_action(G_ACTION_MAP(window), actions[ix]); | ||
| 106 | + | ||
| 107 | + if(action && PW3270_IS_ACTION(action)) { | ||
| 108 | + pw3270_action_set_terminal_widget(action,NULL); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + g_strfreev(actions); | ||
| 114 | + | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + | ||
| 90 | static gboolean bg_auto_connect(GtkWidget *terminal) { | 118 | static gboolean bg_auto_connect(GtkWidget *terminal) { |
| 91 | v3270_reconnect(terminal); | 119 | v3270_reconnect(terminal); |
| 92 | return FALSE; | 120 | return FALSE; |
| @@ -135,6 +163,7 @@ | @@ -135,6 +163,7 @@ | ||
| 135 | g_signal_connect(G_OBJECT(terminal), "session_changed", G_CALLBACK(session_changed),label); | 163 | g_signal_connect(G_OBJECT(terminal), "session_changed", G_CALLBACK(session_changed),label); |
| 136 | g_signal_connect(G_OBJECT(terminal), "disconnected", G_CALLBACK(disconnected),window); | 164 | g_signal_connect(G_OBJECT(terminal), "disconnected", G_CALLBACK(disconnected),window); |
| 137 | g_signal_connect(G_OBJECT(terminal), "connected", G_CALLBACK(connected),window); | 165 | g_signal_connect(G_OBJECT(terminal), "connected", G_CALLBACK(connected),window); |
| 166 | + g_signal_connect(G_OBJECT(terminal), "destroy", G_CALLBACK(on_terminal_destroy),window); | ||
| 138 | 167 | ||
| 139 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_close_tab), terminal); | 168 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_close_tab), terminal); |
| 140 | 169 |
src/objects/window/window.c
| @@ -35,7 +35,34 @@ | @@ -35,7 +35,34 @@ | ||
| 35 | 35 | ||
| 36 | G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW); | 36 | G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW); |
| 37 | 37 | ||
| 38 | - static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass G_GNUC_UNUSED(*klass)) { | 38 | + static void destroy(GtkWidget *widget) { |
| 39 | + | ||
| 40 | + debug("%s(%p)",__FUNCTION__,widget); | ||
| 41 | + | ||
| 42 | + // Update actions | ||
| 43 | + size_t ix; | ||
| 44 | + gchar ** actions = g_action_group_list_actions(G_ACTION_GROUP(widget)); | ||
| 45 | + | ||
| 46 | + for(ix = 0; actions[ix]; ix++) { | ||
| 47 | + GAction * action = g_action_map_lookup_action(G_ACTION_MAP(widget), actions[ix]); | ||
| 48 | + | ||
| 49 | + if(action && PW3270_IS_ACTION(action)) { | ||
| 50 | + pw3270_action_set_terminal_widget(action,NULL); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + g_strfreev(actions); | ||
| 56 | + | ||
| 57 | + GTK_WIDGET_CLASS(pw3270ApplicationWindow_parent_class)->destroy(widget); | ||
| 58 | + | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass *klass) { | ||
| 62 | + | ||
| 63 | + GtkWidgetClass * widget = GTK_WIDGET_CLASS(klass); | ||
| 64 | + widget->destroy = destroy; | ||
| 65 | + | ||
| 39 | 66 | ||
| 40 | } | 67 | } |
| 41 | 68 |