Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Inser into QTextEdit using QChar::ObjectReplacementCharacter crash after clear()
Forum Updated to NodeBB v4.3 + New Features

Inser into QTextEdit using QChar::ObjectReplacementCharacter crash after clear()

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • deleted57D Offline
    deleted57D Offline
    deleted57
    wrote on last edited by
    #1

    Hi all

    I'm developing a software using Qt 4.8.4. I have a QTextEdit where I insert some custom objects as found in the "Text Object" example. The first time I insert my object all goes well. The problem happen after I call QTextEdit clear() method. Since I need to fill the editor with a new set of objects I clear all the content and start inser again. Unofrtunately it seem after called clear() insert new objects make crash the application. The debugger report me the crash into a realloc() function of a vector inside QTextEdit control. I'm currently using Visual Studio for developing. Currently I still was not able to find a workaround for this problem. Someone know a solution?

    Thank you

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Could you post a minimum example of code that triggers the crash ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • deleted57D Offline
        deleted57D Offline
        deleted57
        wrote on last edited by
        #3

        Hi

        Thank you for your reply

        Well, a very short example could be the following:

        @QTextCharFormat MyFormat;
        QTextCursor Cursor;

        MyFormat.setObjectType(MyFormatType);
        MyFormat.setProperty(PROPERTY1, Data1);
        MyFormat.setProperty(PROPERTY2, Data2);
        MyFormat.setProperty(PROPERTY3, Data3);

        Cursor = textCursor();
        Cursor.insertText(QString(QChar::ObjectReplacementCharacter), MyFormat);
        Cursor.insertText(" ");
        setTextCursor(Cursor);@

        This code insert my custom objects into QTextEdit. This work very well the first insertion where I can insert a large number of objects. However when I need to clear all for make new insertions I call:

        @MyEditText->clear();@

        After this call that correctly clear all the editor content if I retry to execute the same insertion code above the crash described is reported. If could help I can report additional info based to my tests:

        • if I countinue to add object without never call clear() no error is reported
        • after called clear() I need to insert a number of object around more than 10/15 for generate the crash. If I add a few number no crash is reported (but I still didn't try to make the add operation of few elements more times)
        • Instead to call clear() function I tried to select all elements by code and remove them but the result is the same crash

        It seem clear() function doesn't correctly delete all the vector elements associated to the editor or some problem happen during vector realloc operation...

        Thank you for the help

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Thanks for the clarification.

          I meant: could you post enough code that could be built to reproduce the crash. I can't really try to do anything from there.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • deleted57D Offline
            deleted57D Offline
            deleted57
            wrote on last edited by
            #5

            Thank you for your interest

            I'll try to develop a full demo for reproduce the problem, just give me some time.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              No stress about it, you might even found yourself the solution while creating the demo.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved