Commit 894046b4 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Merge branch 'rempt/logging-docker'

parents 02ffcef0 f6fbdd5c
......@@ -47,7 +47,7 @@ void removeTempFiles(const QString &filesMask)
void runRenderingTest(KisImageSP image, int numCores, int numClones)
{
{
KisImageConfig cfg;
KisImageConfig cfg(false);
cfg.setMaxNumberOfThreads(numCores);
cfg.setFrameRenderingClones(numClones);
}
......
......@@ -89,7 +89,7 @@ void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName,
/**
* Reset configuration to the desired settings
*/
KisImageConfig config;
KisImageConfig config(false);
qreal oldHardLimit = config.memoryHardLimitPercent();
qreal oldSoftLimit = config.memorySoftLimitPercent();
qreal oldPoolLimit = config.memoryPoolLimitPercent();
......
......@@ -38,7 +38,6 @@
#include <time.h>
#include <KisApplication.h>
#include <KisLoggingManager.h>
#include <KoConfig.h>
#include <KoResourcePaths.h>
#include <kis_config.h>
......@@ -133,8 +132,6 @@ extern "C" int main(int argc, char **argv)
qputenv("QT_QPA_PLATFORM", "xcb");
#endif
KisLoggingManager::initialize();
// A per-user unique string, without /, because QLocalServer cannot use names with a / in it
QString key = "Krita3" + QStandardPaths::writableLocation(QStandardPaths::HomeLocation).replace("/", "_");
key = key.replace(":", "_").replace("\\","_");
......@@ -357,7 +354,7 @@ extern "C" int main(int argc, char **argv)
}
#if defined Q_OS_WIN
KisConfig cfg;
KisConfig cfg(false);
bool supportedWindowsVersion = true;
#if QT_VERSION >= 0x050900
QOperatingSystemVersion osVersion = QOperatingSystemVersion::current();
......
......@@ -25,6 +25,7 @@ class KoCanvasObserverBasePrivate;
#include "kritaflake_export.h"
#include <QString>
#include <QMainWindow>
/**
* An abstract canvas observer interface class.
......@@ -56,6 +57,7 @@ public:
* @return observed canvas, can be 0
*/
KoCanvasBase* observedCanvas() const;
protected:
/**
* re-implement this method in your canvas observer. It will be called
......
......@@ -36,11 +36,21 @@
#include <QImage>
#include <qmath.h>
#include "FlakeDebug.h"
class KoOdfGradientBackgroundPrivate : public KoShapeBackgroundPrivate
{
public:
KoOdfGradientBackgroundPrivate()
: style(), cx(0), cy(0), startColor(), endColor(), angle(0), border(0), opacity(1.0) {};
: style()
, cx(0)
, cy(0)
, startColor()
, endColor()
, angle(0)
, border(0)
, opacity(1.0)
{}
~KoOdfGradientBackgroundPrivate() override{};
//data
QString style;
......@@ -368,9 +378,9 @@ void KoOdfGradientBackground::renderRectangleGradient(QImage& buffer) const
void KoOdfGradientBackground::debug() const
{
Q_D(const KoOdfGradientBackground);
qDebug() << "cx,cy: "<< d->cx << d->cy;
qDebug() << "style" << d->style;
qDebug() << "colors" << d->startColor << d->endColor;
qDebug() << "angle:" << d->angle;
qDebug() << "border" << d->border;
debugFlake << "cx,cy: "<< d->cx << d->cy;
debugFlake << "style" << d->style;
debugFlake << "colors" << d->startColor << d->endColor;
debugFlake << "angle:" << d->angle;
debugFlake << "border" << d->border;
}
This diff is collapsed.
......@@ -96,7 +96,7 @@ KoToolBase::~KoToolBase()
// }
// else {
// qDebug() << "Tool" << toolId() << "has no actions";
// debugFlake << "Tool" << toolId() << "has no actions";
// }
qDeleteAll(d_ptr->optionWidgets);
delete d_ptr;
......
......@@ -41,6 +41,7 @@
#include <KoShapePaintingContext.h>
#include <SvgParser.h>
#include <FlakeDebug.h>
void paintGroup(KoShapeGroup *group, QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &paintContext)
{
......@@ -76,7 +77,7 @@ QImage KoSvgSymbol::icon()
KoViewConverter vc;
KoShapePaintingContext ctx;
// qDebug() << "Going to render. Original bounding rect:" << group->boundingRect()
// debugFlake << "Going to render. Original bounding rect:" << group->boundingRect()
// << "Normalized: " << rc
// << "Scale W" << 256 / rc.width() << "Scale H" << 256 / rc.height();
......@@ -163,7 +164,7 @@ bool KoSvgSymbolCollectionResource::loadFromDevice(QIODevice *dev)
// We're not interested in the shapes themselves
qDeleteAll(parser.parseSvg(doc.documentElement(), &fragmentSize));
d->symbols = parser.takeSymbols();
// qDebug() << "Loaded" << filename() << "\n\t"
// debugFlake << "Loaded" << filename() << "\n\t"
// << "Title" << parser.documentTitle() << "\n\t"
// << "Description" << parser.documentDescription()
// << "\n\tgot" << d->symbols.size() << "symbols"
......
......@@ -247,11 +247,11 @@ void SvgLoadingContext::parseProfile(const KoXmlElement &element)
if (element.attribute("rendering-intent", "auto") != "auto") {
// WARNING: Krita does *not* treat rendering intents attributes of the profile!
qDebug() << "WARNING: we do *not* treat rendering intents attributes of the profile!";
debugFlake << "WARNING: we do *not* treat rendering intents attributes of the profile!";
}
if (d->profiles.contains(name)) {
qDebug() << "Profile already in the map!" << ppVar(name);
debugFlake << "Profile already in the map!" << ppVar(name);
return;
}
......@@ -268,12 +268,12 @@ void SvgLoadingContext::parseProfile(const KoXmlElement &element)
profile = engine->addProfile(profileData);
if (profile->uniqueId() != uniqueId) {
qDebug() << "WARNING: ProfileID of the attached profile doesn't match the one mentioned in SVG element";
qDebug() << " " << ppVar(profile->uniqueId().toHex());
qDebug() << " " << ppVar(uniqueId.toHex());
debugFlake << "WARNING: ProfileID of the attached profile doesn't match the one mentioned in SVG element";
debugFlake << " " << ppVar(profile->uniqueId().toHex());
debugFlake << " " << ppVar(uniqueId.toHex());
}
} else {
qDebug() << "WARNING: couldn't fetch the ICCprofile file!" << fileName;
debugFlake << "WARNING: couldn't fetch the ICCprofile file!" << fileName;
}
}
}
......@@ -281,7 +281,7 @@ void SvgLoadingContext::parseProfile(const KoXmlElement &element)
if (profile) {
d->profiles.insert(name, profile);
} else {
qDebug() << "WARNING: couldn't load SVG profile" << ppVar(name) << ppVar(href) << ppVar(uniqueId);
debugFlake << "WARNING: couldn't load SVG profile" << ppVar(name) << ppVar(href) << ppVar(uniqueId);
}
}
......
......@@ -103,14 +103,14 @@ struct SvgParser::DeferredUseStore {
if (id.isEmpty())
return;
// qDebug() << "Checking id: " << id;
// debugFlake << "Checking id: " << id;
auto i = std::partition(m_uses.begin(), m_uses.end(),
[&](const El& e) -> bool {return e.m_key != id;});
while (i != m_uses.end()) {
const El& el = m_uses.back();
if (m_parse->m_context.hasDefinition(el.m_key)) {
// qDebug() << "Found pending use for id: " << el.m_key;
// debugFlake << "Found pending use for id: " << el.m_key;
shape = m_parse->resolveUse(*(el.m_useElement), el.m_key);
if (shape) {
shapes.append(shape);
......@@ -377,7 +377,7 @@ SvgGradientHelper* SvgParser::parseGradient(const KoXmlElement &e)
}
gradHelper.setGradient(g);
} else {
qDebug() << "WARNING: Failed to parse gradient with tag" << e.tagName();
debugFlake << "WARNING: Failed to parse gradient with tag" << e.tagName();
}
// handle spread method
......@@ -1262,7 +1262,7 @@ KoShape* SvgParser::parseUse(const KoXmlElement &e, DeferredUseStore* deferredUs
deferredUseStore->add(&e, key);
return 0;
}
qDebug() << "WARNING: Did not find reference for svg 'use' element. Skipping. Id: "
debugFlake << "WARNING: Did not find reference for svg 'use' element. Skipping. Id: "
<< key;
return 0;
}
......
......@@ -41,6 +41,7 @@
#include <html/HtmlSavingContext.h>
#include <FlakeDebug.h>
namespace {
......@@ -463,7 +464,7 @@ bool KoSvgTextChunkShape::saveHtml(HtmlSavingContext &context)
context.shapeWriter().addAttribute("style", styleString);
}
if (layoutInterface()->isTextNode()) {
qDebug() << "saveHTML" << this << d->text << xPos << yPos << dxPos << dyPos;
debugFlake << "saveHTML" << this << d->text << xPos << yPos << dxPos << dyPos;
// After adding all the styling to the <p> element, add the text
context.shapeWriter().addTextNode(d->text);
}
......
......@@ -52,6 +52,7 @@
#include <text/KoSvgTextChunkShapeLayoutInterface.h>
#include <FlakeDebug.h>
struct KoSvgTextShapePrivate : public KoSvgTextChunkShapePrivate
{
......@@ -580,7 +581,7 @@ KoSvgTextShapeFactory::KoSvgTextShapeFactory()
KoShape *KoSvgTextShapeFactory::createDefaultShape(KoDocumentResourceManager *documentResources) const
{
qDebug() << "Create default svg text shape";
debugFlake << "Create default svg text shape";
KoSvgTextShape *shape = new KoSvgTextShape();
shape->setShapeId(KoSvgTextShape_SHAPEID);
......@@ -591,7 +592,7 @@ KoShape *KoSvgTextShapeFactory::createDefaultShape(KoDocumentResourceManager *do
QRectF(0, 0, 200, 60),
documentResources->shapeController()->pixelsPerInch());
qDebug() << converter.errors() << converter.warnings();
debugFlake << converter.errors() << converter.warnings();
return shape;
}
......
......@@ -50,6 +50,7 @@
#include "kis_dom_utils.h"
#include <boost/optional.hpp>
#include <FlakeDebug.h>
struct KoSvgTextShapeMarkupConverter::Private {
Private(KoSvgTextShape *_shape) : shape(_shape) {}
......@@ -104,7 +105,7 @@ bool KoSvgTextShapeMarkupConverter::convertFromSvg(const QString &svgText, const
const QRectF &boundsInPixels, qreal pixelsPerInch)
{
qDebug() << "convertFromSvg. text:" << svgText << "styles:" << stylesText << "bounds:" << boundsInPixels << "ppi:" << pixelsPerInch;
debugFlake << "convertFromSvg. text:" << svgText << "styles:" << stylesText << "bounds:" << boundsInPixels << "ppi:" << pixelsPerInch;
d->clearErrors();
......@@ -182,7 +183,7 @@ bool KoSvgTextShapeMarkupConverter::convertToHtml(QString *htmlText)
*htmlText = QString(shapesBuffer.data());
qDebug() << "\t\t" << *htmlText;
debugFlake << "\t\t" << *htmlText;
return true;
}
......@@ -190,7 +191,7 @@ bool KoSvgTextShapeMarkupConverter::convertToHtml(QString *htmlText)
bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QString *svgText, QString *styles)
{
qDebug() << ">>>>>>>>>>>" << htmlText;
debugFlake << ">>>>>>>>>>>" << htmlText;
QBuffer svgBuffer;
svgBuffer.open(QIODevice::WriteOnly);
......@@ -218,7 +219,7 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QSt
{
newLine = false;
if (htmlReader.name() == "br") {
qDebug() << "\tdoing br";
debugFlake << "\tdoing br";
svgWriter.writeEndElement();
elementName = QStringRef(&p);
em = bodyEm;
......@@ -230,13 +231,13 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QSt
}
if (elementName == "body") {
qDebug() << "\tstart Element" << elementName;
debugFlake << "\tstart Element" << elementName;
svgWriter.writeStartElement("text");
appendStyle = QString();
}
else if (elementName == "p") {
// new line
qDebug() << "\t\tstart Element" << elementName;
debugFlake << "\t\tstart Element" << elementName;
svgWriter.writeStartElement("tspan");
newLine = true;
if (em.isEmpty()) {
......@@ -246,22 +247,22 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QSt
lineCount++;
}
else if (elementName == "span") {
qDebug() << "\tstart Element" << elementName;
debugFlake << "\tstart Element" << elementName;
svgWriter.writeStartElement("tspan");
appendStyle = QString();
}
else if (elementName == "b" || elementName == "strong") {
qDebug() << "\tstart Element" << elementName;
debugFlake << "\tstart Element" << elementName;
svgWriter.writeStartElement("tspan");
appendStyle = "font-weight:700;";
}
else if (elementName == "i" || elementName == "em") {
qDebug() << "\tstart Element" << elementName;
debugFlake << "\tstart Element" << elementName;
svgWriter.writeStartElement("tspan");
appendStyle = "font-style:italic;";
}
else if (elementName == "u") {
qDebug() << "\tstart Element" << elementName;
debugFlake << "\tstart Element" << elementName;
svgWriter.writeStartElement("tspan");
appendStyle = "text-decoration:underline";
}
......@@ -279,7 +280,7 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QSt
QStringList styles = attributes.value("style").toString().split(";");
for(int i=0; i<styles.size(); i++) {
QStringList style = QString(styles.at(i)).split(":");
qDebug()<<style.at(0);
debugFlake<<style.at(0);
if (svgStyles.contains(QString(style.at(0)).trimmed())) {
filteredStyles.append(styles.at(i)+";");
}
......@@ -325,7 +326,7 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QSt
}
if (newLine && lineCount > 1) {
qDebug() << "\t\tAdvancing to the next line";
debugFlake << "\t\tAdvancing to the next line";
svgWriter.writeAttribute("x", "0");
svgWriter.writeAttribute("dy", em);
}
......@@ -335,7 +336,7 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QSt
{
if (htmlReader.name() == "br") break;
if (elementName == "p" || elementName == "span" || elementName == "body") {
qDebug() << "\tEndElement" << htmlReader.name() << "(" << elementName << ")";
debugFlake << "\tEndElement" << htmlReader.name() << "(" << elementName << ")";
svgWriter.writeEndElement();
}
break;
......@@ -347,7 +348,7 @@ bool KoSvgTextShapeMarkupConverter::convertFromHtml(const QString &htmlText, QSt
}
else {
if (!htmlReader.isWhitespace()) {
qDebug() << "\tCharacters:" << htmlReader.text();
debugFlake << "\tCharacters:" << htmlReader.text();
svgWriter.writeCharacters(htmlReader.text().toString());
}
}
......
......@@ -678,12 +678,12 @@ void KoPathTool::mouseMoveEvent(KoPointerEvent *event)
delete m_activeHandle;
if (KoConnectionShape * connectionShape = dynamic_cast<KoConnectionShape*>(parameterShape)) {
//qDebug() << "handleId" << handleId;
//debugFlake << "handleId" << handleId;
m_activeHandle = new ConnectionHandle(this, connectionShape, handleId);
m_activeHandle->repaint();
return;
} else {
//qDebug() << "handleId" << handleId;
//debugFlake << "handleId" << handleId;
m_activeHandle = new ParameterHandle(this, parameterShape, handleId);
m_activeHandle->repaint();
return;
......
......@@ -28,7 +28,6 @@ set(kritaglobal_LIB_SRCS
KisSharedThreadPoolAdapter.cpp
KisSharedRunnable.cpp
KisRollingMeanAccumulatorWrapper.cpp
KisLoggingManager.cpp
kis_config_notifier.cpp
)
......
/*
* Copyright (c) 2017 Alvin Wong <alvinhochun@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "KisLoggingManager.h"
#include <QSet>
#include <QLoggingCategory>
using ScopedLogCapturer = KisLoggingManager::ScopedLogCapturer;
namespace
{
QtMessageHandler oldMessageHandler;
QLoggingCategory::CategoryFilter oldCategoryFilter;
QSet<const ScopedLogCapturer *> capturerSet;
} // namespace
class KisLoggingManager::Private
{
friend class KisLoggingManager;
static void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
Q_FOREACH (const ScopedLogCapturer *const &capturer, capturerSet) {
if (capturer->m_category == context.category) {
capturer->m_callback(type, context, msg);
}
}
// TODO: Hide capture-only messages from default output
oldMessageHandler(type, context, msg);
}
static void myCategoryFilter(QLoggingCategory *category)
{
oldCategoryFilter(category);
// Enable categories to be captured
// TODO: Keep track of default filter stage to hide message from output
Q_FOREACH (const ScopedLogCapturer *const &capturer, capturerSet) {
if (capturer->m_category == category->categoryName()) {
category->setEnabled(QtDebugMsg, true);
category->setEnabled(QtInfoMsg, true);
category->setEnabled(QtWarningMsg, true);
category->setEnabled(QtCriticalMsg, true);
}
}
}
static void refreshCategoryFilter()
{
QLoggingCategory::installFilter(myCategoryFilter);
}
}; // class KisLoggingManager::Private
void KisLoggingManager::initialize()
{
// Install our QtMessageHandler for capturing logging messages
oldMessageHandler = qInstallMessageHandler(KisLoggingManager::Private::myMessageHandler);
// HACK: Gets the default CategoryFilter because the filter function may
// be called synchronously.
oldCategoryFilter = QLoggingCategory::installFilter(nullptr);
// Install our CategoryFilter for filtering
KisLoggingManager::Private::refreshCategoryFilter();
}
ScopedLogCapturer::ScopedLogCapturer(QByteArray category, ScopedLogCapturer::callback_t callback)
: m_category(category)
, m_callback(callback)
{
capturerSet.insert(this);
KisLoggingManager::Private::refreshCategoryFilter();
}
ScopedLogCapturer::~ScopedLogCapturer()
{
capturerSet.remove(this);
KisLoggingManager::Private::refreshCategoryFilter();
}
/*
* Copyright (c) 2017 Alvin Wong <alvinhochun@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KISLOGGINGMANAGER_H
#define KISLOGGINGMANAGER_H
#include "kritaglobal_export.h"
#include <QtGlobal>
#include <QByteArray>
#include <functional>
#include <type_traits>
/**
* This static class is used to control the Qt logging infrastructure to suit
* our needs.
*
* This class assumes no other code calls qInstallMessageHandler and
* QLoggingCategory::installFilter.
*
* This class might or might not be thread-safe, please only use this class
* on the main GUI thread. There is no checking or synchronization in place.
*/
class KRITAGLOBAL_EXPORT KisLoggingManager
{
public:
/**
* Initialize KisLoggingManager globally..
* This function should be called as early as possible in main().
*/
static void initialize();
class ScopedLogCapturer;
private:
KisLoggingManager() = delete;
class Private;
}; // class KisLoggingManager
/**
* This class is used to capture logging output within a certain scope.
*
* This class might or might not be thread-safe, please only use this class
* on the main GUI thread. There is no checking or synchronization in place.
*/
class KRITAGLOBAL_EXPORT KisLoggingManager::ScopedLogCapturer
{
friend class KisLoggingManager;
using callback_t = std::function<std::remove_pointer<QtMessageHandler>::type>;
public:
ScopedLogCapturer(QByteArray category, callback_t callback);
~ScopedLogCapturer();
private:
QByteArray m_category;
callback_t m_callback;
ScopedLogCapturer(const ScopedLogCapturer &) = delete;
ScopedLogCapturer &operator=(const ScopedLogCapturer &) = delete;
}; // class KisLoggingManager::ScopedLogCapturer
#endif // KISLOGGINGMANAGER_H
......@@ -382,7 +382,7 @@ QVector<QPointF> intersectTwoCircles(const QPointF &center1, qreal r1,
if (centerDistance < qAbs(r1 - r2)) return points;
if (centerDistance < qAbs(r1 - r2) + 0.001) {
qDebug() << "Skipping intersection" << ppVar(center1) << ppVar(center2) << ppVar(r1) << ppVar(r2) << ppVar(centerDistance) << ppVar(qAbs(r1-r2));
dbgKrita << "Skipping intersection" << ppVar(center1) << ppVar(center2) << ppVar(r1) << ppVar(r2) << ppVar(centerDistance) << ppVar(qAbs(r1-r2));
return points;
}
......
......@@ -34,7 +34,6 @@ KisMemoryLeakTracker* KisMemoryLeakTracker::instance()
{
return s_instance;
}
#ifdef HAVE_MEMORY_LEAK_TRACKER
#include <QHash>
......@@ -114,7 +113,7 @@ KisMemoryLeakTracker::KisMemoryLeakTracker() : d(new Private)
KisMemoryLeakTracker::~KisMemoryLeakTracker()
{
if (d->whatWhoWhen.isEmpty()) {
qDebug() << "No leak detected.";
qInfo() << "No leak detected.";
} else {
qWarning() << "****************************************";
qWarning() << (d->whatWhoWhen.size()) << " leaks have been detected";
......@@ -179,21 +178,21 @@ void KisMemoryLeakTracker::dumpReferences(const void* what)
}
WhatInfo& info = d->whatWhoWhen[what];
qDebug() << "Object " << what << "(" << info.name << ") is still referenced by " << info.infos.size() << " objects:";
qInfo() << "Object " << what << "(" << info.name << ") is still referenced by " << info.infos.size() << " objects:";
for (QHash<const void*, BacktraceInfo*>::iterator it2 = info.infos.begin();
it2 != info.infos.end(); ++it2) {
qDebug() << "Referenced by " << it2.key() << " at:";
qInfo() << "Referenced by " << it2.key() << " at:";
#ifdef HAVE_BACKTRACE_SUPPORT
BacktraceInfo* info = it2.value();
char** strings = backtrace_symbols(info->trace, info->size);
for (int i = 0; i < info->size; ++i) {
qDebug() << strings[i];
qInfo() << strings[i];
}
#else
qDebug() << "Enable backtrace support in kis_memory_leak_tracker.cpp";
qInfo() << "Enable backtrace support in kis_memory_leak_tracker.cpp";
#endif