Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116318

QTextEngine::layoutData is nullptr

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P1: Critical
    • None
    • 5.15.10
    • GUI: Text handling
    • None
    • windows10 vs2015
    • Windows

    Description

      QTextEdit*  mytext = new QTextEdit(parent);

      setAcceptRichText(false);
      setReadOnly(true);
      setUndoRedoEnabled(false);

      setTextColor(lineColor);

      append("14:41:51: 开始读取数据计算数据(v:2.8.3),请等待...");

      When the above code append, layoutData is a null pointer at the following location, causing the program to crash

      inline bool ensureSpace(int nGlyphs) const

      {         if (layoutData->glyphLayout.numGlyphs - layoutData->used < nGlyphs)             return layoutData->reallocate((((layoutData->used + nGlyphs)*3/2 + 15) >> 4) << 4);         return true;     }

      Also in QTextLineItemIterator: : next () collapse, layoutData is also a null pointer.

       

      • The crash caused by layoutData being a null pointer is accidental.

       
      eg:

      class MsgListener
      {
      public:
          MsgListener(){};
          virtual ~MsgListener() {}

          virtual void showMsg(const QString & qsMsg, int nType) = 0;
      };

      ---------------------------------------------------------------------
      static QList<MsgListener *>   MsgListeners;
      class MsgManage
      {
      public:
          ~MsgManage();
          static void Register_Listener(MsgListener * pListener);
          static void Unregister_Listener(MsgListener * pListener);
          static bool ShowMsg( const QString & qsMsg,int nType = -1 )
          {
              for (int i = 0; i < MsgListeners.size(); ++i)

      {             MsgListener * listener = MsgListeners[i];            listener->showMsg(qsMsg, nType);         }

          }

          private:
              MsgManage();    
          };
      ---------------------------------------------------------------------
          DockMsgOutput : public QDockWidget,MsgListener

      {         m_editMsg = new QTextEdit(parent);         m_editMsg->setAcceptRichText(false);         m_editMsg->setReadOnly(true);         m_editMsg->setUndoRedoEnabled(false);         DockMsgOutput->setWidget(m_editMsg);     }

         
          void DockMsgOutput::showMsg(const QString & qsMsg, int nType)

      {         ...         m_editMsg->setTextColor(color);         m_editMsg->append(msg);           m_editMsg->ensureCursorVisible();     }

      ---------------------------------------------------------------------

          callback(qsMsg,type)

      {         MsgManage::showMsg(qsMsg,type)     }

      Attachments

        1. 1692690304305.jpg
          33 kB
          Jasper chen
        2. 1692691722884.jpg
          111 kB
          Jasper chen
        3. main.cpp
          0.4 kB
          Eskil Abrahamsen Blomfeldt
        4. SensorForce_231204.7z.003
          10.19 MB
          健成 刘
        5. SensorForce_231204.7z.001
          15.00 MB
          健成 刘
        6. SensorForce_231204.7z.002
          15.00 MB
          健成 刘
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            huairui008 Jasper chen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes