summaryrefslogtreecommitdiffstats
path: root/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2025-03-25 11:58:36 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2025-04-24 10:44:03 +0100
commiteeead68995653ab38e43e9f1494feaaa679dfd07 (patch)
treed27faff34eee926996cabab0d2fafee17c00745d /examples/widgets/draganddrop/draggabletext/dragwidget.cpp
parent323f408be6bcf5bfa5e2d447be94381556e52a62 (diff)
Examples: fix a couple of nodiscard warnings from QFile::open
In one case, the code simply checked for isOpen afterwards; refactor it to use QFile::open's result. In another case, a file was opened from the resource system, so add a check. Pick-to: 6.9 6.8 Change-Id: I5f4c22dd5ce678f15c9c1609c4228d50a2b32a1d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'examples/widgets/draganddrop/draggabletext/dragwidget.cpp')
-rw-r--r--examples/widgets/draganddrop/draggabletext/dragwidget.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
index d56f91e9001..4142a564356 100644
--- a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
+++ b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp
@@ -20,7 +20,12 @@ DragWidget::DragWidget(QWidget *parent)
: QWidget(parent)
{
QFile dictionaryFile(QStringLiteral(":/dictionary/words.txt"));
- dictionaryFile.open(QIODevice::ReadOnly);
+ if (!dictionaryFile.open(QIODevice::ReadOnly)) {
+ // This would be a build problem, as the dictionary is in the
+ // resource system.
+ qFatal("Could not open the dictionary file: %s",
+ qPrintable(dictionaryFile.errorString()));
+ }
QTextStream inputStream(&dictionaryFile);
int x = 5;