aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/main_window.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-12-14 10:29:48 -0800
committerGerald Combs <gerald@wireshark.org>2017-12-14 20:26:52 +0000
commitdb740987fffeb7e8122a6cd40e25f16244af5721 (patch)
tree3b0a6831fefe8c7e13be9d0f01a1916a413aaffe /ui/qt/main_window.cpp
parent4cf7cd3ed20c57dc5977be5be37ced0bd1706d61 (diff)
Qt: Add and use qUtf8Printable.
Qt 5.4 introduced qUtf8Printable, a convenience macro for converting QString to a UTF-8 const char *. Add a compatibility definition and start using it. Change-Id: I3cf88611b1ed1a34082cb2ba82394954e2e6c461 Reviewed-on: https://code.wireshark.org/review/24828 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/main_window.cpp')
-rw-r--r--ui/qt/main_window.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 2dee41a3e5..83c07d73f1 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -1284,7 +1284,7 @@ void MainWindow::mergeCaptureFile()
if (merge_dlg.merge(file_name)) {
gchar *err_msg;
- if (!dfilter_compile(read_filter.toUtf8().constData(), &rfcode, &err_msg)) {
+ if (!dfilter_compile(qUtf8Printable(read_filter), &rfcode, &err_msg)) {
/* Not valid. Tell the user, and go back and run the file
selection box again once they dismiss the alert. */
// Similar to commandline_info.jfilter section in main().
@@ -1455,7 +1455,7 @@ bool MainWindow::saveCaptureFile(capture_file *cf, bool dont_reopen) {
closes the current file and then opens and reloads the saved file,
so make a copy and free it later. */
file_name = cf->filename;
- status = cf_save_records(cf, file_name.toUtf8().constData(), cf->cd_t, cf->iscompressed,
+ status = cf_save_records(cf, qUtf8Printable(file_name), cf->cd_t, cf->iscompressed,
discard_comments, dont_reopen);
switch (status) {
@@ -1545,14 +1545,14 @@ bool MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments,
//#ifndef _WIN32
// /* If the file exists and it's user-immutable or not writable,
// ask the user whether they want to override that. */
-// if (!file_target_unwritable_ui(top_level, file_name.toUtf8().constData())) {
+// if (!file_target_unwritable_ui(top_level, qUtf8Printable(file_name))) {
// /* They don't. Let them try another file name or cancel. */
// continue;
// }
//#endif
/* Attempt to save the file */
- status = cf_save_records(cf, file_name.toUtf8().constData(), file_type, compressed,
+ status = cf_save_records(cf, qUtf8Printable(file_name), file_type, compressed,
discard_comments, dont_reopen);
switch (status) {
@@ -1570,7 +1570,7 @@ bool MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments,
cf->unsaved_changes = false; //we just saved so we signal that we have no unsaved changes
updateForUnsavedChanges(); // we update the title bar to remove the *
/* Add this filename to the list of recent files in the "Recent Files" submenu */
- add_menu_recent_capture_file(file_name.toUtf8().constData());
+ add_menu_recent_capture_file(qUtf8Printable(file_name));
return true;
case CF_WRITE_ERROR:
@@ -1647,9 +1647,9 @@ void MainWindow::exportSelectedPackets() {
* name and the read file name may be relative (if supplied on
* the command line). From Joerg Mayer.
*/
- if (files_identical(capture_file_.capFile()->filename, file_name.toUtf8().constData())) {
+ if (files_identical(capture_file_.capFile()->filename, qUtf8Printable(file_name))) {
QMessageBox msg_box;
- gchar *display_basename = g_filename_display_basename(file_name.toUtf8().constData());
+ gchar *display_basename = g_filename_display_basename(qUtf8Printable(file_name));
msg_box.setIcon(QMessageBox::Critical);
msg_box.setText(QString(tr("Unable to export to \"%1\".").arg(display_basename)));
@@ -1668,14 +1668,14 @@ void MainWindow::exportSelectedPackets() {
//#ifndef _WIN32
// /* If the file exists and it's user-immutable or not writable,
// ask the user whether they want to override that. */
-// if (!file_target_unwritable_ui(top_level, file_name.toUtf8().constData())) {
+// if (!file_target_unwritable_ui(top_level, qUtf8Printable(file_name))) {
// /* They don't. Let them try another file name or cancel. */
// continue;
// }
//#endif
/* Attempt to save the file */
- status = cf_export_specified_packets(capture_file_.capFile(), file_name.toUtf8().constData(), &range, file_type, compressed);
+ status = cf_export_specified_packets(capture_file_.capFile(), qUtf8Printable(file_name), &range, file_type, compressed);
switch (status) {
case CF_WRITE_OK:
@@ -1689,7 +1689,7 @@ void MainWindow::exportSelectedPackets() {
if (discard_comments)
packet_list_queue_draw();
/* Add this filename to the list of recent files in the "Recent Files" submenu */
- add_menu_recent_capture_file(file_name.toUtf8().constData());
+ add_menu_recent_capture_file(qUtf8Printable(file_name));
return;
case CF_WRITE_ERROR:
@@ -2858,7 +2858,7 @@ void MainWindow::removeAdditionalToolbar(QString toolbarName)
AdditionalToolBar *ifToolBar = dynamic_cast<AdditionalToolBar *>(tb);
if (ifToolBar && ifToolBar->menuName().compare(toolbarName)) {
- GList *entry = g_list_find_custom(recent.gui_additional_toolbars, ifToolBar->menuName().toStdString().c_str(), (GCompareFunc) strcmp);
+ GList *entry = g_list_find_custom(recent.gui_additional_toolbars, qUtf8Printable(ifToolBar->menuName()), (GCompareFunc) strcmp);
if (entry) {
recent.gui_additional_toolbars = g_list_remove(recent.gui_additional_toolbars, entry->data);
}