title: Why does QPainter restore cause segmentfault?
body: <p>My program  sometimes(low probability) crashed with the following imformation backtrace:</p>
  
  <pre><code>Error: signal 11:
  /ri/flamingo_console(_Z7handleri+0x174)[0x884a14]
  /lib/libc.so.6(__default_sa_restorer_v2+0x0)[0xb5d3de60]
  /lib/libc.so.6(memcpy+0x74)[0xb5d94124]
  /ri/Qt5.5/lib/libQt5Core.so.5(_ZN7QString11reallocDataEjb+0x8c) 
  [0xb60f2f68]
  /ri/Qt5.5/lib/libQt5Gui.so.5(+0x2f2284)[0xb6923284]  
  /ri/flamingo_console[0x5f75a8]
  /ri/flamingo_console[0x54f6e4]
  </code></pre>
  
  <p>I use the tool of addr2line and find the text address of 0x5f75a8 is in the following function:</p>
  
  <pre><code>void RElementStyle::drawText( QPainter &amp;painter,
             const QRect &amp;rect,
             const QString &amp;str,
             Qt::AlignmentFlag align )
  {
      painter.save();
      painter.setPen( mCommon.getColor( mStatus, str) );
      //! font
      QFont font = qApp-&gt;font();
      font.setPointSize( mCommon.mContentFont.mSize );
      painter.setFont( font );
      painter.drawText( rect,
                    align | Qt::AlignVCenter,
                    str );
      painter.restore();  //! this is the crash line 0x54f6e4
  }
  </code></pre>
  
  <p>I learn some things about painter.restore(), and I konw the restore() pops the settings of painter.However, I can't understand why the restore can cause a segment fault. Can someone analyze it for me? Thanks very much.</p>