<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
git version control wrote:
<blockquote cite="mid:20081112190919.7575328D57@skanda.videolan.org"
 type="cite">
  <pre wrap="">vlc | branch: master | Ludovic Fauvet <a class="moz-txt-link-rfc2396E" href="mailto:etix@l0cal.com"><etix@l0cal.com></a> | Tue Nov 11 11:37:34 2008 +0100| [7c8f1b05e8d2b4aa1717e623eb683337e6f1dced] | committer: Rémi Denis-Courmont 

Fix a cursor selection bug in the Messages logs (see #2163)

Also introduce a smart selection where the selection is restored after
text is inserted.

Signed-off-by: Rémi Denis-Courmont <a class="moz-txt-link-rfc2396E" href="mailto:rdenis@simphalempin.com"><rdenis@simphalempin.com></a>

  </pre>
  <blockquote type="cite">
    <pre wrap=""><a class="moz-txt-link-freetext" href="http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c8f1b05e8d2b4aa1717e623eb683337e6f1dced">http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c8f1b05e8d2b4aa1717e623eb683337e6f1dced</a>
    </pre>
  </blockquote>
  <pre wrap=""><!---->---

 modules/gui/qt4/dialogs/messages.cpp |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/modules/gui/qt4/dialogs/messages.cpp b/modules/gui/qt4/dialogs/messages.cpp
index 46aa53b..dd8d9fe 100644
--- a/modules/gui/qt4/dialogs/messages.cpp
+++ b/modules/gui/qt4/dialogs/messages.cpp
@@ -166,7 +166,11 @@ void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
      || (item->i_type == VLC_MSG_DBG && verbosityBox->value() < 2 ))
         return;
 
-    messages->textCursor().movePosition( QTextCursor::End );
+    // Saving cursor selection
+    int startPos = messages->textCursor().selectionStart();
+    int endPos = messages->textCursor().selectionEnd();
+
+    messages->moveCursor( QTextCursor::End );
     messages->setFontItalic( true );
     messages->setTextColor( "darkBlue" );
     messages->insertPlainText( qfu( item->psz_module ) );
@@ -198,6 +202,13 @@ void MessagesDialog::sinkMessage (msg_item_t *item, unsigned)
     messages->insertPlainText( qfu(item->psz_msg) );
     messages->insertPlainText( "\n" );
     messages->ensureCursorVisible();
+
+    // Restoring saved cursor selection
+    QTextCursor cur = messages->textCursor();
+    cur.movePosition( QTextCursor::Start );
+    cur.movePosition( QTextCursor::NextCharacter, QTextCursor::MoveAnchor, startPos );
+    cur.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, endPos - startPos );
+    messages->setTextCursor( cur );
 }
 
 void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,</pre>
</blockquote>
Some more problems have been introduced since this patch.<br>
There seems to be a huge performance issue after this patch after
selection of text,<br>
when the log becomes huge where it is now doing lots of work by
movePosition.<br>
Sometimes it takes more then 2-3-5 seconds for UI to become responsive
again<br>
on debugging build already running a bit slow.<br>
<br>
</body>
</html>