From 0981a50a57381fb33b010da791b7d82367b681cd Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Tue, 24 Nov 2015 15:10:21 +0100 Subject: [PATCH] Qt: check that a file name was selected before trying to export follow content Bug: 11763 Change-Id: Iab117fe9f572eccc3cf88a9f3ff86a22aa0e33c9 Reviewed-on: https://code.wireshark.org/review/12099 Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin --- ui/qt/follow_stream_dialog.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index ea3c084fed..b2e5d83bab 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -220,22 +220,24 @@ void FollowStreamDialog::findText(bool go_back) void FollowStreamDialog::saveAs() { QString file_name = QFileDialog::getSaveFileName(this, wsApp->windowTitleString(tr("Save Stream Content As" UTF8_HORIZONTAL_ELLIPSIS))); - file_.setFileName(file_name); - file_.open( QIODevice::WriteOnly ); - QTextStream out(&file_); + if (!file_name.isEmpty()) { + file_.setFileName(file_name); + file_.open( QIODevice::WriteOnly ); + QTextStream out(&file_); - save_as_ = true; + save_as_ = true; - readStream(); + readStream(); - if ((follow_info_.show_type != SHOW_RAW) && (follow_info_.show_type != SHOW_UTF8)) - { - out << ui->teStreamContent->toPlainText(); + if ((follow_info_.show_type != SHOW_RAW) && (follow_info_.show_type != SHOW_UTF8)) + { + out << ui->teStreamContent->toPlainText(); + } + + save_as_ = false; + + file_.close(); } - - save_as_ = false; - - file_.close(); } void FollowStreamDialog::helpButton()