Chromium Code Reviews| Index: tools/gtk_clipboard_dump/gtk_clipboard_dump.cc |
| diff --git a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc |
| index c96ee0083693da327190e572246883d8bf7be3a4..abaa40c9a0840ef9ebb73fe0085ceb41d69537d9 100644 |
| --- a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc |
| +++ b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc |
| @@ -28,22 +28,33 @@ void PrintClipboardContents(GtkClipboard* clip) { |
| printf("%d available targets:\n---------------\n", num_targets); |
| + gboolean target_omitted; |
| + gchar* target_name; |
|
Evan Stade
2013/05/09 04:46:06
no reason for these to be declared outside the for
|
| for (int i = 0; i < num_targets; i++) { |
| - printf(" [format: %s", gdk_atom_name(targets[i])); |
| + target_name = gdk_atom_name(targets[i]); |
| + printf(" [format: %s", target_name); |
| GtkSelectionData* data = gtk_clipboard_wait_for_contents(clip, targets[i]); |
| if (!data) { |
| printf("]: NULL\n\n"); |
| + g_free(target_name); |
|
Evan Stade
2013/05/09 04:46:06
just copy it into a std::string and free right awa
|
| continue; |
| } |
| printf(" / length: %d / bits %d]: ", data->length, data->format); |
| - if (strstr(gdk_atom_name(targets[i]), "image")) { |
| + if (strstr(target_name, "image")) { |
| printf("(image omitted)\n\n"); |
| - continue; |
| - } else if (strstr(gdk_atom_name(targets[i]), "TIMESTAMP")) { |
| + target_omitted = true; |
| + } else if (strstr(target_name, "TIMESTAMP")) { |
| // TODO(estade): Print the time stamp in human readable format. |
| printf("(time omitted)\n\n"); |
| + target_omitted = true; |
| + } else |
|
Evan Stade
2013/05/09 04:46:06
curlies
|
| + target_omitted = false; |
| + |
| + g_free(target_name); |
| + if (target_omitted) { |
| + gtk_selection_data_free(data); |
| continue; |
| } |
| @@ -53,6 +64,7 @@ void PrintClipboardContents(GtkClipboard* clip) { |
| printf("%c", (data->data[j] == 0 ? '_' : data->data[j])); |
| } |
| printf("\n\n"); |
| + gtk_selection_data_free(data); |
| } |
| if (num_targets <= 0) { |
| @@ -63,6 +75,7 @@ void PrintClipboardContents(GtkClipboard* clip) { |
| } |
| g_free(targets); |
| + gtk_selection_data_free(target_data); |
| } |
| } |