Fix potential symbol clash in the IIOF helpers

Since the IIOF helpers are compiled multiple times into different
handler binaries, there is a potential for symbol clash when they are
linked into the same app. Solve by enclosing the IIOF helper class in
a namespace specific to each handler.

Fixes: QTBUG-113349
Pick-to: 6.5
Change-Id: I9784d5f76d990222dba0ba12e3ca30bfaa9945cc
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 34282d8cef)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Eirik Aavitsland 2023-05-31 12:15:43 +02:00 committed by Qt Cherry-pick Bot
parent 21116aec1b
commit 6a28e2066b
8 changed files with 21 additions and 7 deletions

View File

@ -19,6 +19,8 @@ qt_internal_add_plugin(QMacHeifPlugin
qmacheifhandler.cpp qmacheifhandler.h
INCLUDE_DIRECTORIES
../shared
DEFINES
NS_IIOF_HELPERS=QMacHeif
LIBRARIES
${FWCoreFoundation}
${FWCoreGraphics}

View File

@ -4,7 +4,6 @@
#ifndef QT_NO_IMAGEFORMATPLUGIN
#include <qmacheifhandler.h>
#include <qiiofhelpers_p.h>
QT_BEGIN_NAMESPACE

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qmacheifhandler.h"
#include "qiiofhelpers_p.h"
#include <QVariant>
QT_BEGIN_NAMESPACE

View File

@ -6,14 +6,16 @@
#include <QScopedPointer>
#include <QImageIOHandler>
#include "qiiofhelpers_p.h"
QT_BEGIN_NAMESPACE
using namespace NS_IIOF_HELPERS;
class QImage;
class QByteArray;
class QIODevice;
class QVariant;
class QIIOFHelper;
class QMacHeifHandler : public QImageIOHandler
{

View File

@ -14,6 +14,8 @@ qt_internal_add_plugin(QMacJp2Plugin
qmacjp2handler.cpp qmacjp2handler.h
INCLUDE_DIRECTORIES
../shared
DEFINES
NS_IIOF_HELPERS=QMacJp2
LIBRARIES
${FWCoreFoundation}
${FWCoreGraphics}

View File

@ -7,6 +7,8 @@
QT_BEGIN_NAMESPACE
using namespace NS_IIOF_HELPERS;
class QMacJp2HandlerPrivate
{
Q_DECLARE_PUBLIC(QMacJp2Handler)

View File

@ -11,6 +11,12 @@
QT_BEGIN_NAMESPACE
// QImage <-> CGImage conversion functions from QtGui on darwin
CGImageRef qt_mac_toCGImage(const QImage &qImage);
QImage qt_mac_toQImage(CGImageRef image);
namespace NS_IIOF_HELPERS {
// Callbacks for sequential data provider & consumer:
static size_t cbGetBytes(void *info, void *buffer, size_t count)
@ -55,10 +61,6 @@ static size_t cbPutBytes(void *info, const void *buffer, size_t count)
}
// QImage <-> CGImage conversion functions from QtGui on darwin
CGImageRef qt_mac_toCGImage(const QImage &qImage);
QImage qt_mac_toQImage(CGImageRef image);
QImageIOPlugin::Capabilities QIIOFHelpers::systemCapabilities(const QString &uti)
{
QImageIOPlugin::Capabilities res;
@ -286,4 +288,6 @@ bool QIIOFHelper::writeImage(const QImage &in, const QString &uti)
return CGImageDestinationFinalize(cgImageDest);
}
}
QT_END_NAMESPACE

View File

@ -22,6 +22,8 @@
QT_BEGIN_NAMESPACE
namespace NS_IIOF_HELPERS {
/*
Functions to utilize the native ImageIO Framework in OS X and iOS
*/
@ -55,6 +57,8 @@ protected:
QCFType<CFDictionaryRef> cfImageDict = nullptr;
};
}
QT_END_NAMESPACE
#endif