Commit 92e2cadf36f7eb44fd9ffdacf374584fd1d94cbd
1 parent
81460183
Exists in
master
and in
1 other branch
Fixing segfaults in print settings.
Showing
2 changed files
with
51 additions
and
18 deletions
Show diff stats
src/dialogs/print/convenience.c
... | ... | @@ -32,6 +32,8 @@ |
32 | 32 | #include <v3270/dialogs.h> |
33 | 33 | #include <terminal.h> |
34 | 34 | #include <lib3270/selection.h> |
35 | + #include <lib3270/log.h> | |
36 | + #include <lib3270/trace.h> | |
35 | 37 | |
36 | 38 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
37 | 39 | |
... | ... | @@ -48,17 +50,14 @@ |
48 | 50 | return errno = ENOTCONN; |
49 | 51 | |
50 | 52 | // Print operation. |
53 | + debug("************** %s",__FUNCTION__); | |
51 | 54 | GtkPrintOperation * operation = v3270_print_operation_new(widget, mode); |
52 | 55 | if(!operation) |
53 | 56 | return errno = EPERM; |
54 | 57 | |
55 | 58 | gtk_print_operation_set_show_progress(operation,TRUE); |
56 | 59 | |
57 | -#ifdef DEBUG | |
58 | 60 | gtk_print_operation_set_allow_async(operation,TRUE); |
59 | -#else | |
60 | - gtk_print_operation_set_allow_async(operation,FALSE); | |
61 | -#endif // DEBUG | |
62 | 61 | |
63 | 62 | GtkPrintOperationResult result = GTK_PRINT_OPERATION_RESULT_ERROR; |
64 | 63 | |
... | ... | @@ -105,22 +104,26 @@ |
105 | 104 | switch(result) |
106 | 105 | { |
107 | 106 | case GTK_PRINT_OPERATION_RESULT_ERROR: |
108 | - g_message("Error on print operation"); | |
107 | + debug("%s: Error on print operation",__FUNCTION__); | |
108 | + lib3270_trace_event(v3270_get_session(widget),_("Error on print operation")); | |
109 | 109 | rc = -1; |
110 | 110 | break; |
111 | 111 | |
112 | 112 | case GTK_PRINT_OPERATION_RESULT_APPLY: |
113 | - g_message("The print settings should be stored."); | |
113 | + debug("%s: The print settings should be stored.",__FUNCTION__); | |
114 | + lib3270_trace_event(v3270_get_session(widget),_("The print settings should be stored.")); | |
114 | 115 | rc = 0; |
115 | 116 | break; |
116 | 117 | |
117 | 118 | case GTK_PRINT_OPERATION_RESULT_CANCEL: |
118 | - g_message("The print operation has been canceled, the print settings should not be stored."); | |
119 | + debug("%s: The print operation has been canceled, the print settings should not be stored.", __FUNCTION__); | |
120 | + lib3270_trace_event(v3270_get_session(widget),_("The print operation has been canceled, the print settings should not be stored.")); | |
119 | 121 | rc = 0; |
120 | 122 | break; |
121 | 123 | |
122 | 124 | case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: |
123 | - g_message("The print operation is running"); | |
125 | + debug("%s: The print operation is running",__FUNCTION__); | |
126 | + lib3270_trace_event(v3270_get_session(widget),_("The print operation is running")); | |
124 | 127 | rc = 0; |
125 | 128 | break; |
126 | 129 | ... | ... |
src/dialogs/print/print.c
... | ... | @@ -63,7 +63,36 @@ |
63 | 63 | |
64 | 64 | if(operation->widget) |
65 | 65 | { |
66 | - debug("%s: Emiting signal PRINT_DONE",__FUNCTION__); | |
66 | + debug("%s: Emiting signal PRINT_DONE with result code %d",__FUNCTION__,result); | |
67 | + | |
68 | + switch(result) | |
69 | + { | |
70 | + case GTK_PRINT_OPERATION_RESULT_ERROR: | |
71 | + debug("%s: Error on print operation",__FUNCTION__); | |
72 | + lib3270_trace_event(operation->widget->host,_("Error on print operation")); | |
73 | + break; | |
74 | + | |
75 | + case GTK_PRINT_OPERATION_RESULT_APPLY: | |
76 | + debug("%s: The print settings should be stored.",__FUNCTION__); | |
77 | + lib3270_trace_event(operation->widget->host,_("The print settings should be stored.")); | |
78 | + break; | |
79 | + | |
80 | + case GTK_PRINT_OPERATION_RESULT_CANCEL: | |
81 | + debug("%s: The print operation has been canceled, the print settings should not be stored.", __FUNCTION__); | |
82 | + lib3270_trace_event(operation->widget->host,_("The print operation has been canceled, the print settings should not be stored.")); | |
83 | + break; | |
84 | + | |
85 | + case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: | |
86 | + debug("%s: The print operation is running",__FUNCTION__); | |
87 | + lib3270_trace_event(operation->widget->host,_("The print operation is running")); | |
88 | + break; | |
89 | + | |
90 | + default: | |
91 | + debug("Unexpected status %d in print operation",(int) result); | |
92 | + lib3270_trace_event(operation->widget->host,_("Unexpected status %d in print operation"),(int) result); | |
93 | + | |
94 | + } | |
95 | + | |
67 | 96 | g_signal_emit(GTK_WIDGET(operation->widget), v3270_widget_signal[V3270_SIGNAL_PRINT_DONE], 0, prt, (guint) result); |
68 | 97 | } |
69 | 98 | |
... | ... | @@ -77,6 +106,8 @@ |
77 | 106 | |
78 | 107 | V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(object); |
79 | 108 | |
109 | + operation->contents.selection = NULL; | |
110 | + | |
80 | 111 | debug("%s.operation->font.info.scaled=%p",__FUNCTION__,operation->font.info.scaled); |
81 | 112 | g_message("%s.operation->font.info.scaled=%p",__FUNCTION__,operation->font.info.scaled); |
82 | 113 | if(operation->font.info.scaled) |
... | ... | @@ -103,13 +134,14 @@ |
103 | 134 | #endif // _WIN32 |
104 | 135 | |
105 | 136 | g_list_free_full(operation->contents.dynamic,g_free); |
137 | + | |
106 | 138 | operation->contents.dynamic = NULL; |
107 | 139 | |
108 | 140 | #pragma GCC diagnostic pop |
109 | 141 | } |
110 | - operation->contents.selection = NULL; | |
111 | 142 | |
112 | 143 | debug("%s: Calling parent dispose",__FUNCTION__); |
144 | + | |
113 | 145 | g_message("%s: Calling parent dispose",__FUNCTION__); |
114 | 146 | G_OBJECT_CLASS(V3270PrintOperation_parent_class)->dispose(object); |
115 | 147 | debug("%s: Dispose is complete",__FUNCTION__); |
... | ... | @@ -203,14 +235,12 @@ |
203 | 235 | } |
204 | 236 | |
205 | 237 | |
206 | -static GList * get_selection(H3270 *hSession, int all) | |
238 | +static GList * get_selection(GList *list, H3270 *hSession, int all) | |
207 | 239 | { |
208 | 240 | lib3270_selection * selection = lib3270_get_selection(hSession,0,all); |
209 | 241 | |
210 | 242 | if(selection) |
211 | 243 | { |
212 | - GList * rc = g_new0(GList,1); | |
213 | - | |
214 | 244 | size_t sz = sizeof(lib3270_selection) + (sizeof(lib3270_selection_element) * ((selection->bounds.width * selection->bounds.height)+1)); |
215 | 245 | |
216 | 246 | debug( |
... | ... | @@ -223,12 +253,12 @@ static GList * get_selection(H3270 *hSession, int all) |
223 | 253 | sizeof(lib3270_selection_element) |
224 | 254 | ); |
225 | 255 | |
226 | - rc->data = g_malloc0(sz); | |
227 | - memcpy(rc->data,selection,sz); | |
256 | + gpointer data = g_malloc0(sz); | |
257 | + memcpy(data,selection,sz); | |
228 | 258 | |
229 | 259 | lib3270_free(selection); |
230 | 260 | |
231 | - return rc; | |
261 | + return g_list_append(list,data); | |
232 | 262 | } |
233 | 263 | |
234 | 264 | g_warning("Error getting selection"); |
... | ... | @@ -261,7 +291,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT |
261 | 291 | { |
262 | 292 | case LIB3270_CONTENT_ALL: |
263 | 293 | debug("%s","LIB3270_CONTENT_ALL"); |
264 | - operation->contents.dynamic = get_selection(operation->session,1); | |
294 | + operation->contents.dynamic = get_selection(operation->contents.dynamic, operation->session,1); | |
265 | 295 | operation->contents.selection = operation->contents.dynamic; |
266 | 296 | break; |
267 | 297 | |
... | ... | @@ -272,7 +302,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT |
272 | 302 | |
273 | 303 | case LIB3270_CONTENT_SELECTED: |
274 | 304 | debug("%s","LIB3270_CONTENT_SELECTED"); |
275 | - operation->contents.dynamic = get_selection(operation->session,0); | |
305 | + operation->contents.dynamic = get_selection(operation->contents.dynamic, operation->session,0); | |
276 | 306 | operation->contents.selection = operation->contents.dynamic; |
277 | 307 | break; |
278 | 308 | } | ... | ... |