diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-01-29 13:55:18 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-01-29 22:51:43 +0000 |
commit | 67b069e544da2078cf5c9ba0c95ca9af8ba00b03 (patch) | |
tree | dda3edf650e2a08f86825bbf3d537a7ab33051f2 /ui/qt/qt_ui_utils.cpp | |
parent | 2edf8bbd33e4820c19a52a435ddb2cc8e3e32fdb (diff) | |
download | wireshark-67b069e544da2078cf5c9ba0c95ca9af8ba00b03.tar.gz |
Qt: Add address conversion convenience routines
Add address_to_qstring and address_to_display_qstring, which wrap
address_to_string and address_to_display respectively and return
QStrings. Convert most of the instances in ui/qt to the new routines.
Fix a some memory leaks in the process.
Change-Id: Icda80bbfe0b2df723d54c8da84355255f819af89
Reviewed-on: https://code.wireshark.org/review/6848
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/qt_ui_utils.cpp')
-rw-r--r-- | ui/qt/qt_ui_utils.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/ui/qt/qt_ui_utils.cpp b/ui/qt/qt_ui_utils.cpp index f4a0621080..7c7b5a1d38 100644 --- a/ui/qt/qt_ui_utils.cpp +++ b/ui/qt/qt_ui_utils.cpp @@ -27,6 +27,9 @@ #include <ui/recent.h> #include <ui/ui_util.h> +#include <epan/addr_resolv.h> +#include <epan/to_str.h> + #include <wsutil/str_util.h> #include <QFontDatabase> @@ -36,7 +39,6 @@ format_size_flags_e operator|(format_size_flags_e lhs, format_size_flags_e rhs) return (format_size_flags_e) ((int)lhs| (int)rhs); } - /* * We might want to create our own "wsstring" class with convenience * methods for handling g_malloc()ed strings, GStrings, and a shortcut @@ -53,6 +55,28 @@ QString gchar_free_to_qstring(gchar *glib_string) { return *qt_string; } +const QString address_to_qstring(const _address *address) +{ + QString address_qstr = QString(); + if (address) { + gchar *address_gchar_p = address_to_str(NULL, address); + address_qstr = address_gchar_p; + wmem_free(NULL, address_gchar_p); + } + return address_qstr; +} + +const QString address_to_display_qstring(const _address *address) +{ + QString address_qstr = QString(); + if (address) { + const gchar *address_gchar_p = address_to_display(NULL, address); + address_qstr = address_gchar_p; + wmem_free(NULL, (void *) address_gchar_p); + } + return address_qstr; +} + void smooth_font_size(QFont &font) { QFontDatabase fdb; #if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) |