From 5525779b2ea9e2805c5d4a1b6b070ca8b4838396 Mon Sep 17 00:00:00 2001 From: Tatiana Borisova Date: Thu, 5 Dec 2024 17:44:55 +0100 Subject: [PATCH] QTextStream: use new operator bool() around the code - After adding the QTextStream::operator bool(), it is not required to check the QTextStream::status(). It is enough to use the reference of stream in the statement, which returns true if stream status is OK. New operator usage makes code more convenient. Task-number: QTBUG-52189 Change-Id: Id9ecaa8a5c9cf1931dbeefa85f9d948d15379a82 Reviewed-by: Marc Mutz --- src/gui/image/qxpmhandler.cpp | 2 +- .../widgets/draganddrop/fridgemagnets/dragwidget.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index be024d752dc..8f39d281e72 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1137,7 +1137,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const s << '\"'; } s << "};" << Qt::endl; - return (s.status() == QTextStream::Ok); + return static_cast(s); } QXpmHandler::QXpmHandler() diff --git a/tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp b/tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp index a883e7c58af..f6fd06e96fb 100644 --- a/tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp +++ b/tests/manual/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp @@ -21,9 +21,8 @@ DragWidget::DragWidget(QWidget *parent) int x = 5; int y = 5; - while (!inputStream.atEnd()) { - QString word; - inputStream >> word; + QString word; + while (inputStream >> word) { if (!word.isEmpty()) { DragLabel *wordLabel = new DragLabel(word, this); wordLabel->move(x, y);