diff --git a/qimagereader.cpp b/home/jari/Qt/6.8.0/Src/qtbase/src/gui/image/qimagereader.cpp
index 1f85fef3bd..168a0ae237 100644
--- a/qimagereader.cpp
+++ b/home/jari/Qt/6.8.0/Src/qtbase/src/gui/image/qimagereader.cpp
@@ -134,12 +134,15 @@
 
 QT_BEGIN_NAMESPACE
 
+//#define QIMAGEREADER_DEBUG
+
 using namespace QImageReaderWriterHelpers;
 using namespace Qt::StringLiterals;
 
 Q_TRACE_POINT(qtgui, QImageReader_read_before_reading, QImageReader *reader, const QString &filename);
 Q_TRACE_POINT(qtgui, QImageReader_read_after_reading, QImageReader *reader, bool result);
 
+
 static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
                                                 const QByteArray &format,
                                                 bool autoDetectImageFormat,
@@ -218,41 +221,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
             device->seek(pos);
     }
 
-    if (!handler && !testFormat.isEmpty() && !ignoresFormatAndExtension) {
-        // check if any plugin supports the format (they are not allowed to
-        // read from the device yet).
-        const qint64 pos = device ? device->pos() : 0;
-
-        if (autoDetectImageFormat) {
-            const int keyCount = keyMap.size();
-            for (int i = 0; i < keyCount; ++i) {
-                if (i != suffixPluginIndex) {
-                    QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i));
-                    if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
-#ifdef QIMAGEREADER_DEBUG
-                        qDebug() << "QImageReader::createReadHandler: the" << keyMap.keys().at(i) << "plugin can read this format";
-#endif
-                        handler = plugin->create(device, testFormat);
-                        break;
-                    }
-                }
-            }
-        } else {
-            const int testIndex = keyMap.key(QLatin1StringView(testFormat), -1);
-            if (testIndex != -1) {
-                QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(testIndex));
-                if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
-#ifdef QIMAGEREADER_DEBUG
-                    qDebug() << "QImageReader::createReadHandler: the" << testFormat << "plugin can read this format";
-#endif
-                    handler = plugin->create(device, testFormat);
-                }
-            }
-        }
-        if (device && !device->isSequential())
-            device->seek(pos);
-    }
-
 #endif // QT_NO_IMAGEFORMATPLUGIN
 
     // if we don't have a handler yet, check if we have built-in support for
@@ -290,6 +258,44 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
         if (handler)
             qDebug() << "QImageReader::createReadHandler: using the built-in handler for" << testFormat;
 #endif
+
+#ifndef QT_NO_IMAGEFORMATPLUGIN
+        if (!handler && !testFormat.isEmpty() && !ignoresFormatAndExtension) {
+            // check if any plugin supports the format (they are not allowed to
+            // read from the device yet).
+            const qint64 pos = device ? device->pos() : 0;
+
+            if (autoDetectImageFormat) {
+                const int keyCount = keyMap.size();
+                for (int i = 0; i < keyCount; ++i) {
+                    if (i != suffixPluginIndex) {
+                        QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i));
+                        if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
+#ifdef QIMAGEREADER_DEBUG
+                            qDebug() << "QImageReader::createReadHandler: the" << keyMap.keys().at(i) << "plugin can read this format";
+#endif
+                            handler = plugin->create(device, testFormat);
+                            break;
+                        }
+                    }
+                }
+            } else {
+                const int testIndex = keyMap.key(QLatin1StringView(testFormat), -1);
+                if (testIndex != -1) {
+                    QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(testIndex));
+                    if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) {
+#ifdef QIMAGEREADER_DEBUG
+                        qDebug() << "QImageReader::createReadHandler: the" << testFormat << "plugin can read this format";
+#endif
+                        handler = plugin->create(device, testFormat);
+                    }
+                }
+            }
+            if (device && !device->isSequential())
+                device->seek(pos);
+        }
+#endif // QT_NO_IMAGEFORMATPLUGIN
+
     }
 
     if (handler && device && !suffix.isEmpty()) {
