[vlc-devel] commit: Fix a cursor selection bug in the Messages logs (see #2163) ( Ludovic Fauvet )

xxcv xxcv07 at gmail.com
Tue Nov 18 15:14:52 CET 2008


git version control wrote:
> vlc | branch: master | Ludovic Fauvet <etix at l0cal.com> | 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 <rdenis at simphalempin.com>
>
>   
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c8f1b05e8d2b4aa1717e623eb683337e6f1dced
>>     
> ---
>
>  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,
Some more problems have been introduced since this patch.
There seems to be a huge performance issue after this patch after 
selection of text,
when the log becomes huge where it is now doing lots of work by 
movePosition.
Sometimes it takes more then 2-3-5 seconds for UI to become responsive again
on debugging build already running a bit slow.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20081119/04fc7141/attachment.html>


More information about the vlc-devel mailing list