Commit 77b3b549f14202391011e484a025162e48f4a300

Authored by Perry Werneck
1 parent caf4cba9
Exists in master and in 1 other branch develop

Working on bug related with multi-threaded updates.

Showing 2 changed files with 50 additions and 11 deletions   Show diff stats
src/v3270/iocallback.c
... ... @@ -29,6 +29,7 @@
29 29  
30 30 #include <config.h>
31 31 #include <lib3270.h>
  32 +#include <lib3270/log.h>
32 33 #include "private.h"
33 34  
34 35 static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata);
... ... @@ -142,6 +143,12 @@ gpointer BgCall(struct bgParameter *p)
142 143  
143 144 static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void *parm)
144 145 {
  146 + trace("%s starts -------------------------------------", __FUNCTION__);
  147 +
  148 + int rc = callback(hSession,parm);
  149 +
  150 + trace("%s starts -------------------------------------", __FUNCTION__);
  151 + /*
145 152 struct bgParameter p = { TRUE, hSession, -1, callback, parm };
146 153  
147 154 p.running = TRUE;
... ... @@ -162,7 +169,9 @@ static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void
162 169 g_thread_join(thread);
163 170  
164 171 return p.rc;
  172 + */
165 173  
  174 + return rc;
166 175 }
167 176  
168 177 void v3270_register_io_handlers(G_GNUC_UNUSED v3270Class *cls)
... ...
src/v3270/widget.c
... ... @@ -727,9 +727,24 @@ static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value
727 727  
728 728 }
729 729  
730   -static void update_message(H3270 *session, LIB3270_MESSAGE id)
  730 +static void bg_update_message(H3270 *session)
731 731 {
732   - g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)), v3270_widget_signal[SIGNAL_MESSAGE_CHANGED], 0, (gint) id);
  732 + void *widget = lib3270_get_user_data(session);
  733 + trace("-----A %s %p",__FUNCTION__, lib3270_get_user_data(session));
  734 +
  735 + g_signal_emit(
  736 + GTK_WIDGET(widget),
  737 + v3270_widget_signal[SIGNAL_MESSAGE_CHANGED],
  738 + 0,
  739 + (gint) lib3270_get_program_message(session)
  740 + );
  741 +
  742 + trace("-----B %s %p",__FUNCTION__, lib3270_get_user_data(session));
  743 +}
  744 +
  745 +static void update_message(H3270 *session, G_GNUC_UNUSED LIB3270_MESSAGE id)
  746 +{
  747 + g_idle_add((GSourceFunc) bg_update_message, session);
733 748 }
734 749  
735 750 static void update_luname(H3270 *session, const char *name)
... ... @@ -923,11 +938,21 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title
923 938  
924 939 }
925 940  
926   - static void update_ssl(H3270 *session, G_GNUC_UNUSED LIB3270_SSL_STATE state)
  941 + static gboolean bg_update_ssl(H3270 *session)
927 942 {
928   - v3270_blink_ssl(GTK_V3270(lib3270_get_user_data(session)));
929   - if(state == LIB3270_SSL_NEGOTIATING)
  943 + trace("%s",__FUNCTION__);
  944 +
  945 + v3270_blink_ssl(GTK_V3270(lib3270_get_user_data(session)));
  946 +
  947 + if(lib3270_get_secure(session) == LIB3270_SSL_NEGOTIATING)
930 948 v3270_start_blinking(GTK_WIDGET(lib3270_get_user_data(session)));
  949 +
  950 + return FALSE;
  951 + }
  952 +
  953 + static void update_ssl(H3270 *session, G_GNUC_UNUSED LIB3270_SSL_STATE state)
  954 + {
  955 + g_idle_add((GSourceFunc) bg_update_ssl, session);
931 956 }
932 957  
933 958 const gchar * v3270_default_font = "monospace";
... ... @@ -1020,6 +1045,17 @@ static void v3270_destroy(GtkObject *widget)
1020 1045 {
1021 1046 v3270 * terminal = GTK_V3270(widget);
1022 1047  
  1048 + if(terminal->host)
  1049 + {
  1050 + // Cleanup
  1051 + lib3270_reset_callbacks(terminal->host);
  1052 + lib3270_set_user_data(terminal->host,NULL);
  1053 +
  1054 + // Release session
  1055 + lib3270_session_free(terminal->host);
  1056 + terminal->host = NULL;
  1057 + }
  1058 +
1023 1059 if(terminal->accessible)
1024 1060 {
1025 1061 gtk_accessible_set_widget(terminal->accessible, NULL);
... ... @@ -1027,12 +1063,6 @@ static void v3270_destroy(GtkObject *widget)
1027 1063 terminal->accessible = NULL;
1028 1064 }
1029 1065  
1030   - if(terminal->host)
1031   - {
1032   - lib3270_session_free(terminal->host);
1033   - terminal->host = NULL;
1034   - }
1035   -
1036 1066 if(terminal->font.family)
1037 1067 {
1038 1068 g_free(terminal->font.family);
... ...