Bug 118748 - Double superscripts causes kst to crash.
Summary: Double superscripts causes kst to crash.
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Fedora RPMs Linux
: NOR crash
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-20 21:48 UTC by Matthew Truch
Modified: 2005-12-20 22:40 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Truch 2005-12-20 21:48:56 UTC
Version:           1.2.0_svn_trunk (using KDE KDE 3.4.2)
Installed from:    Fedora RPMs
OS:                Linux

Double super scripts cause kst to crash.  

I entered "s^-^2" as the text for the x-axis, and kst crashed.  This was while trying to figure out how to get s^{-2} (before I realized grouping was with curly braces, a la latex, duh!).  Double subscripts have a similar effect.  

Backtrace follows:

Using host libthread_db library "/lib/libthread_db.so.1".
`shared object read from target memory' has disappeared; keeping its symbols.
[Thread debugging using libthread_db enabled]
[New Thread -1209116992 (LWP 9342)]
[New Thread -1212662864 (LWP 9345)]
[KCrash handler]
#4  0x00bc5c14 in KstPlotLabel::computeTextSize (this=0x8767900)
    at kstplotlabel.cpp:155
#5  0x00bc5e2e in KstPlotLabel::setText (this=0x8767900, text=@0xbfc00e00)
    at kstplotlabel.cpp:82
#6  0x00c33f1e in KstPlotDialogI::applyAppearance (this=0x8548340, 
    plot=@0xbfc00ef8) at kstplotdialog_i.cpp:550
#7  0x00c3d9a6 in KstPlotDialogI::applySettings (this=0x8548340, c=0x8b66158, 
    plot=@0xbfc00fa8) at kstplotdialog_i.cpp:834
#8  0x00c3e5f8 in KstPlotDialogI::edit_I (this=0x8548340)
    at kstplotdialog_i.cpp:912
#9  0x00c3e945 in KstPlotDialogI::qt_invoke (this=0x8548340, _id=59, 
    _o=0xbfc010a8) at kstplotdialog_i.moc:197
#10 0x026b4eb4 in QObject::activate_signal (this=0x85f26b8, clist=0x8619188, 
    o=0xbfc010a8) at kernel/qobject.cpp:2355
#11 0x026b5374 in QObject::activate_signal (this=0x85f26b8, signal=4)
    at kernel/qobject.cpp:2324
#12 0x02a34c7e in QButton::clicked (this=0x0)
    at .moc/release-shared-mt/moc_qbutton.cpp:152
#13 0x02754a63 in QButton::mouseReleaseEvent (this=0x85f26b8, e=0xbfc014d4)
    at widgets/qbutton.cpp:836
#14 0x026f3187 in QWidget::event (this=0x85f26b8, e=0xbfc014d4)
    at kernel/qwidget.cpp:4699
#15 0x026500dd in QApplication::internalNotify (this=0x0, receiver=0x85f26b8, 
    e=0xbfc014d4) at kernel/qapplication.cpp:2635
#16 0x0265103f in QApplication::notify (this=0xbfc01c58, receiver=0x85f26b8, 
    e=0xbfc014d4) at kernel/qapplication.cpp:2421
#17 0x008a0851 in KApplication::notify () from /usr/lib/libkdecore.so.4
#18 0x025e7746 in QETWidget::translateMouseEvent (this=0x85f26b8, 
    event=0xbfc01798) at kernel/qapplication.h:518
#19 0x025e5f01 in QApplication::x11ProcessEvent (this=0xbfc01c58, 
    event=0xbfc01798) at kernel/qapplication_x11.cpp:3468
#20 0x025fa008 in QEventLoop::processEvents (this=0x84a05d0, flags=)
    at kernel/qeventloop_x11.cpp:192
#21 0x0266882b in QEventLoop::enterLoop (this=0x84a05d0)
    at kernel/qeventloop.cpp:198
#22 0x02668736 in QEventLoop::exec (this=0x84a05d0)
    at kernel/qeventloop.cpp:145
#23 0x0264faa9 in QApplication::exec (this=0xbfc01c58)
    at kernel/qapplication.cpp:2758
#24 0x080548db in main (argc=2, argv=0xbfc022d4) at main.cpp:811
#25 0x00de7d5f in __libc_start_main () from /lib/libc.so.6
#26 0x0804d9b1 in _start ()
Comment 1 George Staikos 2005-12-20 22:40:11 UTC
SVN commit 490138 by staikos:

Don't crash due to failed parsing of labels.
BUG: 118748


 M  +33 -14    kstplotlabel.cpp  
 M  +15 -11    kstviewlabel.cpp  


--- trunk/extragear/graphics/kst/kst/kstplotlabel.cpp #490137:490138
@@ -80,6 +80,7 @@
     _txt = text;
     reparse();
     computeTextSize();
+    //setDirty(true);
   }
 }
 
@@ -90,14 +91,20 @@
 
 
 void KstPlotLabel::setRotation(float rotation) {
-  _rotation = rotation;
-  _sinr = fabs(sin(_rotation * M_PI / 180.0));
-  _cosr = fabs(cos(_rotation * M_PI / 180.0));
+  if (_rotation != rotation) {
+    _rotation = rotation;
+    _sinr = fabs(sin(_rotation * M_PI / 180.0));
+    _cosr = fabs(cos(_rotation * M_PI / 180.0));
+    //setDirty(true);
+  }
 }
 
 
 void KstPlotLabel::setJustification(KstLJustifyType justify) {
-  _justify = justify;
+  if (_justify != justify) {
+    _justify = justify;
+    //setDirty(true);
+  }
 }
 
 
@@ -110,6 +117,7 @@
   if (_fontName != fontName) {
     _fontName = fontName;
     computeTextSize();
+    //setDirty(true);
   }
 }
 
@@ -123,12 +131,16 @@
   if (_interpret != interpreted) {
     _interpret = interpreted;
     reparse();
+    //setDirty(true);
   }
 }
 
 
 void KstPlotLabel::setDoScalarReplacement(bool replace) {
-  _replace = replace;
+  if (_replace != replace) {
+    _replace = replace;
+    //setDirty(true);
+  }
 }
 
 
@@ -145,18 +157,22 @@
   p.translate(tx, ty);
   p.rotate(_rotation);
 
-  renderLabel(rc, lp->chunk);
+  if (lp && lp->chunk) {
+    renderLabel(rc, lp->chunk);
+  }
 }
 
 
 void KstPlotLabel::computeTextSize() {
-  RenderContext rc(_fontName, _absFontSize, 0L);
-  rc.setSubstituteScalars(_replace);
-  renderLabel(rc, _parsed->chunk);
-  _textWidth = rc.x;
-  _ascent = rc.ascent;
-  _textHeight = 1 + rc.ascent + rc.descent;
-  _lineSpacing = QFontMetrics(QFont(_fontName, _absFontSize)).lineSpacing();
+  if (_parsed && _parsed->chunk) {
+    RenderContext rc(_fontName, _absFontSize, 0L);
+    rc.setSubstituteScalars(_replace);
+    renderLabel(rc, _parsed->chunk);
+    _textWidth = rc.x;
+    _ascent = rc.ascent;
+    _textHeight = 1 + rc.ascent + rc.descent;
+    _lineSpacing = QFontMetrics(QFont(_fontName, _absFontSize)).lineSpacing();
+  }
 }
 
 
@@ -166,7 +182,10 @@
 
 
 void KstPlotLabel::setFontSize(int size) {
-  _fontSize = size;
+  if (_fontSize != size) {
+    _fontSize = size;
+    //setDirty(true);
+  }
 }
 
 
--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #490137:490138
@@ -292,7 +292,9 @@
   QTime t;
   t.start();
 #endif
-  renderLabel(rc, lp->chunk);
+  if (lp && lp->chunk) {
+    renderLabel(rc, lp->chunk);
+  }
 #ifdef BENCHMARK
   kstdDebug() << "render took: " << t.elapsed() << endl;
   t.start();
@@ -305,20 +307,22 @@
 
 
 void KstViewLabel::computeTextSize(Label::Parsed *lp) {
-  RenderContext rc(_fontName, _absFontSize, 0L);
-  rc.setSubstituteScalars(_replace);
-  rc.precision = _dataPrecision;
+  if (lp && lp->chunk) {
+    RenderContext rc(_fontName, _absFontSize, 0L);
+    rc.setSubstituteScalars(_replace);
+    rc.precision = _dataPrecision;
 #ifdef BENCHMARK
-  QTime t;
-  t.start();
+    QTime t;
+    t.start();
 #endif
-  renderLabel(rc, lp->chunk);
+    renderLabel(rc, lp->chunk);
 #ifdef BENCHMARK
-  kstdDebug() << "compute (false render) took: " << t.elapsed() << endl;
+    kstdDebug() << "compute (false render) took: " << t.elapsed() << endl;
 #endif
-  _textWidth = rc.xMax;
-  _ascent = rc.ascent;
-  _textHeight = 1 + rc.ascent + rc.descent;
+    _textWidth = rc.xMax;
+    _ascent = rc.ascent;
+    _textHeight = 1 + rc.ascent + rc.descent;
+  }
 }