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..6861d68fd0fdb2b97c9a199dab0b13d26ccc9ac6 100644 |
| --- a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc |
| +++ b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc |
| @@ -5,6 +5,7 @@ |
| #include <gtk/gtk.h> |
| #include <stdio.h> |
| #include <string.h> |
| +#include <string> |
| namespace { |
| @@ -29,7 +30,10 @@ void PrintClipboardContents(GtkClipboard* clip) { |
| printf("%d available targets:\n---------------\n", num_targets); |
| for (int i = 0; i < num_targets; i++) { |
| - printf(" [format: %s", gdk_atom_name(targets[i])); |
| + gchar* target_name_cstr = gdk_atom_name(targets[i]); |
| + std::string target_name(target_name_cstr); |
| + g_free(target_name_cstr); |
| + printf(" [format: %s", target_name.c_str()); |
| GtkSelectionData* data = gtk_clipboard_wait_for_contents(clip, targets[i]); |
| if (!data) { |
| printf("]: NULL\n\n"); |
| @@ -38,21 +42,24 @@ void PrintClipboardContents(GtkClipboard* clip) { |
| printf(" / length: %d / bits %d]: ", data->length, data->format); |
| - if (strstr(gdk_atom_name(targets[i]), "image")) { |
| + if (strstr(target_name.c_str(), "image")) { |
| printf("(image omitted)\n\n"); |
| + gtk_selection_data_free(data); |
| continue; |
|
Evan Stade
2013/05/10 17:55:37
remove L47-48
|
| - } else if (strstr(gdk_atom_name(targets[i]), "TIMESTAMP")) { |
| + } else if (strstr(target_name.c_str(), "TIMESTAMP")) { |
| // TODO(estade): Print the time stamp in human readable format. |
| printf("(time omitted)\n\n"); |
| + gtk_selection_data_free(data); |
| continue; |
|
Evan Stade
2013/05/10 17:55:37
remove L52-53
|
| + } else { |
| + for (int j = 0; j < data->length; j++) { |
| + // Output data one byte at a time. Currently wide strings look |
| + // pretty weird. |
| + printf("%c", (data->data[j] == 0 ? '_' : data->data[j])); |
| + } |
| + printf("\n\n"); |
| + gtk_selection_data_free(data); |
|
Evan Stade
2013/05/10 17:55:37
pull this out
|
| } |
| - |
| - for (int j = 0; j < data->length; j++) { |
| - // Output data one byte at a time. Currently wide strings look |
| - // pretty weird. |
| - printf("%c", (data->data[j] == 0 ? '_' : data->data[j])); |
| - } |
| - printf("\n\n"); |
| } |
| if (num_targets <= 0) { |
| @@ -63,6 +70,7 @@ void PrintClipboardContents(GtkClipboard* clip) { |
| } |
| g_free(targets); |
| + gtk_selection_data_free(target_data); |
| } |
| } |