Bug 93928 - ASSERT: "!m_doc->wrapCursor()" in katerenderer.cpp (626)
Summary: ASSERT: "!m_doc->wrapCursor()" in katerenderer.cpp (626)
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: kwrite (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-25 22:28 UTC by Michael Zeilfelder
Modified: 2005-02-18 00:27 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Fix the problem (1.02 KB, patch)
2004-12-19 01:34 UTC, Richard Smith
Details
patch for KDE3.3.2 (1.78 KB, patch)
2004-12-20 06:34 UTC, Kazuki Ohta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Zeilfelder 2004-11-25 22:28:30 UTC
Version:           4.3 (using KDE KDE 3.3.1)
Installed from:    Debian testing/unstable Packages
OS:                Linux

I get this assertmessage for each column which my cursor is behind column 22. 
So for example i click on column 26 i get this message 4 times.
Comment 1 Michael Zeilfelder 2004-11-25 22:58:29 UTC
I've tried around some more and it's not always behind column 22 but sometimes sooner. Not exactly sure, but could have to do something with the number of tabs i'm using before that (the asserts come on a earlier column if i use more tabs).

Comment 2 Gabor Fekete 2004-12-18 13:24:33 UTC
It seems this bug is related to the fact that the Kate part is slow when dealing with long lines. These asserts go to stderr (~/.xsession-errors). If I send stderr to /dev/null the slowness with long lines of kate part goes away.
Comment 3 Wilbert Berendsen 2004-12-18 23:13:54 UTC
Same here, I often run kate or kwrite from the console i'm in. It is irritating that it fills the whole konsole history sometimes with the asserts :-)
Comment 4 Anders Lund 2004-12-18 23:26:02 UTC
It has alwo been commented out for kde 3.4a1 by David Faure.
The commit log for v. 1.83 is:
his warning is driving me crazy. It happens all the time (e.g. I simply do Ctrl+U to
view a webpage's HTML).
CCMAIL: rodda@kde.org

According to Hamish, it actually is a problem, so I left it in there despite my desperate desire to comment it out some months ago.. But I guess someone should analyze the code and find out what the problem really is.
Comment 5 Anders Lund 2004-12-18 23:26:20 UTC
It has also been commented out for kde 3.4a1 by David Faure.
The commit log for v. 1.83 is:
his warning is driving me crazy. It happens all the time (e.g. I simply do Ctrl+U to
view a webpage's HTML).
CCMAIL: rodda@kde.org

According to Hamish, it actually is a problem, so I left it in there despite my desperate desire to comment it out some months ago.. But I guess someone should analyze the code and find out what the problem really is.
Comment 6 Richard Smith 2004-12-19 01:34:11 UTC
Created attachment 8718 [details]
Fix the problem

Under a minute of debugging later, this patch solves the problem. I'm not
entirely sure it's the desired behaviour since I've got no idea how this input
method stuff is supposed to work (what's preedit all about?), or even what that
code is supposed to do. Nonetheless, can this be committed?
Comment 7 Anders Lund 2004-12-19 02:39:10 UTC
It looks sane, but I don't know anything about the input stuff either.
I add the developer who has added the im code to the CC list of this bug, in the hope he can tell if it is OK.
Comment 8 Kazuki Ohta 2004-12-19 20:00:51 UTC
Richard's solution is wrong for CJK(Chinese, Japanese, Korean) people.

The problem is when removing the text, the place of cursor is not updated. For example, imagine the situation strlen of current line = 2 and cursor-pos = 1. Then, remove the text from position 0 to 2. Calling KateRenderer::textWidth in this situation causes the problem.

Please test this patch. If there's no problem, I'll commit this patch.

--- kateviewinternal.cpp.orig   2004-12-20 03:16:23.000000000 +0900
+++ kateviewinternal.cpp        2004-12-20 03:49:56.000000000 +0900
@@ -3009,6 +3009,10 @@
   }
 
   if ( m_imPreeditLength > 0 ) {
+    // reset cursor position before removing text
+    cursor.setPos( cursor.line(), m_imPreeditStart );
+    updateCursor( cursor, true );
+
     m_doc->removeText( cursor.line(), m_imPreeditStart,
                        cursor.line(), m_imPreeditStart + m_imPreeditLength );
   }
@@ -3034,6 +3038,10 @@
   }
 
   if ( m_imPreeditLength > 0 ) {
+    // reset cursor position before removing text
+    cursor.setPos( cursor.line(), m_imPreeditStart );
+    updateCursor( cursor, true );
+
     m_doc->removeText( cursor.line(), m_imPreeditStart,
                        cursor.line(), m_imPreeditStart + m_imPreeditLength );
   }
Comment 9 Richard Smith 2004-12-19 23:04:36 UTC
On Sunday 19 December 2004 19:00, Kazuki Ohta wrote:
> The problem is when removing the text, the place of cursor is not updated.

The problem happens without removing text. The problem is that 
m_imPreeditStartLine isn't cursor.line(), so calling 
textWidth(m_imPreeditStartLine, cursor.pos()) is wrong (since cursor.pos() 
might not be on that line). Usually, m_imPreeditLine is the first line in the 
document (for me, at least).

I've not tested your patch, but I can reproduce the bug by going to 
kateviewinternal.cpp, to the line which I changed, and typing some stuff near 
the end. No removal occurs. m_imPreeditStartLine is the first line.
Comment 10 Kazuki Ohta 2004-12-20 06:34:29 UTC
Created attachment 8731 [details]
patch for KDE3.3.2

> No removal occurs. m_imPreeditStartLine is the first line. 
I see.
For the people which doesn't use InputMethod, m_imPreeditStartLine is always 0.
Then, the line you pointed behaves wrongly.
For the InputMethod using people, the problem which I pointed occurs in
removing preedit text.
So, there's two ways which causes the assertion failure. Complete patch is
attached. Please try.
Comment 11 Aquila 2005-02-10 10:55:42 UTC
Can anyone confirm this patch works? It's really annoying when using Konsole...
Comment 12 Anders Lund 2005-02-10 13:25:05 UTC
I don't see this problem in cvs HEAD. So either it has been solved, or it's not present if the special input method is not used.
Comment 13 Anders Lund 2005-02-18 00:27:39 UTC
This line is commented out. The actual bug remains, but we will not release kate with this line enabled.