Bug 281513 - dbus method org.kde.konsole.Konsole.currentSession always return the active session within the first window, even when the qdbus commnd is executed in some session within the second window.
Summary: dbus method org.kde.konsole.Konsole.currentSession always return the active s...
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Unclassified
Component: general (show other bugs)
Version: 2.7
Platform: Chakra Linux
: NOR normal with 20 votes (vote)
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-07 03:09 UTC by Gris Ge
Modified: 2012-04-20 05:42 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gris Ge 2011-09-07 03:09:44 UTC
Version:           2.7 (using KDE 4.7.0) 
OS:                Linux

When we have 2+ konsole windows running, command:

qdbus org.kde.konsole /Konsole org.kde.konsole.Konsole.currentSession 

will get incorrect serssionID if execute in later opened konsole.

For example:
Windows 1 have session: 1 3 6 9
Windows 2 have session: 11

If execute command before in Windows 2 session 11, we got number 9.



Reproducible: Always

Steps to Reproduce:
1. Open 2 konsole windows with several tab (session)
2. Execute this command in later opened windows.
    qdbus org.kde.konsole /Konsole org.kde.konsole.Konsole.currentSession
3. Use this command to verify whether session id is correct:
==========
CURR_SE_ID=$(qdbus org.kde.konsole /Konsole \
    org.kde.konsole.Konsole.currentSession)
PRE_TAB_FORMAT="$(qdbus org.kde.konsole /Sessions/${CURR_SE_ID} \
    org.kde.konsole.Session.tabTitleFormat 0)"
qdbus org.kde.konsole /Sessions/${CURR_SE_ID} \
    org.kde.konsole.Session.setTabTitleFormat 0 "" 1>/dev/null
qdbus org.kde.konsole /Sessions/${CURR_SE_ID} \
    org.kde.konsole.Session.setTitle 0 "Changed Session" 1>/dev/null
qdbus org.kde.konsole /Sessions/${CURR_SE_ID} \
    org.kde.konsole.Session.setTitle 1 "Changed Session" 1>/dev/null
==========

Actual Results:  
Incorrect session number returned.
If using step above, one of window 1 session got changed tag text when execute command in window 2.

Expected Results:  
org.kde.konsole.Konsole.currentSession should return correct sessionID

As qdbus is owned by qt. not sure whether this is kde bug or qt bug.

Let me know if I could investigate more.
Comment 1 Jekyll Wu 2011-09-08 13:42:40 UTC
You are right. The problem is that dbus method always return the id of active session in the FIRST window.
Comment 2 Jekyll Wu 2011-10-22 09:39:21 UTC
[Techninal note; normal users can just ignore this comment]

The real problem is no matter how many windows are opened in konsole, konsole actually only creates dbus object for the first window. So every dbus method on that dbus object takes effect in the context of the first window.  I think that is basically a coding mistake, instead of intentional design.

bug 276912 is also influenced by this underlying problem.
Comment 3 Jekyll Wu 2012-02-07 12:06:07 UTC
https://git.reviewboard.kde.org/r/103790/
Comment 4 Jekyll Wu 2012-02-08 17:52:58 UTC
Git commit 07cddfe302233c3555258f077429e55ce622e262 by Jekyll Wu.
Committed on 08/02/2012 at 18:49.
Pushed by jekyllwu into branch 'master'.

Create dbus object for each Konsole window respectively

Its naming scheme is "/Windows/N", similar to "/Sessions/N" for
sessions. That is not the final decision and might change before next
major release.

The old "/Konsole" dbus object is still available at this moment, but
it might disappear or be used for something different in the future, so
it is better to use "/Windows/N" from now on.

For convenience, $KONSOLE_DBUS_WINDOW can be used to refer to the dbus
object corresponding to the Konsole window containing current session.
Note, that environment variable does not work well with detaching and
draging. Maybe it should not be added at all.
Related: bug 276912, bug 292309

REVIEW:103790

M  +2    -0    src/Application.cpp
M  +5    -0    src/Session.cpp
M  +2    -0    src/Session.h
M  +11   -0    src/ViewManager.cpp
M  +5    -0    src/ViewManager.h

http://commits.kde.org/konsole/07cddfe302233c3555258f077429e55ce622e262