Valgrind complaining in every use of QTextCursor:insertText
Unsolved
General and Desktop
-
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; }