[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [Bug 180239] stange text editing behaviour on undo
From:       Pierre Stirnweiss <pstirnweiss () googlemail ! com>
Date:       2009-01-17 21:32:44
Message-ID: 20090117213244.34E1014245 () immanuel ! kde ! org
[Download RAW message or body]

http://bugs.kde.org/show_bug.cgi?id=180239


Pierre Stirnweiss pstirnweiss googlemail com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pstirnweiss@googlemail.com




--- Comment #1 from Pierre Stirnweiss <pstirnweiss googlemail com>  2009-01-17 22:32:43 ---
This problem is caused by a bug in Qt:
when a selection is "replaced" by new text, the following happens within
QTextDocumentPrivate:
- a call to remove is made, which creates a number of commands (depending
whether the selection contains a linebreak or not)
- new characters are inserted, which also create a command

These commands are grouped together in the stack by a
beginEditBlock/endEditBlock, so that when undo is requested, they are ALL
undone.

The problem lies in that on each push of these commands, the signal
undoCommandAdded is emited.

KOffice creates one undoCommand per signal on its own stack. All these are also
grouped in a parent command.
When we hit undo, calls to QTextDocument::undo are done for each child
undoCommands. The first time, QTextDocument undoes ALL the internal grouped
commands, undoing the "replace" action completly. The second time
QTextDocument::undo is called, the QTextDocument undoes the previous change
(which in the case of the present bug was "type ddd". A further time would undo
the previous command again (in this case the linebreak), and so on.

The signal undoCommandAdded should be emitted only once per
beginEditBlock/endEditBlock. Perhaps by moving the emission from the
appendUndoCommand method to the endEditBlock method somewhere?


-- 
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic