Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-63066

QTextEdit::scrollToAnchor works randomly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.11.0
    • 5.10
    • GUI: Text handling
    • None
    • ab7d48625aed1c1bb56148f57f958371e810cf4c

    Description

      Reproducible in assistant, when calling setSource() with an url containing the proper anchor. Sometimes it works properly, but sometimes after setting the vbar to the proper value, an additional call to vbar->setValue() comes from Qt. The call stack for the unwanted one:

      1  QAbstractSlider::setValue                     qabstractslider.cpp               549  0x7ffff79e061b 
      2  QTextEditPrivate::_q_ensureVisible            qtextedit.cpp                     342  0x7ffff79aa63f 
      3  QTextEdit::qt_static_metacall                 moc_qtextedit.cpp                 361  0x7ffff79addf1 
      4  QMetaObject::activate                         qobject.cpp                       3766 0x7ffff6d1c013 
      5  QMetaObject::activate                         qobject.cpp                       3628 0x7ffff6d1c39d 
      6  QWidgetTextControl::visibilityRequest         moc_qwidgettextcontrol_p.cpp      566  0x7ffff7a538ed 
      7  QWidgetTextControl::ensureCursorVisible       qwidgettextcontrol.cpp            3156 0x7ffff7a55bb0 
      8  QTextEdit::ensureCursorVisible                qtextedit.cpp                     2641 0x7ffff79abe67 
      9  QTextEdit::inputMethodEvent                   qtextedit.cpp                     1707 0x7ffff79abeed 
      10 QWidget::event                                qwidget.cpp                       8870 0x7ffff7887ab8 
      11 QFrame::event                                 qframe.cpp                        550  0x7ffff794ecdc 
      12 QAbstractScrollArea::event                    qabstractscrollarea.cpp           1155 0x7ffff79b8ab8 
      13 QTextEdit::event                              qtextedit.cpp                     1080 0x7ffff79ac316 
      14 QTextBrowser::event                           qtextbrowser.cpp                  1269 0x7ffff7a4a025 
      15 QApplicationPrivate::notify_helper            qapplication.cpp                  3725 0x7ffff783ea2d 
      16 QApplication::notify                          qapplication.cpp                  3688 0x7ffff78486b2 
      17 QCoreApplication::notifyInternal2             qcoreapplication.cpp              1021 0x7ffff6cebd20 
      18 QCoreApplication::sendEvent                   qcoreapplication.h                234  0x7ffff7e69ae5 
      19 QIBusPlatformInputContext::updatePreeditText  qibusplatforminputcontext.cpp     289  0x7ffff7e69ae5 
      20 QIBusPlatformInputContext::qt_static_metacall moc_qibusplatforminputcontext.cpp 113  0x7ffff7e725d8 
      21 QMetaObject::activate                         qobject.cpp                       3766 0x7ffff6d1c013 
      22 QMetaObject::activate                         qobject.cpp                       3628 0x7ffff6d1c39d 
      23 QIBusInputContextProxy::UpdatePreeditText     moc_qibusinputcontextproxy.cpp    637  0x7ffff7e7476e 
      24 QIBusInputContextProxy::qt_static_metacall    moc_qibusinputcontextproxy.cpp    239  0x7ffff7e748e8 
      25 QIBusInputContextProxy::qt_metacall           moc_qibusinputcontextproxy.cpp    503  0x7ffff7e762af 
      26 QDBusConnectionPrivate::deliverCall           qdbusintegrator.cpp               998  0x7fffea1c7e4f 
      27 QDBusCallDeliveryEvent::placeMetaCall         qdbusintegrator_p.h               114  0x7fffea1d390d 
      28 QObject::event                                qobject.cpp                       1246 0x7ffff6d1c7ff 
      29 QApplicationPrivate::notify_helper            qapplication.cpp                  3725 0x7ffff783ea2d 
      30 QApplication::notify                          qapplication.cpp                  3097 0x7ffff78467dc 
      31 QCoreApplication::notifyInternal2             qcoreapplication.cpp              1021 0x7ffff6cebd20 
      32 QCoreApplication::sendEvent                   qcoreapplication.h                234  0x7ffff6cf0fab 
      33 QCoreApplicationPrivate::sendPostedEvents     qcoreapplication.cpp              1696 0x7ffff6cf0fab 
      34 QCoreApplication::sendPostedEvents            qcoreapplication.cpp              1550 0x7ffff6cf1708 
      35 postEventSourceDispatch                       qeventdispatcher_glib.cpp         276  0x7ffff6d47662 
      36 g_main_context_dispatch                                                              0x7ffff2930e52 
      37 g_main_context_iterate.isra                                                          0x7ffff29311d0 
      38 g_main_context_iteration                                                             0x7ffff293127c 
      39 QEventDispatcherGlib::processEvents           qeventdispatcher_glib.cpp         423  0x7ffff6d47028 
      40 QPAEventDispatcherGlib::processEvents         qeventdispatcher_glib.cpp         69   0x7fffea516683 
      41 QEventLoop::processEvents                     qeventloop.cpp                    134  0x7ffff6ce9b2f 
      42 QEventLoop::exec                              qeventloop.cpp                    212  0x7ffff6ce9f75 
      43 QCoreApplication::exec                        qcoreapplication.cpp              1309 0x7ffff6cf3c42 
      44 main                                          main.cpp                          392  0x45962f       
      

      The above one sets the vbar value to 8, which means the document is scrolled to the top.

      Happens completely randomly. Crazy.

      To reproduce:
      1. Run assistant
      2. Go to index
      3. Enter e.g. "number"
      4. Double click on it, it will open a Choose Topic dialog
      5. Double click one of the proposed topics. In about 50% of cases it will work correctly, and in about the other 50% of cases it will show the right page, but the top of it instead position it on the right anchor.

      ===========================

      Attached also the small example. You may reproduce it there, outside of assistant. It looks like there are some issues with focus in event and input method event. When you scroll the read-only text edit and just after that call setFocus() for it, you may receive the inputMethodEvent, which by default calls ensureCursorVisible() - which scrolls back the view to the position 0 (readonly text edit doesn't modify its position when scrolling the view). In addition, it only happens when some other dialog was shown before. This may be reproduced in the attached example. The issue is that widgets, which have WA_InputMethodEnabled flag shouldn't receive the inputMethod event at all.

      Attachments

        1. main.cpp
          0.2 kB
        2. textbrowser.pro
          1.0 kB
        3. widget.cpp
          1 kB
        4. widget.h
          0.3 kB
        5. widget.ui
          0.9 kB
        6. QTBUG-63066.webm
          1.49 MB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              treinio Topi Reiniƶ
              jkobus Jarek Kobus
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes