[pim/trojita] src/Gui: Check that LICENSE QFile is open before reading

Espen Sandøy Hustad <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 8f0f2d70dd9328666f0b13233efe6ad9465319e6 by Espen Sandøy Hustad.
Committed on 03/08/2026 at 18:32.
Pushed by ehustad into branch 'master'.

Check that LICENSE QFile is open before reading

And inform the user about the error in the About dialog box.

Fix src/Gui/Window.cpp:2169:9: warning: ignoring return
value of function declared with 'nodiscard' attribute [-Wunused-result]

M  +6    -2    src/Gui/Window.cpp

https://invent.kde.org/pim/trojita/-/commit/8f0f2d70dd9328666f0b13233efe6ad9465319e6

diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index cea4f291b..c1dd671f1 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -2162,10 +2162,14 @@ void MainWindow::slotShowAboutTrojita()
     featuresText += QStringLiteral("</ul>");
     ui.descriptionLabel->setText(ui.descriptionLabel->text() + featuresText);
 
+    QStringList copyright;
     // Find the names of the authors and remove date codes from there
     QFile license(QStringLiteral(":/LICENSE"));
-    license.open(QFile::ReadOnly);
-    const QStringList copyright = copyrightHolders(&license);
+    if (license.open(QFile::ReadOnly)) {
+        copyright = copyrightHolders(&license);
+    } else {
+        copyright << tr("Failed to open license file.");
+    }
 
     ui.credits->setTextFormat(Qt::PlainText);
     ui.credits->setText(copyright.join(QStringLiteral("\n")));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.