Compare commits

...

13 Commits

Author SHA1 Message Date
beaf20bd4a GIT_SILENT Upgrade ECM and KF5 version requirements for 5.52.0 release. 2018-11-03 12:00:43 +00:00
8ac949d459 Fix minor EBN issues 2018-10-22 19:58:24 +03:00
4c0c6c8d60 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.51.0 release. 2018-10-07 10:07:12 +00:00
f485719012 kimg_rgb: optimize away QRegExp and QString::fromLocal8Bit.
Summary:
The code is even simpler this way.

Found by using heaptrack.

Test Plan: the unittest for rgb still passes.

Reviewers: cfeck

Reviewed By: cfeck

Subscribers: jtamate, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D15890
2018-10-03 00:51:29 +02:00
1db1b94657 [EPS] qWarning -> qCWarning 2018-09-17 11:56:58 +02:00
98c65a438d [EPS] Fix crash at app shutdown (being tried to persist clipboard image)
Summary:
Deny any capabilities when there is no QApp instance.

BUG: 397040

Test Plan:
Untested, as I do not experience the bug on my system and had no time to
invest into trying to.

Reviewers: zccrs, dfaure, pino

Reviewed By: dfaure

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D15405
2018-09-17 11:54:18 +02:00
167967a145 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.50.0 release. 2018-08-31 22:22:12 +00:00
17239a7ea6 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.49.0 release. 2018-08-04 08:43:39 +00:00
118d262bec GIT_SILENT Upgrade ECM and KF5 version requirements for 5.48.0 release. 2018-07-07 21:52:47 +00:00
67a84f459d Use override 2018-06-12 07:01:11 +02:00
de2b942b33 GIT_SILENT Upgrade ECM and KF5 version requirements for 5.47.0 release. 2018-06-02 16:28:21 +00:00
813a7bdddb Remove duplicated mime types from json files
Qt expects a bijection between keys and mime types.
2018-05-25 14:32:11 +03:00
a4d1f4db1d Use override 2018-05-23 08:06:50 +02:00
22 changed files with 117 additions and 108 deletions

View File

@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0)
project(KImageFormats)
include(FeatureSummary)
find_package(ECM 5.46.0 NO_MODULE)
find_package(ECM 5.52.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules")
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)

View File

@ -14,6 +14,7 @@
#include <QPrinter>
#include <QProcess>
#include <QTemporaryFile>
#include <QCoreApplication>
// logging category for this framework, default: log stuff >= warning
Q_LOGGING_CATEGORY(EPSPLUGIN, "epsplugin", QtWarningMsg)
@ -156,7 +157,7 @@ bool EPSHandler::read(QImage *image)
QTemporaryFile tmpFile;
if (!tmpFile.open()) {
qWarning() << "Could not create the temporary file" << tmpFile.fileName();
qCWarning(EPSPLUGIN) << "Could not create the temporary file" << tmpFile.fileName();
return false;
}
qCDebug(EPSPLUGIN) << "temporary file:" << tmpFile.fileName();
@ -198,7 +199,7 @@ bool EPSHandler::read(QImage *image)
converter.setProcessChannelMode(QProcess::ForwardedErrorChannel);
converter.start(QStringLiteral("gs"), gsArgs);
if (!converter.waitForStarted(3000)) {
qWarning() << "Reading EPS files requires gs (from GhostScript)";
qCWarning(EPSPLUGIN) << "Reading EPS files requires gs (from GhostScript)";
return false;
}
@ -297,7 +298,7 @@ bool EPSHandler::write(const QImage &image)
converter.start(QStringLiteral("gs"), gsArgs);
if (!converter.waitForStarted(3000)) {
qWarning() << "Creating EPS files requires pdftops (from Poppler) or gs (from GhostScript)";
qCWarning(EPSPLUGIN) << "Creating EPS files requires pdftops (from Poppler) or gs (from GhostScript)";
return false;
}
}
@ -312,7 +313,7 @@ bool EPSHandler::write(const QImage &image)
bool EPSHandler::canRead(QIODevice *device)
{
if (!device) {
qWarning("EPSHandler::canRead() called with no device");
qCWarning(EPSPLUGIN) << "EPSHandler::canRead() called with no device";
return false;
}
@ -333,6 +334,15 @@ bool EPSHandler::canRead(QIODevice *device)
QImageIOPlugin::Capabilities EPSPlugin::capabilities(QIODevice *device, const QByteArray &format) const
{
// prevent bug #397040: when on app shutdown the clipboard content is to be copied to survive end of the app,
// QXcbIntegration looks for some QImageIOHandler to apply, querying the capabilities and picking any first.
// At that point this plugin no longer has its requirements e.g. to run the external process, so we have to deny.
// The capabilities seem to be queried on demand in Qt code and not cached, so it's fine to report based
// in current dynamic state
if (!QCoreApplication::instance()) {
return {};
}
if (format == "eps" || format == "epsi" || format == "epsf") {
return Capabilities(CanRead | CanWrite);
}

View File

@ -4,8 +4,8 @@
*
* This library is distributed under the conditions of the GNU LGPL.
*/
#ifndef KIMG_EPS_H
#define KIMG_EPS_H
#ifndef KIMG_EPS_P_H
#define KIMG_EPS_P_H
#include <QImageIOPlugin>
#include <QLoggingCategory>
@ -15,9 +15,9 @@ class EPSHandler : public QImageIOHandler
public:
EPSHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool write(const QImage &image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
bool write(const QImage &image) override;
static bool canRead(QIODevice *device);
};
@ -28,11 +28,11 @@ class EPSPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "eps.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
Q_DECLARE_LOGGING_CATEGORY(EPSPLUGIN)
#endif // KIMG_EPS_H
#endif // KIMG_EPS_P_H

View File

@ -41,10 +41,10 @@ public:
{
}
bool read(char c[], int n) Q_DECL_OVERRIDE;
Imf::Int64 tellg() Q_DECL_OVERRIDE;
void seekg(Imf::Int64 pos) Q_DECL_OVERRIDE;
void clear() Q_DECL_OVERRIDE;
bool read(char c[], int n) override;
Imf::Int64 tellg() override;
void seekg(Imf::Int64 pos) override;
void clear() override;
private:
QIODevice *m_dev;

View File

@ -8,8 +8,8 @@
*
*/
#ifndef KIMG_EXR_H
#define KIMG_EXR_H
#ifndef KIMG_EXR_P_H
#define KIMG_EXR_P_H
#include <QImageIOPlugin>
@ -18,8 +18,8 @@ class EXRHandler : public QImageIOHandler
public:
EXRHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *outImage) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *outImage) override;
static bool canRead(QIODevice *device);
};
@ -30,8 +30,8 @@ class EXRPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "exr.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
#endif // KIMG_EXR_H
#endif // KIMG_EXR_P_H

