diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
| commit | 69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch) | |
| tree | ebc98370a697a9bbd6b973a14fa5113c475c6db7 /WFPalette.cpp | |
| parent | 3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff) | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg'
with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
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; } } } |
