[calligra/calligra/2.4] krita: Fixed a crash in the text brush

Dmitry Kazakov dimula73 at gmail.com
Sat Mar 10 16:17:39 UTC 2012


Git commit 7b680bed37e407aeed696c554892cd393700ba03 by Dmitry Kazakov.
Committed on 10/03/2012 at 09:40.
Pushed by dkazakov into branch 'calligra/2.4'.

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 at kde.org

M  +0    -1    krita/image/brushengine/kis_paintop_registry.cc
M  +0    -1    krita/image/kis_convolution_painter.cc
M  +0    -1    krita/image/kis_fill_painter.cc
M  +0    -1    krita/image/kis_gradient_painter.cc
M  +0    -1    krita/plugins/extensions/colorrange/dlg_colorrange.cc
M  +0    -1    krita/plugins/extensions/histogram/dlg_histogram.cc
M  +0    -1    krita/plugins/extensions/histogram/kis_histogram_widget.cc
M  +0    -2    krita/plugins/filters/levelfilter/kgradientslider.cpp
M  +11   -11   krita/plugins/paintops/libbrush/kis_text_brush.cpp
M  +0    -1    krita/ui/canvas/kis_qpainter_canvas.cpp
M  +0    -1    krita/ui/dialogs/kis_dlg_preferences.cc
M  +0    -1    krita/ui/kis_bookmarked_filter_configurations_model.cc
M  +0    -1    krita/ui/ko_favorite_resource_manager.h

http://commits.kde.org/calligra/7b680bed37e407aeed696c554892cd393700ba03

diff --git a/krita/image/brushengine/kis_paintop_registry.cc b/krita/image/brushengine/kis_paintop_registry.cc
index ffe695e..fc88b08 100644
--- a/krita/image/brushengine/kis_paintop_registry.cc
+++ b/krita/image/brushengine/kis_paintop_registry.cc
@@ -17,7 +17,6 @@
  */
 
 #include "kis_paintop_registry.h"
-#include <QPixmap>
 
 #include <kglobal.h>
 #include <klocale.h>
diff --git a/krita/image/kis_convolution_painter.cc b/krita/image/kis_convolution_painter.cc
index ec8320f..318d188 100644
--- a/krita/image/kis_convolution_painter.cc
+++ b/krita/image/kis_convolution_painter.cc
@@ -32,7 +32,6 @@
 #include <QImage>
 #include <QMap>
 #include <QPainter>
-#include <QPixmap>
 #include <QRect>
 #include <QString>
 #include <QVector>
diff --git a/krita/image/kis_fill_painter.cc b/krita/image/kis_fill_painter.cc
index 54734c9..f241585 100644
--- a/krita/image/kis_fill_painter.cc
+++ b/krita/image/kis_fill_painter.cc
@@ -33,7 +33,6 @@
 #include <QImage>
 #include <QMap>
 #include <QPainter>
-#include <QPixmap>
 #include <QRect>
 #include <QString>
 
diff --git a/krita/image/kis_gradient_painter.cc b/krita/image/kis_gradient_painter.cc
index f3af3ef..b110998 100644
--- a/krita/image/kis_gradient_painter.cc
+++ b/krita/image/kis_gradient_painter.cc
@@ -32,7 +32,6 @@
 #include <QImage>
 #include <QMap>
 #include <QPainter>
-#include <QPixmap>
 #include <QRect>
 #include <QString>
 
diff --git a/krita/plugins/extensions/colorrange/dlg_colorrange.cc b/krita/plugins/extensions/colorrange/dlg_colorrange.cc
index 59cd9cf..3ab6832 100644
--- a/krita/plugins/extensions/colorrange/dlg_colorrange.cc
+++ b/krita/plugins/extensions/colorrange/dlg_colorrange.cc
@@ -24,7 +24,6 @@
 #include <QCheckBox>
 #include <QSlider>
 #include <QComboBox>
-#include <QPixmap>
 #include <QImage>
 #include <QLabel>
 #include <QColor>
diff --git a/krita/plugins/extensions/histogram/dlg_histogram.cc b/krita/plugins/extensions/histogram/dlg_histogram.cc
index 7d06166..388c807 100644
--- a/krita/plugins/extensions/histogram/dlg_histogram.cc
+++ b/krita/plugins/extensions/histogram/dlg_histogram.cc
@@ -24,7 +24,6 @@
 #include <QCheckBox>
 #include <QSlider>
 #include <QComboBox>
-#include <QPixmap>
 #include <QImage>
 #include <QLabel>
 
diff --git a/krita/plugins/extensions/histogram/kis_histogram_widget.cc b/krita/plugins/extensions/histogram/kis_histogram_widget.cc
index 764fdca..58dad2a 100644
--- a/krita/plugins/extensions/histogram/kis_histogram_widget.cc
+++ b/krita/plugins/extensions/histogram/kis_histogram_widget.cc
@@ -20,7 +20,6 @@
 #include "kis_histogram_widget.h"
 
 #include <QPainter>
-#include <QPixmap>
 #include <QLabel>
 #include <QComboBox>
 #include <QPushButton>
diff --git a/krita/plugins/filters/levelfilter/kgradientslider.cpp b/krita/plugins/filters/levelfilter/kgradientslider.cpp
index 955199c..d0290bc 100644
--- a/krita/plugins/filters/levelfilter/kgradientslider.cpp
+++ b/krita/plugins/filters/levelfilter/kgradientslider.cpp
@@ -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
diff --git a/krita/plugins/paintops/libbrush/kis_text_brush.cpp b/krita/plugins/paintops/libbrush/kis_text_brush.cpp
index 9725fd0..36bcd38 100644
--- a/krita/plugins/paintops/libbrush/kis_text_brush.cpp
+++ b/krita/plugins/paintops/libbrush/kis_text_brush.cpp
@@ -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;
 }
 
 
diff --git a/krita/ui/canvas/kis_qpainter_canvas.cpp b/krita/ui/canvas/kis_qpainter_canvas.cpp
index a318a33..ab1073a 100644
--- a/krita/ui/canvas/kis_qpainter_canvas.cpp
+++ b/krita/ui/canvas/kis_qpainter_canvas.cpp
@@ -30,7 +30,6 @@
 #include <QString>
 #include <QTime>
 #include <QTimer>
-#include <QPixmap>
 #include <QApplication>
 #include <QMenu>
 
diff --git a/krita/ui/dialogs/kis_dlg_preferences.cc b/krita/ui/dialogs/kis_dlg_preferences.cc
index 46ff8f0..ea4c9c1 100644
--- a/krita/ui/dialogs/kis_dlg_preferences.cc
+++ b/krita/ui/dialogs/kis_dlg_preferences.cc
@@ -29,7 +29,6 @@
 #include <QLabel>
 #include <QLayout>
 #include <QLineEdit>
-#include <QPixmap>
 #include <QPushButton>
 #include <QSlider>
 #include <QToolButton>
diff --git a/krita/ui/kis_bookmarked_filter_configurations_model.cc b/krita/ui/kis_bookmarked_filter_configurations_model.cc
index c74f7f0..777627b 100644
--- a/krita/ui/kis_bookmarked_filter_configurations_model.cc
+++ b/krita/ui/kis_bookmarked_filter_configurations_model.cc
@@ -19,7 +19,6 @@
 #include "kis_bookmarked_filter_configurations_model.h"
 
 #include <QFutureWatcher>
-#include <QPixmap>
 #include <QSignalMapper>
 #include <QtConcurrentRun>
 
diff --git a/krita/ui/ko_favorite_resource_manager.h b/krita/ui/ko_favorite_resource_manager.h
index d3605b8..4db70be 100644
--- a/krita/ui/ko_favorite_resource_manager.h
+++ b/krita/ui/ko_favorite_resource_manager.h
@@ -24,7 +24,6 @@
 #include "kis_color_data_list.h"
 #include <QQueue>
 #include <QList>
-#include <QPixmap>
 #include "KoResourceServerObserver.h"
 
 class QString;


More information about the kimageshop mailing list