Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Inser into QTextEdit using QChar::ObjectReplacementCharacter crash after clear()
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?
Hi and welcome to devnet,
Could you post a minimum example of code that triggers the crash ?
Thank you for your reply
Well, a very short example could be the following:
Cursor = textCursor();
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:
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
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.
Thank you for your interest
I'll try to develop a full demo for reproduce the problem, just give me some time.
No stress about it, you might even found yourself the solution while creating the demo.