Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.6.1, 5.7.0
-
None
-
Ubuntu 14.04.4LTS x86_64, running Linux 4.4.0-28
QtCreator 4.1.0beta1 from the official installer.
Project uses Qt 5.7.0, from the official installer.
Description
minimalExample.cpp
#include <QApplication> #include <QPlainTextEdit> int main(int argc, char *argv[]) { QApplication a(argc, argv); QPlainTextEdit pe; pe.setLineWrapMode(QPlainTextEdit::WidgetWidth); QTextOption opt = pe.document()->defaultTextOption(); opt.setFlags(opt.flags() | QTextOption::IncludeTrailingSpaces); pe.document()->setDefaultTextOption(opt); pe.setPlainText(QString(50, ' ') + QString ("line2")); pe.show(); // manually resize the editor until "line2" is wrapped and click inside the first now wrapped line... BOOM return a.exec(); }
ORIGINAL CREATOR BUG REPORT:
QtCreator segfaults in QTextLine::xToCursor while editing when wrapping is on
I was editing QML, making a selection using the Shift+arrow keys, then hitting a key to type a replacement, when
#0 0x00007fb4fe377312 in QTextLine::xToCursor(double, QTextLine::CursorPosition) const () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Gui.so.5 #1 0x00007fb4fe3c5c04 in QTextCursorPrivate::movePosition(QTextCursor::MoveOperation, QTextCursor::MoveMode) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Gui.so.5 #2 0x00007fb4fe3c65e5 in QTextCursor::movePosition(QTextCursor::MoveOperation, QTextCursor::MoveMode, int) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Gui.so.5 #3 0x00007fb4eb9ab6c8 in ?? () from /opt/qtcreator-410b1/lib/qtcreator/plugins/libTextEditor.so #4 0x00007fb4eb9c878e in TextEditor::TextEditorWidget::keyPressEvent(QKeyEvent*) () from /opt/qtcreator-410b1/lib/qtcreator/plugins/libTextEditor.so #5 0x00007fb4feaa1db4 in QWidget::event(QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #6 0x00007fb4feb84c0e in QFrame::event(QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #7 0x00007fb4fec083a3 in QAbstractScrollArea::event(QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #8 0x00007fb4fec30075 in QPlainTextEdit::event(QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #9 0x00007fb4fea5c52c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #10 0x00007fb4fea63029 in QApplication::notify(QObject*, QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #11 0x00007fb4fd752ae0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Core.so.5 #12 0x00007fb4feabf52b in ?? () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #13 0x00007fb4fea5c52c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #14 0x00007fb4fea63220 in QApplication::notify(QObject*, QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Widgets.so.5 #15 0x00007fb4fd752ae0 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Core.so.5 #16 0x00007fb4fe256a58 in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Gui.so.5 #17 0x00007fb4fe25b725 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Gui.so.5 #18 0x00007fb4fe23ce73 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Gui.so.5 #19 0x00007fb4f4a75080 in ?? () from /opt/qtcreator-410b1/lib/Qt/plugins/platforms/../../lib/libQt5XcbQpa.so.5 #20 0x00007fb4f9099e04 in g_main_dispatch (context=0x7fb4ec001e10) at /build/buildd/glib2.0-2.40.2/./glib/gmain.c:3064 #21 g_main_context_dispatch (context=context@entry=0x7fb4ec001e10) at /build/buildd/glib2.0-2.40.2/./glib/gmain.c:3663 #22 0x00007fb4f909a048 in g_main_context_iterate (context=context@entry=0x7fb4ec001e10, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at /build/buildd/glib2.0-2.40.2/./glib/gmain.c:3734 #23 0x00007fb4f909a0ec in g_main_context_iteration (context=0x7fb4ec001e10, may_block=1) at /build/buildd/glib2.0-2.40.2/./glib/gmain.c:3795 #24 0x00007fb4fd7a0047 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Core.so.5 #25 0x00007fb4fd750dca in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Core.so.5 #26 0x00007fb4fd758bad in QCoreApplication::exec() () from /opt/qtcreator-410b1/bin/../lib/Qt/lib/libQt5Core.so.5 #27 0x0000000000409731 in ?? () #28 0x00007fb4fc3cff45 in __libc_start_main (main=0x406b20, argc=1, argv=0x7ffdc600d8b8,
EDIT got a reliable reproduction scenario with this code:
import QtQuick 2.7 MouseArea { property bool hoversOnCanvas: distance(1.0 - mouseX / width, mouseY / height, volatiles.mainAnnotation.center[0], volatiles.mainAnnotation.center[1]) // Window width should be so that this line exactly doesn't wrap: ---------------------------------- onMouseXChanged: console.log('===== mouseX', mouseX, 'hoversOnCanvas', hoversOnCanvas, 'distance', ); }
Please see the attached screencast to see by yourself. Steps are:
- Set your QtCreator to wrap long lines
- Adjust your QtCreator window width so that the commented line precisely doesn't wrap
- Copy the distance(...) call
- Paste it at the end of the console.log statement, which should be exactly where it wraps
- Navigate using the arrow keys
→ QtCreator should crash.