diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /WFPalette.cpp | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'WFPalette.cpp')
| -rw-r--r-- | WFPalette.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/WFPalette.cpp b/WFPalette.cpp index d7d8a5e6..d59fa70f 100644 --- a/WFPalette.cpp +++ b/WFPalette.cpp @@ -26,6 +26,7 @@ #include <QDebug> #include "qt_helpers.hpp" +#include "widgets/MessageBox.hpp" #include "ui_wf_palette_design_dialog.h" @@ -73,7 +74,7 @@ namespace auto line = in.readLine(); ++line_counter; - if (++count >= points) + if (++count > points) { throw_qstring (QObject::tr ("Error reading waterfall palette file \"%1:%2\" too many colors.") .arg (file.fileName ()).arg (line_counter)); @@ -221,8 +222,15 @@ namespace auto file_name = QFileDialog::getOpenFileName (this, tr ("Import Palette"), docs, tr ("Palettes (*.pal)")); if (!file_name.isEmpty ()) { - colours_ = load_palette (file_name); - load_table (); + try + { + colours_ = load_palette (file_name); + load_table (); + } + catch (std::exception const& error) + { + MessageBox::critical_message (this, tr ("Import Palette Failed"), QString::fromLocal8Bit (error.what ())); + } } } @@ -237,7 +245,8 @@ namespace file_name += ".pal"; } QFile file {file_name}; - if (file.open (QFile::WriteOnly | QFile::Truncate | QFile::Text)) + bool ok {file.open (QFile::WriteOnly | QFile::Truncate | QFile::Text)}; + if (ok) { QTextStream stream {&file}; Q_FOREACH (auto colour, colours_) @@ -250,10 +259,15 @@ namespace #endif ; } + stream.flush (); + ok = stream.status () == QTextStream::Ok && file.error () == QFileDevice::NoError; } - else + if (!ok) { - throw_qstring (QObject::tr ("Error writing waterfall palette file \"%1\": %2.").arg (file.fileName ()).arg (file.errorString ())); + MessageBox::critical_message (this, tr ("Export Palette Failed"), + tr ("Error writing waterfall palette file \"%1\": %2.") + .arg (file.fileName ()).arg (file.errorString ())); + return; } } } |
