Commit 7e6d8885 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fixed a crash in the text brush

Now the brushes are running in a separate thread, so no QPixmap's
are available for work.

Also removes excessive includes of <QPixmap> everywhere

Please review for backporting to 2.4

CCMAIL:kimageshop@kde.org
parent 2efe1275
......@@ -17,7 +17,6 @@
*/
#include "kis_paintop_registry.h"
#include <QPixmap>
#include <kglobal.h>
#include <klocale.h>
......
......@@ -32,7 +32,6 @@
#include <QImage>
#include <QMap>
#include <QPainter>
#include <QPixmap>
#include <QRect>
#include <QString>
#include <QVector>
......
......@@ -33,7 +33,6 @@
#include <QImage>
#include <QMap>
#include <QPainter>
#include <QPixmap>
#include <QRect>
#include <QString>
......
......@@ -32,7 +32,6 @@
#include <QImage>
#include <QMap>
#include <QPainter>
#include <QPixmap>
#include <QRect>
#include <QString>
......
......@@ -24,7 +24,6 @@
#include <QCheckBox>
#include <QSlider>
#include <QComboBox>
#include <QPixmap>
#include <QImage>
#include <QLabel>
#include <QColor>
......
......@@ -24,7 +24,6 @@
#include <QCheckBox>
#include <QSlider>
#include <QComboBox>
#include <QPixmap>
#include <QImage>
#include <QLabel>
......
......@@ -20,7 +20,6 @@
#include "kis_histogram_widget.h"
#include <QPainter>
#include <QPixmap>
#include <QLabel>
#include <QComboBox>
#include <QPushButton>
......
......@@ -28,7 +28,6 @@
// Qt includes.
#include <QPixmap>
#include <QPainter>
#include <QPoint>
#include <QPen>
......@@ -60,7 +59,6 @@ void KGradientSlider::paintEvent(QPaintEvent *)
const int gradientHeight = (int)round((double)wHeight / 7.0 * 2);
// A QPixmap is used for enable the double buffering.
QPainter p1(this);
// Draw first gradient
......
......@@ -23,7 +23,6 @@
#include <QDomElement>
#include <QFontMetrics>
#include <QPainter>
#include <QPixmap>
#include "kis_gbr_brush.h"
KisTextBrush::KisTextBrush()
......@@ -114,22 +113,23 @@ void KisTextBrush::updateBrush()
QImage KisTextBrush::renderChar(const QString& text)
{
QFontMetrics metric(m_font);
int w = metric.width(text);
int h = metric.height();
QRect rect = metric.boundingRect(text);
// don't crash, if there is no text
if (w==0) w=1;
if (h==0) h=1;
if (rect.isEmpty()) {
rect = QRect(0, 0, 1, 1); // paint at least something
}
QRect paintingRect = rect.translated(-rect.x(), -rect.y());
QPixmap px(w, h);
QImage renderedChar(paintingRect.size(), QImage::Format_ARGB32);
QPainter p;
p.begin(&px);
p.begin(&renderedChar);
p.setFont(m_font);
p.fillRect(0, 0, w, h, Qt::white);
p.fillRect(paintingRect, Qt::white);
p.setPen(Qt::black);
p.drawText(0, metric.ascent(), text);
p.drawText(-rect.x(), -rect.y(), text);
p.end();
return px.toImage();
return renderedChar;
}
......
......@@ -30,7 +30,6 @@
#include <QString>
#include <QTime>
#include <QTimer>
#include <QPixmap>
#include <QApplication>
#include <QMenu>
......
......@@ -29,7 +29,6 @@
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QPixmap>
#include <QPushButton>
#include <QSlider>
#include <QToolButton>
......
......@@ -19,7 +19,6 @@
#include "kis_bookmarked_filter_configurations_model.h"
#include <QFutureWatcher>
#include <QPixmap>
#include <QSignalMapper>
#include <QtConcurrentRun>
......
......@@ -24,7 +24,6 @@
#include "kis_color_data_list.h"
#include <QQueue>
#include <QList>
#include <QPixmap>
#include "KoResourceServerObserver.h"
class QString;
......
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