View File

@ -7,8 +7,8 @@
version 2 of the License, or (at your option) any later version.
*/
#ifndef KIMG_HDR_H
#define KIMG_HDR_H
#ifndef KIMG_HDR_P_H
#define KIMG_HDR_P_H
class QImageIO;

View File

@ -17,8 +17,8 @@ class KraHandler : public QImageIOHandler
public:
KraHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
static bool canRead(QIODevice *device);
};
@ -29,8 +29,8 @@ class KraPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "kra.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};

View File

@ -1,5 +1,4 @@
{
"Keys": [ "kra" ],
"MimeTypes": [ "application/x-krita", "application/x-krita" ]
"MimeTypes": [ "application/x-krita" ]
}

View File

@ -17,8 +17,8 @@ class OraHandler : public QImageIOHandler
public:
OraHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
static bool canRead(QIODevice *device);
};
@ -29,8 +29,8 @@ class OraPlugin : public QImageIOPlugin
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "ora.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};

View File

@ -1,5 +1,4 @@
{
"Keys": [ "ora" ],
"MimeTypes": [ "image/openraster", "image/openraster" ]
"MimeTypes": [ "image/openraster" ]
}

View File

@ -7,8 +7,8 @@
version 2 of the License, or (at your option) any later version.
*/
#ifndef KIMG_PCX_H
#define KIMG_PCX_H
#ifndef KIMG_PCX_P_H
#define KIMG_PCX_P_H
#include <QImageIOPlugin>
@ -17,9 +17,9 @@ class PCXHandler : public QImageIOHandler
public:
PCXHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool write(const QImage &image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
bool write(const QImage &image) override;
static bool canRead(QIODevice *device);
};
@ -30,8 +30,8 @@ class PCXPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "pcx.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
#endif // KIMG_PCX_H
#endif // KIMG_PCX_P_H

View File

@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ----------------------------------------------------------------------------
*/

View File

@ -14,12 +14,12 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ----------------------------------------------------------------------------
*/
#ifndef KIMG_PIC_H
#define KIMG_PIC_H
#ifndef KIMG_PIC_P_H
#define KIMG_PIC_P_H
#include <QImageIOPlugin>
#include <QDataStream>
@ -154,13 +154,13 @@ struct PicChannel {
class SoftimagePICHandler : public QImageIOHandler
{
public:
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool write(const QImage &) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
bool write(const QImage &) override;
QVariant option(ImageOption option) const Q_DECL_OVERRIDE;
void setOption(ImageOption option, const QVariant &value) Q_DECL_OVERRIDE;
bool supportsOption(ImageOption option) const Q_DECL_OVERRIDE;
QVariant option(ImageOption option) const override;
void setOption(ImageOption option, const QVariant &value) override;
bool supportsOption(ImageOption option) const override;
static bool canRead(QIODevice *device);
@ -195,8 +195,8 @@ class SoftimagePICPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "pic.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
#endif // KIMG_PIC_H
#endif // KIMG_PIC_P_H

View File

@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*

View File

@ -7,8 +7,8 @@
version 2 of the License, or (at your option) any later version.
*/
#ifndef KIMG_PSD_H
#define KIMG_PSD_H
#ifndef KIMG_PSD_P_H
#define KIMG_PSD_P_H
#include <QImageIOPlugin>
@ -17,8 +17,8 @@ class PSDHandler : public QImageIOHandler
public:
PSDHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
static bool canRead(QIODevice *device);
};
@ -29,9 +29,9 @@ class PSDPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "psd.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
#endif // KIMG_PSD_H
#endif // KIMG_PSD_P_H

View File

@ -8,8 +8,8 @@
version 2 of the License, or (at your option) any later version.
*/
#ifndef KIMG_RAS_H
#define KIMG_RAS_H
#ifndef KIMG_RAS_P_H
#define KIMG_RAS_P_H
#include <QImageIOPlugin>
@ -18,8 +18,8 @@ class RASHandler : public QImageIOHandler
public:
RASHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
static bool canRead(QIODevice *device);
};
@ -30,9 +30,9 @@ class RASPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "ras.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
#endif // KIMG_RAS_H
#endif // KIMG_RAS_P_H

