Commit 54bdc4f343727654eb1ea3ec9a2628d9de59cdc9
1 parent
8075dae7
Exists in
master
and in
1 other branch
Adjustment to try to identify print dialog randomic segfaults.
Showing
3 changed files
with
89 additions
and
12 deletions
Show diff stats
src/dialogs/print/convenience.c
... | ... | @@ -50,15 +50,19 @@ |
50 | 50 | GtkPrintOperation * operation = v3270_print_operation_new(widget, mode); |
51 | 51 | |
52 | 52 | gtk_print_operation_set_show_progress(operation,TRUE); |
53 | + gtk_print_operation_set_allow_async(operation,FALSE); | |
54 | + | |
55 | + GtkPrintOperationResult result = GTK_PRINT_OPERATION_RESULT_ERROR; | |
53 | 56 | |
54 | 57 | if(error) |
55 | 58 | { |
56 | - gtk_print_operation_run( | |
59 | + result = | |
60 | + gtk_print_operation_run( | |
57 | 61 | operation, |
58 | 62 | GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, |
59 | 63 | GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
60 | 64 | error |
61 | - ); | |
65 | + ); | |
62 | 66 | |
63 | 67 | rc = (*error == NULL ? 0 : -1); |
64 | 68 | |
... | ... | @@ -67,12 +71,13 @@ |
67 | 71 | { |
68 | 72 | GError *err = NULL; |
69 | 73 | |
70 | - gtk_print_operation_run( | |
74 | + result = | |
75 | + gtk_print_operation_run( | |
71 | 76 | operation, |
72 | 77 | GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, |
73 | 78 | GTK_WINDOW(gtk_widget_get_toplevel(widget)), |
74 | 79 | &err |
75 | - ); | |
80 | + ); | |
76 | 81 | |
77 | 82 | if(err) |
78 | 83 | { |
... | ... | @@ -89,7 +94,36 @@ |
89 | 94 | } |
90 | 95 | } |
91 | 96 | |
97 | + switch(result) | |
98 | + { | |
99 | + case GTK_PRINT_OPERATION_RESULT_ERROR: | |
100 | + g_message("Error on print operation"); | |
101 | + rc = -1; | |
102 | + break; | |
103 | + | |
104 | + case GTK_PRINT_OPERATION_RESULT_APPLY: | |
105 | + g_message("The print settings should be stored."); | |
106 | + rc = 0; | |
107 | + break; | |
108 | + | |
109 | + case GTK_PRINT_OPERATION_RESULT_CANCEL: | |
110 | + g_message("The print operation has been canceled, the print settings should not be stored."); | |
111 | + rc = 0; | |
112 | + break; | |
113 | + | |
114 | + case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: | |
115 | + g_message("The print operation is running"); | |
116 | + rc = 0; | |
117 | + break; | |
118 | + | |
119 | + default: | |
120 | + g_message("Unexpected status %d in print operation",(int) result); | |
121 | + | |
122 | + } | |
123 | + | |
124 | + debug("%s(%p)",__FUNCTION__,operation); | |
92 | 125 | g_object_unref(operation); |
126 | + debug("%s(%p)",__FUNCTION__,operation); | |
93 | 127 | |
94 | 128 | return rc; |
95 | 129 | ... | ... |
src/dialogs/print/draw.c
... | ... | @@ -114,7 +114,7 @@ |
114 | 114 | size_t col; |
115 | 115 | rect.x = operation->font.info.margin.left; |
116 | 116 | |
117 | - debug("Drawing: %u row=%u selection=%p pos=%u", (unsigned int) drawing, row, selection, (unsigned int) pos); | |
117 | +// debug("Drawing: %u row=%u selection=%p pos=%u", (unsigned int) drawing, row, selection, (unsigned int) pos); | |
118 | 118 | |
119 | 119 | for(col = 0; col < selection->bounds.width;col++) |
120 | 120 | { | ... | ... |
src/dialogs/print/print.c
... | ... | @@ -68,16 +68,24 @@ |
68 | 68 | |
69 | 69 | static void dispose(GObject *object) |
70 | 70 | { |
71 | - debug("%s",__FUNCTION__); | |
71 | + | |
72 | + debug("%s(%p)",__FUNCTION__,object); | |
73 | + g_message("%s(%p)",__FUNCTION__,object); | |
72 | 74 | |
73 | 75 | V3270PrintOperation * operation = GTK_V3270_PRINT_OPERATION(object); |
74 | 76 | |
77 | + debug("%s.operation->font.info.scaled=%p",__FUNCTION__,operation->font.info.scaled); | |
78 | + g_message("%s.operation->font.info.scaled=%p",__FUNCTION__,operation->font.info.scaled); | |
75 | 79 | if(operation->font.info.scaled) |
76 | 80 | cairo_scaled_font_destroy(operation->font.info.scaled); |
77 | 81 | |
82 | + debug("%s.operation->font.name=%p",__FUNCTION__,operation->font.name); | |
83 | + g_message("%s.operation->font.name=%p",__FUNCTION__,operation->font.name); | |
78 | 84 | if(operation->font.name) |
79 | 85 | g_free(operation->font.name); |
80 | 86 | |
87 | + debug("%s.operation->contents.dynamic=%p",__FUNCTION__,operation->font.name); | |
88 | + g_message("%s.operation->contents.dynamic=%p",__FUNCTION__,operation->font.name); | |
81 | 89 | if(operation->contents.dynamic) |
82 | 90 | { |
83 | 91 | #pragma GCC diagnostic push |
... | ... | @@ -85,14 +93,18 @@ |
85 | 93 | #pragma GCC diagnostic ignored "-Wcast-function-type" |
86 | 94 | #endif // _WIN32 |
87 | 95 | |
88 | - g_list_free_full(operation->contents.dynamic,(GDestroyNotify) lib3270_free); | |
96 | + g_list_free_full(operation->contents.dynamic,g_free); | |
89 | 97 | operation->contents.dynamic = NULL; |
90 | 98 | |
91 | 99 | #pragma GCC diagnostic pop |
92 | 100 | } |
93 | 101 | operation->contents.selection = NULL; |
94 | 102 | |
103 | + debug("%s: Calling parent dispose",__FUNCTION__); | |
104 | + g_message("%s: Calling parent dispose",__FUNCTION__); | |
95 | 105 | G_OBJECT_CLASS(V3270PrintOperation_parent_class)->dispose(object); |
106 | + debug("%s: Dispose is complete",__FUNCTION__); | |
107 | + g_message("%s: Dispose is complete",__FUNCTION__); | |
96 | 108 | |
97 | 109 | |
98 | 110 | } |
... | ... | @@ -181,7 +193,40 @@ |
181 | 193 | return GTK_WIDGET(GTK_V3270_PRINT_OPERATION(operation)->widget); |
182 | 194 | } |
183 | 195 | |
184 | -GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) | |
196 | + | |
197 | +static GList * get_selection(H3270 *hSession, int all) | |
198 | +{ | |
199 | + lib3270_selection * selection = lib3270_get_selection(hSession,0,all); | |
200 | + | |
201 | + if(selection) | |
202 | + { | |
203 | + GList * rc = g_new0(GList,1); | |
204 | + | |
205 | + size_t sz = sizeof(lib3270_selection) + (sizeof(lib3270_selection_element) * ((selection->bounds.width * selection->bounds.height)+1)); | |
206 | + | |
207 | + debug( | |
208 | + "width=%u height=%u length=%u (sz=%u, szHeader=%u, szElement=%u)", | |
209 | + selection->bounds.width, | |
210 | + selection->bounds.height, | |
211 | + (selection->bounds.width * selection->bounds.height), | |
212 | + sz, | |
213 | + sizeof(lib3270_selection), | |
214 | + sizeof(lib3270_selection_element) | |
215 | + ); | |
216 | + | |
217 | + rc->data = g_malloc0(sz); | |
218 | + memcpy(rc->data,selection,sz); | |
219 | + | |
220 | + lib3270_free(selection); | |
221 | + | |
222 | + return rc; | |
223 | + } | |
224 | + | |
225 | + g_warning("Error getting selection"); | |
226 | + return NULL; | |
227 | +} | |
228 | + | |
229 | +GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT_OPTION mode) | |
185 | 230 | { |
186 | 231 | g_return_val_if_fail(GTK_IS_V3270(widget),NULL); |
187 | 232 | |
... | ... | @@ -198,8 +243,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT |
198 | 243 | { |
199 | 244 | case LIB3270_CONTENT_ALL: |
200 | 245 | debug("%s","LIB3270_CONTENT_ALL"); |
201 | - operation->contents.dynamic = g_new0(GList,1); | |
202 | - operation->contents.dynamic->data = (gpointer) lib3270_get_selection(operation->session,0,1); | |
246 | + operation->contents.dynamic = get_selection(operation->session,1); | |
203 | 247 | operation->contents.selection = operation->contents.dynamic; |
204 | 248 | break; |
205 | 249 | |
... | ... | @@ -210,8 +254,7 @@ GtkPrintOperation * v3270_print_operation_new(GtkWidget *widget, LIB3270_CONTENT |
210 | 254 | |
211 | 255 | case LIB3270_CONTENT_SELECTED: |
212 | 256 | debug("%s","LIB3270_CONTENT_SELECTED"); |
213 | - operation->contents.dynamic = g_new0(GList,1); | |
214 | - operation->contents.dynamic->data = (gpointer) lib3270_get_selection(operation->session,0,0); | |
257 | + operation->contents.dynamic = get_selection(operation->session,0); | |
215 | 258 | operation->contents.selection = operation->contents.dynamic; |
216 | 259 | break; |
217 | 260 | } | ... | ... |