Bug 49153 - deattach/attach session -> key input is doubled
Summary: deattach/attach session -> key input is doubled
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: VHI normal
Target Milestone: ---
Assignee: Simon Hausmann
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-14 23:52 UTC by Jan Spitalnik
Modified: 2002-10-21 12:21 UTC (History)
1 user (show)

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


Attachments
patch to fix invalid reads when attaching session (4.82 KB, patch)
2002-10-20 18:13 UTC, Simon Hausmann
Details
fix slot declaration (538 bytes, patch)
2002-10-21 11:14 UTC, Simon Hausmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Spitalnik 2002-10-14 23:52:31 UTC
Version:           1.2 Beta2 (using KDE 3.0.8 (KDE 3.1 beta2))
Installed from:     (testing/unstable)
Compiler:          gcc version 3.2.1 20020924 (Debian prerelease)
OS:          Linux (i686) release 2.4.20-pre8aa2

hi,
startup konsole, do deattach/attach combo and then try to write
"Hello" it will come out as "HHeelllloo" :-)
Cheers,
		spity
Comment 1 Stephan Binner 2002-10-15 19:46:47 UTC
Cannot reproduce this. Which steps did you leave out (obviously at least the 
one creating a second session) to make it reproducible? :-) 
Comment 2 Jan Spitalnik 2002-10-15 23:21:53 UTC
Subject: Re:  deattach/attach session -> key input is doubled

On Tue, Oct 15, 2002 ve 05:46:48PM -0000, Stephan Binner wrote:
> Cannot reproduce this. Which steps did you leave out (obviously at least the 
> one creating a second session) to make it reproducible? :-)

oops, okey, start konsole, create two sessions, deattach/attach one of them
-> double-chars :) CVS(14.10.2002)


Comment 3 Stephan Binner 2002-10-16 16:09:55 UTC
Ok, I can reproduce this - but only with current qt-copy, Qt 3.0.6 works fine. 
Can you confirm that you use qt-copy (and why doesn't ask the bug system 
this)? 
Comment 4 Jan Spitalnik 2002-10-16 16:20:21 UTC
Subject: Re:  deattach/attach session -> key input is doubled

Dne st 16. 
Comment 5 Stephan Binner 2002-10-20 16:51:01 UTC
http://lists.kde.org/?l=konsole-devel&m=103512276507858&w=2 has a work-around   
patch for use with qt-copy, thanks. :-) But better try to find this subtle bug 
as long there is time left before it bugs us again somewhere else.   
Tronical, do you succeed in creating a simple test case for TrollTech? :-)   
Comment 6 Simon Hausmann 2002-10-20 18:13:03 UTC
Created attachment 225 [details]
patch to fix invalid reads when attaching session
Comment 7 Simon Hausmann 2002-10-20 18:13:57 UTC
While debugging (it looks indeed like a Qt bug) I noticed that when attaching the KonsoleChild     
destructor deletes the TEWidget object before emitting the doneChild signal. the signal emission   
leads to attachSession and somewhen it ends up in TEmulation::changeGUI . At this point the gui  
member variable is a dangling pointer because the TEWidget is already dead. See attached patch for  
a fix for the invalid reads caused by that. (nope, that doesn't fix this bug, it's just a side-effect :)  
Comment 8 Simon Hausmann 2002-10-21 11:14:18 UTC
Created attachment 236 [details]
fix slot declaration

This patch fixes the slot declaration to make the connection in the base class
constructor use the same slot when disconnecting later (when the TEmuVt102
class) is ininitialized.
Comment 9 Simon Hausmann 2002-10-21 11:21:57 UTC
OK, turned out not to be a real Qt bug. TEmulation declares the onKeyPress slot. TEmuVt102's   
declares the slot again, so the slot is listed twice, once in TEmulation's QMetaObject and once in    
TEmuVt102's one. But as the TEmulation constructor calls connectGUI at this time only the   
onKeyPressed slot of TEmulation is avaiable, because the vtbl of the object is not adjusted to   
TEmuVt102 yet, so the metaObject method still returns TEmulations' QMetaObject. As a result in   
the sender object the member index of TEmulation's onKeyPressed signal is stored (in the   
connection list) .  
  
At run-time it doesn't make a difference as the slot method was marked virtual.  
  
But when disconnecting metaObject() returns TEmuVt102's metaobject and there disconnect  
immediately finds the onKeyPressed slot and tries to disconnect that one. It fails however as the  
member index is different to the one in the base class.  
  
The fact that it worked with Qt 3.0.x I would call a fortune or something like relying on undefined  
behaviour :)  
  
Attachment 2 [details] fixes the bug. 
 
Konsole developers, please approve both patches :) 
Comment 10 Stephan Binner 2002-10-21 12:15:41 UTC
Ouch, thanks for your efforts. Please commit the patches. 
Comment 11 Simon Hausmann 2002-10-21 12:21:34 UTC
Subject: kdebase/konsole/konsole

CVS commit by hausmann: 

- fixed an invalid read when attaching a detached session
- fixed keyPress signal/slot connection when detaching and re-attaching
  a session
  See #49153 for details about both patches. Approved by Beineri
CCMAIL: 49153-done@bugs.kde.org

  M  +7 -5     TEmuVt102.cpp   1.95
  M  +1 -1     TEmuVt102.h   1.33
  M  +23 -21   TEmulation.cpp   1.45
  M  +2 -1     TEmulation.h   1.27