View File

@ -686,8 +686,8 @@ bool RGBHandler::canRead(QIODevice *device)
return false;
}
qint64 oldPos = device->pos();
QByteArray head = device->readLine(64);
const qint64 oldPos = device->pos();
const QByteArray head = device->readLine(64);
int readBytes = head.size();
if (device->isSequential()) {
@ -699,10 +699,7 @@ bool RGBHandler::canRead(QIODevice *device)
device->seek(oldPos);
}
const QRegExp regexp(QLatin1String("^\x01\xda\x01[\x01\x02]"));
QString data(QString::fromLocal8Bit(head));
return data.contains(regexp);
return head.size() >= 4 && head.startsWith("\x01\xda\x01") && (head[3] == 1 || head[3] == 2);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -7,8 +7,8 @@
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
#ifndef KIMG_RGB_H
#define KIMG_RGB_H
#ifndef KIMG_RGB_P_H
#define KIMG_RGB_P_H
#include <QImageIOPlugin>
@ -17,9 +17,9 @@ class RGBHandler : public QImageIOHandler
public:
RGBHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool write(const QImage &image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
bool write(const QImage &image) override;
static bool canRead(QIODevice *device);
};
@ -30,9 +30,9 @@ class RGBPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "rgb.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
#endif // KIMG_RGB_H
#endif // KIMG_RGB_P_H

View File

@ -14,12 +14,12 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ----------------------------------------------------------------------------
*/
#ifndef KIMAGEFORMATS_RLE_H
#define KIMAGEFORMATS_RLE_H
#ifndef KIMAGEFORMATS_RLE_P_H
#define KIMAGEFORMATS_RLE_P_H
#include <QDebug>
#include <QDataStream>
@ -220,4 +220,4 @@ static inline void encodeRLEData(RLEVariant variant,
}
}
#endif // KIMAGEFORMATS_RLE_H
#endif // KIMAGEFORMATS_RLE_P_H

View File

@ -7,8 +7,8 @@
version 2 of the License, or (at your option) any later version.
*/
#ifndef KIMG_TGA_H
#define KIMG_TGA_H
#ifndef KIMG_TGA_P_H
#define KIMG_TGA_P_H
#include <QImageIOPlugin>
@ -17,9 +17,9 @@ class TGAHandler : public QImageIOHandler
public:
TGAHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool write(const QImage &image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
bool write(const QImage &image) override;
static bool canRead(QIODevice *device);
};
@ -30,8 +30,8 @@ class TGAPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "tga.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
#endif // KIMG_TGA_H
#endif // KIMG_TGA_P_H

View File

@ -19,8 +19,8 @@
*
*/
#ifndef KIMG_XCF_H
#define KIMG_XCF_H
#ifndef KIMG_XCF_P_H
#define KIMG_XCF_P_H
#include <QImageIOPlugin>
@ -29,9 +29,9 @@ class XCFHandler : public QImageIOHandler
public:
XCFHandler();
bool canRead() const Q_DECL_OVERRIDE;
bool read(QImage *image) Q_DECL_OVERRIDE;
bool write(const QImage &image) Q_DECL_OVERRIDE;
bool canRead() const override;
bool read(QImage *image) override;
bool write(const QImage &image) override;
static bool canRead(QIODevice *device);
};
@ -42,8 +42,8 @@ class XCFPlugin : public QImageIOPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "xcf.json")
public:
Capabilities capabilities(QIODevice *device, const QByteArray &format) const Q_DECL_OVERRIDE;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const Q_DECL_OVERRIDE;
Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
};
#endif // KIMG_XCF_H
#endif // KIMG_XCF_P_H

View File

@ -19,6 +19,9 @@
* <http://www.gnu.org/licenses/>.
*/
#ifndef FORMAT_ENUM_H
#define FORMAT_ENUM_H
#include <QImage>
// Generated from QImage::Format enum
@ -71,3 +74,4 @@ QString formatToString(QImage::Format format)
QLatin1String(">");
}
#endif