Commit 43fd85d0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to qlogging categories

parent f17fb1bd
......@@ -28,7 +28,7 @@ include(ECMGenerateHeaders)
include(ECMAddAppIcon)
include(GenerateExportHeader)
include(FeatureSummary)
include(ECMQtDeclareLoggingCategory)
## Generate header with version number
ecm_setup_version(${KDE_APPLICATIONS_VERSION}
VARIABLE_PREFIX GWENVIEW
......@@ -194,5 +194,5 @@ add_subdirectory(cursors)
add_subdirectory(color-schemes)
add_subdirectory(doc)
add_subdirectory(kconf_update)
install(FILES gwenview.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
......@@ -33,7 +33,8 @@ set(gwenview_SRCS
thumbnailviewhelper.cpp
browsemainpage.cpp
)
# need by GV_RETURN_VALUE_IF_FAIL
ecm_qt_declare_logging_category(gwenview_SRCS HEADER gwenview_lib_debug.h IDENTIFIER GWENVIEW_LIB_LOG CATEGORY_NAME org.kde.kdegraphics.gwenview.lib)
if (NOT GWENVIEW_SEMANTICINFO_BACKEND_NONE)
set (gwenview_SRCS
${gwenview_SRCS}
......
org.kde.kdegraphics.gwenview.lib gwenview lib (kdegraphics) IDENTIFIER [GWENVIEW_LIB_LOG]
......@@ -180,6 +180,8 @@ set(gwenviewlib_SRCS
${GV_JPEG_DIR}/transupp.c
)
ecm_qt_declare_logging_category(gwenviewlib_SRCS HEADER gwenview_lib_debug.h IDENTIFIER GWENVIEW_LIB_LOG CATEGORY_NAME org.kde.kdegraphics.gwenview.lib)
if(HAVE_QTDBUS)
set(gwenviewlib_SRCS
${gwenviewlib_SRCS}
......
......@@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "archiveutils.h"
// KDE
#include <QDebug>
#include "gwenview_lib_debug.h"
#include <KFileItem>
#include <QMimeDatabase>
#include <KProtocolManager>
......@@ -37,7 +37,7 @@ bool fileItemIsArchive(const KFileItem& item)
{
QMimeType mimeType = item.determineMimeType();
if (!mimeType.isValid()) {
qWarning() << "determineMimeType() returned a null pointer";
qCWarning(GWENVIEW_LIB_LOG) << "determineMimeType() returned a null pointer";
return false;
}
return !ArchiveUtils::protocolForMimeType(mimeType.name()).isEmpty();
......
......@@ -36,7 +36,7 @@ extern "C" {
// Qt
#include <QBuffer>
#include <QDebug>
#include "gwenview_lib_debug.h"
#include <QtGlobal>
// lcms
......@@ -60,7 +60,7 @@ namespace Gwenview
#undef LOG
//#define ENABLE_LOG
#ifdef ENABLE_LOG
#define LOG(x) //qDebug() << x
#define LOG(x) //qCDebug(GWENVIEW_LIB_LOG) << x
#else
#define LOG(x) ;
#endif
......@@ -78,7 +78,7 @@ static cmsHPROFILE loadFromJpegData(const QByteArray& data)
srcinfo.err = &srcErrorManager;
jpeg_create_decompress(&srcinfo);
if (setjmp(srcErrorManager.jmp_buffer)) {
qCritical() << "libjpeg error in src\n";
qCCritical(GWENVIEW_LIB_LOG) << "libjpeg error in src\n";
return nullptr;
}
......
......@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// Qt
#include <QBuffer>
#include <QDebug>
#include "gwenview_lib_debug.h"
// lcms
#include <lcms2.h>
......@@ -69,21 +69,21 @@ cmsHPROFILE loadFromPngData(const QByteArray& data)
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
qWarning() << "Could not create info_struct";
qCWarning(GWENVIEW_LIB_LOG) << "Could not create info_struct";
return 0;
}
png_infop end_info = png_create_info_struct(png_ptr);
if (!end_info) {
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
qWarning() << "Could not create info_struct2";
qCWarning(GWENVIEW_LIB_LOG) << "Could not create info_struct2";
return 0;
}
// Catch errors
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
qWarning() << "Error decoding png file";
qCWarning(GWENVIEW_LIB_LOG) << "Error decoding png file";
return 0;
}
......
......@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QImage>
// KDE
#include <QDebug>
#include "gwenview_lib_debug.h"
#include <KLocalizedString>
// Local
......@@ -85,7 +85,7 @@ void CropImageOperation::redo()
void CropImageOperation::undo()
{
if (!document()->editor()) {
qWarning() << "!document->editor()";
qCWarning(GWENVIEW_LIB_LOG) << "!document->editor()";
return;
}
document()->editor()->setImage(d->mOriginalImage);
......
......@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QPainter>
#include <QPushButton>
#include <QRect>
#include <QDebug>
#include "gwenview_lib_debug.h"
// KDE
......
......@@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QPushButton>
#include <QSpinBox>
#include <QtMath>
#include <QDebug>
#include "gwenview_lib_debug.h"
#include <QLineEdit>
// KDE
......
......@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <QBuffer>
#include <QImage>
#include <QMovie>
#include <QDebug>
#include "gwenview_lib_debug.h"
// KDE
......@@ -98,8 +98,8 @@ void AnimatedDocumentLoadedImpl::startAnimation()
d->mMovie.start();
if (d->mMovie.state() == QMovie::NotRunning) {
// This is true with qt-copy as of 2008.08.23
//qDebug() << "QMovie didn't start. This can happen in some cases when starting for the second time.";
//qDebug() << "Trying to start again, it usually fixes the bug.";
//qCDebug(GWENVIEW_LIB_LOG) << "QMovie didn't start. This can happen in some cases when starting for the second time.";
//qCDebug(GWENVIEW_LIB_LOG) << "Trying to start again, it usually fixes the bug.";
d->mMovie.start();
}
}
......
......@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QImage>
#include <QUndoStack>
#include <QUrl>
#include <QDebug>
#include "gwenview_lib_debug.h"
// KDE
#include <KLocalizedString>
......@@ -50,7 +50,7 @@ namespace Gwenview
#undef LOG
//#define ENABLE_LOG
#ifdef ENABLE_LOG
#define LOG(x) //qDebug() << x
#define LOG(x) //qCDebug(GWENVIEW_LIB_LOG) << x
#else
#define LOG(x) ;
#endif
......@@ -65,7 +65,7 @@ static void logQueue(DocumentPrivate* d)
qDebug(PREFIX "No current job, no pending jobs");
return;
}
qDebug() << PREFIX "Current job:" << d->mCurrentJob.data();
qCDebug(GWENVIEW_LIB_LOG) << PREFIX "Current job:" << d->mCurrentJob.data();
if (d->mJobQueue.isEmpty()) {
qDebug(PREFIX "No pending jobs");
return;
......@@ -73,7 +73,7 @@ static void logQueue(DocumentPrivate* d)
qDebug(PREFIX "%d pending job(s):", d->mJobQueue.size());
for (DocumentJob* job : qAsConst(d->mJobQueue)) {
Q_ASSERT(job);
qDebug() << PREFIX "-" << job;
qCDebug(GWENVIEW_LIB_LOG) << PREFIX "-" << job;
}
#undef PREFIX
}
......@@ -301,7 +301,7 @@ DocumentJob* Document::save(const QUrl &url, const QByteArray& format)
waitUntilLoaded();
DocumentJob* job = d->mImpl->save(url, format);
if (!job) {
qWarning() << "Implementation does not support saving!";
qCWarning(GWENVIEW_LIB_LOG) << "Implementation does not support saving!";
setErrorString(i18nc("@info", "Gwenview cannot save this kind of documents."));
return nullptr;
}
......@@ -431,14 +431,14 @@ void Document::startLoadingFullImage()
} else if (state == Loaded) {
return;
} else if (state == LoadingFailed) {
qWarning() << "Can't load full image: loading has already failed";
qCWarning(GWENVIEW_LIB_LOG) << "Can't load full image: loading has already failed";
}
}
bool Document::prepareDownSampledImageForZoom(qreal zoom)
{
if (zoom >= maxDownSampledZoom()) {
qWarning() << "No need to call prepareDownSampledImageForZoom if zoom >= " << maxDownSampledZoom();
qCWarning(GWENVIEW_LIB_LOG) << "No need to call prepareDownSampledImageForZoom if zoom >= " << maxDownSampledZoom();
return true;
}
......@@ -450,7 +450,7 @@ bool Document::prepareDownSampledImageForZoom(qreal zoom)
LOG("downSampledImageForZoom=" << zoom << "invertedZoom=" << invertedZoom << "not ready");
if (loadingState() == LoadingFailed) {
qWarning() << "Image has failed to load, not doing anything";
qCWarning(GWENVIEW_LIB_LOG) << "Image has failed to load, not doing anything";
return false;
} else if (loadingState() == Loaded) {
d->scheduleImageDownSampling(invertedZoom);
......
......@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QMap>
#include <QUndoGroup>
#include <QUrl>
#include <QDebug>
#include "gwenview_lib_debug.h"
// KDE
......@@ -39,7 +39,7 @@ namespace Gwenview
#undef LOG
//#define ENABLE_LOG
#ifdef ENABLE_LOG
#define LOG(x) qDebug() << x
#define LOG(x) qCDebug(GWENVIEW_LIB_LOG) << x
#else
#define LOG(x) ;
#endif
......
......@@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include <QFutureWatcher>
#include <QtConcurrentRun>
#include <QApplication>
#include <QDebug>
#include "gwenview_lib_debug.h"
// KDE
#include <KDialogJobUiDelegate>
......
......@@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QImage>
#include <QImageWriter>
#include <QTransform>
#include <QDebug>
#include "gwenview_lib_debug.h"
#include <QUrl>
// KDE
......
......@@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QPointer>
#include <QtConcurrent>
#include <QUrl>
#include <QDebug>
#include "gwenview_lib_debug.h"
// KDE
#include <KIO/Job>
......@@ -74,7 +74,7 @@ namespace Gwenview
#undef LOG
//#define ENABLE_LOG
#ifdef ENABLE_LOG
#define LOG(x) //qDebug() << x
#define LOG(x) //qCDebug(GWENVIEW_LIB_LOG) << x
#else
#define LOG(x) ;
#endif
......@@ -172,7 +172,7 @@ struct LoadingDocumentImplPrivate
break;
default:
qWarning() << "We should not reach this point!";
qCWarning(GWENVIEW_LIB_LOG) << "We should not reach this point!";
break;
}
}
......@@ -215,7 +215,7 @@ struct LoadingDocumentImplPrivate
// That's slower but it works even for images containing
// small (160x120px) or none embedded preview.
if (!KDcrawIface::KDcraw::loadHalfPreview(previewData, buffer)) {
qWarning() << "unable to get half preview for " << q->document()->url().fileName();
qCWarning(GWENVIEW_LIB_LOG) << "unable to get half preview for " << q->document()->url().fileName();
return false;
}
}
......@@ -235,19 +235,19 @@ struct LoadingDocumentImplPrivate
mImageSize = reader.size();
if (!reader.canRead()) {
qWarning() << "QImageReader::read() using format hint" << mFormatHint << "failed:" << reader.errorString();
qCWarning(GWENVIEW_LIB_LOG) << "QImageReader::read() using format hint" << mFormatHint << "failed:" << reader.errorString();
if (buffer.pos() != 0) {
qWarning() << "A bad Qt image decoder moved the buffer to" << buffer.pos() << "in a call to canRead()! Rewinding.";
qCWarning(GWENVIEW_LIB_LOG) << "A bad Qt image decoder moved the buffer to" << buffer.pos() << "in a call to canRead()! Rewinding.";
buffer.seek(0);
}
reader.setFormat(QByteArray());
// Set buffer again, otherwise QImageReader won't restart from scratch
reader.setDevice(&buffer);
if (!reader.canRead()) {
qWarning() << "QImageReader::read() without format hint failed:" << reader.errorString();
qCWarning(GWENVIEW_LIB_LOG) << "QImageReader::read() without format hint failed:" << reader.errorString();
return false;
}
qWarning() << "Image format is actually" << reader.format() << "not" << mFormatHint;
qCWarning(GWENVIEW_LIB_LOG) << "Image format is actually" << reader.format() << "not" << mFormatHint;
}
mFormat = reader.format();
......@@ -269,7 +269,7 @@ struct LoadingDocumentImplPrivate
if (mJpegContent.get()) {
if (!mJpegContent->loadFromData(mData, mExiv2Image.get()) &&
!mJpegContent->loadFromData(mData)) {
qWarning() << "Unable to use preview of " << q->document()->url().fileName();
qCWarning(GWENVIEW_LIB_LOG) << "Unable to use preview of " << q->document()->url().fileName();
return false;
}
// Use the size from JpegContent, as its correctly transposed if the
......@@ -342,7 +342,7 @@ struct LoadingDocumentImplPrivate
LOG("Really an animated image (more than one frame)");
mAnimated = true;
} else {
qWarning() << q->document()->url() << "is not really an animated image (only one frame)";
qCWarning(GWENVIEW_LIB_LOG) << q->document()->url() << "is not really an animated image (only one frame)";
}
}
}
......
......@@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include "loadingjob.h"
// Qt
#include <QDebug>
#include "gwenview_lib_debug.h"
#include <QUrl>
// KDE
......
......@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// Qt
#include <QSvgRenderer>
#include <QDebug>
#include "gwenview_lib_debug.h"
// KDE
......@@ -65,7 +65,7 @@ Document::LoadingState SvgDocumentLoadedImpl::loadingState() const
void SvgDocumentLoadedImpl::setImage(const QImage&)
{
qWarning() << "Should not be called";
qCWarning(GWENVIEW_LIB_LOG) << "Should not be called";
}
QByteArray SvgDocumentLoadedImpl::rawData() const
......
......@@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include "videodocumentloadedimpl.h"
// Qt
#include <QDebug>
#include "gwenview_lib_debug.h"
// KDE
......@@ -58,7 +58,7 @@ Document::LoadingState VideoDocumentLoadedImpl::loadingState() const
void VideoDocumentLoadedImpl::setImage(const QImage&)
{
qWarning() << "Should not be called";
qCWarning(GWENVIEW_LIB_LOG) << "Should not be called";
}
} // namespace
......@@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// KDE
// Qt
#include <QDebug>
#include "gwenview_lib_debug.h"
#include <QGuiApplication>
#include <QCursor>
#include <QGraphicsSceneMouseEvent>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment