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. Valgrind complaining in every use of QTextCursor:insertText
Forum Updated to NodeBB v4.3 + New Features

Valgrind complaining in every use of QTextCursor:insertText

Scheduled Pinned Locked Moved Unsolved General and Desktop
crashvalgrind
1 Posts 1 Posters 303 Views
  • 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.
  • G Offline
    G Offline
    Geat
    wrote on last edited by
    #1

    Every single time i use QTextCursor::Insert i get this from valgrind (and i can't ask for tech support directly because i use the open source liscence):

    ==3603== Invalid read of size 16
    ==3603==    at 0x204916A9: ??? (in /dev/zero)
    ==3603==    by 0x1122138F: ???
    ==3603==  Address 0x1122139e is 30 bytes inside a block of size 44 alloc'd
    ==3603==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==3603==    by 0x5C64B50: QArrayData::allocate(QArrayData**, long long, long long, long long, QArrayData::AllocationOption) (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Core.so.6.3.1)
    ==3603==    by 0x5C393F8: QString::reallocData(long long, QArrayData::AllocationOption) (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Core.so.6.3.1)
    ==3603==    by 0x555B079: QTextBlock::text() const (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Gui.so.6.3.1)
    ==3603==    by 0x54C9C94: ??? (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Gui.so.6.3.1)
    ==3603==    by 0x54C9F5E: ??? (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Gui.so.6.3.1)
    ==3603==    by 0x5B9C60F: ??? (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Core.so.6.3.1)
    ==3603==    by 0x54D6662: QTextDocument::contentsChange(int, int, int) (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Gui.so.6.3.1)
    ==3603==    by 0x54EE9BB: QTextDocumentPrivate::finishEdit() (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Gui.so.6.3.1)
    ==3603==    by 0x54D3023: QTextCursor::insertText(QString const&, QTextCharFormat const&) (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Gui.so.6.3.1)
    ==3603==    by 0x54D3167: QTextCursor::insertText(QString const&) (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Gui.so.6.3.1)
    ==3603==    by 0x4D18630: ??? (in /home/anyuser/Qt/6.3.1/gcc_64/lib/libQt6Widgets.so.6.3.1)
    

    Code:

    bool CodeEditor::AddCloseBraceAndChangeIndent()
    {
        auto cursor = textCursor();
    
        cursor.beginEditBlock();
        cursor.insertText(QChar('}'));
    
        cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::MoveAnchor, 2);
    
        if(cursor.block().begin().fragment().text()[cursor.positionInBlock()] == QChar('\t'))
            cursor.deleteChar();
    
        cursor.endEditBlock();
    
        return true;
    }
    
    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