Bug#763037: xdrawchem crashes with segfault when leaving the text tool (jessie 64 bit)

2014-10-05 Thread Georges Khaznadar
Martin Steghöfer a écrit :
 tag 763037 patch
 thanks

Thank you very much, I shall refresh the package.

Best regards,   Georges.



signature.asc
Description: Digital signature


Bug#763037: xdrawchem crashes with segfault when leaving the text tool (jessie 64 bit)

2014-10-03 Thread Martin Steghöfer

tag 763037 patch
thanks



Hi there!

I've fixed it myself. :-) Please find the patch in the attachment.

The cause of the segmentation fault was that the Render2D functions 
GetTextHeight, GetTextFullHeight, GetCharWidth, GetStringWidth and 
GetTextDimensions created their own local QPainter object on the shared 
QPaintDevice, which invalidated the shared and permanent QPainter that 
other functions of the same class use on the same QPaintDevice. Now all 
functions use the same QPainter object.


Cheers,
Martin

Description: Fix crash (segfault) after using text tool
 This patch fixes a segmentation fault that occurs whenever
 anything is rendered after one of the functions GetTextHeight,
 GetTextFullHeight, GetCharWidth, GetStringWidth or
 GetTextDimensions is called. They destroy the state of the
 shared QPainter by using a separate one on the same context.
Author: Martin Steghöfer mar...@steghoefer.eu
Bug-Debian: http://bugs.debian.org/763037

--- a/xdrawchem/render2d_text.cpp
+++ b/xdrawchem/render2d_text.cpp
@@ -554,40 +554,32 @@
 
 int Render2D::GetTextHeight( QFont fn )
 {
-QPainter p( this );
-
-p.setFont( fn );
-QFontMetrics fm = p.fontMetrics();
+painter-setFont( fn );
+QFontMetrics fm = painter-fontMetrics();
 
 return fm.ascent();
 }
 
 int Render2D::GetTextFullHeight( QFont fn )
 {
-QPainter p( this );
-
-p.setFont( fn );
-QFontMetrics fm = p.fontMetrics();
+painter-setFont( fn );
+QFontMetrics fm = painter-fontMetrics();
 
 return fm.height();
 }
 
 int Render2D::GetCharWidth( QChar ch, QFont fn )
 {
-QPainter p( this );
-
-p.setFont( fn );
-QFontMetrics fm = p.fontMetrics();
+painter-setFont( fn );
+QFontMetrics fm = painter-fontMetrics();
 
 return fm.width( ch );
 }
 
 int Render2D::GetStringWidth( QString ch, QFont fn )
 {
-QPainter p( this );
-
-p.setFont( fn );
-QFontMetrics fm = p.fontMetrics();
+painter-setFont( fn );
+QFontMetrics fm = painter-fontMetrics();
 
 return fm.width( ch );
 }
@@ -601,11 +593,9 @@
 
 }
 
-QPainter p( this );
-
-p.setFont( fn );
+painter-setFont( fn );
 int maxwidth, lwidth, linecount, height;
-QFontMetrics fm = p.fontMetrics();
+QFontMetrics fm = painter-fontMetrics();
 QTextStream t( txt, QIODevice::ReadOnly );
 
 linecount = 1;


Bug#763037: xdrawchem crashes with segfault when leaving the text tool (jessie 64 bit)

2014-09-27 Thread Martin Steghöfer

Package: xdrawchem
Version: 2.0-2
Severity: normal


Hi there! :-)


The xdrawchem executable crashed with a segmentation fault every time 
you leave the tool to insert text (no matter if you've entered text or 
not). Steps to reproduce:

 * Startup xdrawchem
 * Close the welcome dialog (if it appears) by clicking OK
 * Switch to the text tool by clicking on the T icon (description 
Draw or edit text) in the toolbar

 * Click on an empty place in the document to start inserting text
 * Switch back to the selection tool by clicking on the cursor icon 
(description: Select) in the toolbar

- Crash with segmentation fault


The last output of the program on the console before the crash is:

 addText
 0
 screen
 paintEvent painter begin
 drawAll:  Drawable(0x14493d30)
 Text::Render begin
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0//EN
 http://www.w3.org/TR/REC-html40/strict.dtd;
 htmlheadmeta name=qrichtext content=1 /
 style type=text/css
 p, li { white-space: pre-wrap; }
 /style/headbody style= font-family:'Helvetica';
 font-size:10pt; font-weight:400; font-style:normal;
 p style=-qt-paragraph-type:empty; margin-top:0px;
 margin-bottom:0px; margin-left:0px; margin-right:0px;
 -qt-block-indent:0; text-indent:0px;
 br //p/body/html
 Text dimensions =  787 , 21


I installed the Qt debug symbols package and compiled xdrawchem from 
source with DEB_BUILD_OPTIONS=nostrip in order to get a reasonable 
backtrace. Here it goes:


==12730== Invalid read of size 4
==12730==at 0x5852360: QRasterPaintEngine::penChanged()
 (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==12730==by 0x57D604D: QPainter::setPen(QColor const)
 (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==12730==by 0x5193FA: Render2D::drawFillBox(QPoint, QPoint,
 QColor, bool, QColor, int) (render2d_draw.cpp:642)
==12730==by 0x53C6E4: Text::Render() (text.cpp:554)
==12730==by 0x49AEB7: ChemData::drawAll() (chemdata.cpp:24)
==12730==by 0x529182: Render2D::paintEvent(QPaintEvent*)
 (render2d_event.cpp:1909)
==12730==by 0x56DF3B7: QWidget::event(QEvent*)
 (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==12730==by 0x568C31B: QApplicationPrivate::notify_helper
 (QObject*, QEvent*)
 (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==12730==by 0x5692E17: QApplication::notify(QObject*, QEvent*)
 (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==12730==by 0x6687CAC: QCoreApplication::notifyInternal
 (QObject*, QEvent*)
 (in /usr/lib/x86_64-linux-gnu/libQtCore.so.4.8.6)
==12730==by 0x56D9A6C: QWidgetPrivate::drawWidget
 (QPaintDevice*, QRegion const, QPoint const, int,
 QPainter*, QWidgetBackingStore*)
 (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==12730==by 0x56DA534: QWidgetPrivate::paintSiblingsRecursive
 (QPaintDevice*, QListQObject* const, int, QRegion const,
 QPoint const, int, QPainter*, QWidgetBackingStore*)
 (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.6)
==12730==  Address 0x2b8 is not stack'd, malloc'd or (recently) free'd


Further system information:

-- System Information:
Debian Release: jessie/sid
  APT prefers testing-updates
  APT policy: (500, 'testing-updates'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.14-2-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: 
LC_ALL set to en_US.UTF-8)

Shell: /bin/sh linked to /bin/dash

Versions of packages xdrawchem depends on:
ii  libc6   2.19-11
ii  libgcc1 1:4.9.1-4
ii  libopenbabel4   2.3.2+dfsg-1.4
ii  libqt4-network  4:4.8.6+git64-g5dc8b2b+dfsg-2
ii  libqt4-xml  4:4.8.6+git64-g5dc8b2b+dfsg-2
ii  libqtcore4  4:4.8.6+git64-g5dc8b2b+dfsg-2
ii  libqtgui4   4:4.8.6+git64-g5dc8b2b+dfsg-2
ii  libstdc++6  4.9.1-4

xdrawchem recommends no packages.

xdrawchem suggests no packages.



I hope that helps! :-)

Cheers,
Martin


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org