Qt: Make our exported and saved line endings consistent.

Make sure we set QIODevice::Text on our QTextStreams when saving and
exporting text so that we get native line endings on Windows.

Change-Id: I4602157d2d170eb9a2c79032254ea5be236c7589
Reviewed-on: https://code.wireshark.org/review/37336
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Gerald Combs 2020-05-29 09:55:59 -07:00 committed by Anders Broman
parent 76d92ba7e7
commit 4e6f47fa62
3 changed files with 18 additions and 4 deletions

View File

@ -47,8 +47,6 @@
#include <QPrintDialog>
#include <QPrinter>
#include <QScrollBar>
#include <QTextEdit>
#include <QTextStream>
// To do:
// - Show text while tapping.

View File

@ -1557,7 +1557,7 @@ void IOGraphDialog::copyAsCsvClicked()
bool IOGraphDialog::saveCsv(const QString &file_name) const
{
QFile save_file(file_name);
save_file.open(QFile::WriteOnly);
save_file.open(QFile::WriteOnly | QFile::Text);
QTextStream out(&save_file);
makeCsv(out);

View File

@ -293,8 +293,24 @@ void ShowPacketBytesDialog::saveAs()
if (file_name.isEmpty())
return;
QFile::OpenMode open_mode = QFile::WriteOnly;
switch (show_as_) {
case ShowAsASCII:
case ShowAsASCIIandControl:
case ShowAsCArray:
case ShowAsHexDump:
case ShowAsISO8859_1:
case ShowAsYAML:
case ShowAsHTML:
case ShowAsUTF8:
open_mode |= QFile::Text;
// case ShowAsUTF16: ???
default:
break;
}
QFile file(file_name);
file.open(QIODevice::WriteOnly);
file.open(open_mode);
switch (show_as_) {