Bug 95407 - deleted session shortcuts are remembered
Summary: deleted session shortcuts are remembered
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Kurt Hindenburg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-18 20:34 UTC by Kurt Hindenburg
Modified: 2004-12-19 17:34 UTC (History)
1 user (show)

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


Attachments
Fix removing shortcuts for deleted sessions (2.93 KB, patch)
2004-12-18 22:40 UTC, Kurt Hindenburg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kurt Hindenburg 2004-12-18 20:34:34 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:                Linux

This bug is from the patch I applied for BR66737.

 ------- Additional Comment #16 From Mikolaj Machowski 2004-12-17 00:18 ------- 
> The creating/deleting sessions problem should be fixed. 
 > Please test this fully... 
 
 Works really pretty now. But still one thing :) 
 - new session, Vim (calling vim) 
 - assign shortcut 'Ctrl-L,V' 
 - remove session with name Vim 
 - create session with the same name 'Vim' old shortcut is automatically 
   reassigned; even after restart of Konsole. 
 
 Looks like patch doesn't remove shortcut assignments and they are 
 automatically recalled when session with that name is visible again. 
 
 Things go astray when: 
 - new session, Vim (calling vim) 
 - assign shortcut 'Ctrl-L,V' 
 - remove session with name Vim 
 - create new session 'top' (with top command) 
 - assign shortcut 'Ctrl-L,V' 
 - create new-old session 'Vim' 
 
 No crashes but after pressing 'Ctrl-L,V' Konsole doesn't know what to 
 do.
Comment 1 Kurt Hindenburg 2004-12-18 22:40:57 UTC
Created attachment 8716 [details]
Fix removing shortcuts for deleted sessions

Mikolaj, can you test this patch?  Is is the bug from my code to implement
shortcuts for sessions.
Have you noticed any other oddities with the shortcuts?
Comment 2 Mikolaj Machowski 2004-12-19 13:41:53 UTC
> Mikolaj, can you test this patch?  Is is the bug from my code to
> implement shortcuts for sessions.
> Have you noticed any other oddities with the shortcuts?

WORKSFORME ;)


Comment 3 Kurt Hindenburg 2004-12-19 17:34:36 UTC
CVS commit by hindenburg: 

BUG: 95407

Fix deleted session shortcuts are remembered.


  M +25 -10    konsole.cpp   1.491
  M +1 -0      konsole.h   1.189


--- kdebase/konsole/konsole/konsole.cpp  #1.490:1.491
@@ -263,4 +263,5 @@ Konsole::Konsole(const char* name, const
 ,m_removeSessionButton(0)
 ,sessionNumberMapper(0)
+,sl_sessionShortCuts(0)
 {
   isRestored = b_inRestore;
@@ -367,6 +368,4 @@ Konsole::Konsole(const char* name, const
 Konsole::~Konsole()
 {
-    delete sessionNumberMapper;
-
     while (detached.count()) {
         KonsoleChild* child=detached.first();
@@ -2092,19 +2091,35 @@ void Konsole::reparseConfiguration()
           this, SLOT( newSessionTabbar( int ) ) );
 
-  // Should be a better way to traverse KActionCollection
+  sl_sessionShortCuts.clear();
+  buildSessionMenus();
+
+  // FIXME: Should be a better way to traverse KActionCollection
   uint count = m_shortcuts->count();
   for ( uint i = 0; i < count; i++ )
   {
     KAction* action = m_shortcuts->action( i );
-    // Delete all session shortcuts...
+    bool b_foundSession = false;
     if ( QString(action->name()).startsWith("SSC_") ) {
+      QString name = QString(action->name());
+
+      // Check to see if shortcut's session has been loaded.
+      for ( QStringList::Iterator it = sl_sessionShortCuts.begin(); it != sl_sessionShortCuts.end(); ++it ) {
+        if ( QString::compare( *it, name ) == 0 ) {
+          b_foundSession = true;
+          break;
+        }
+      }
+      if ( ! b_foundSession ) {
+//       kdDebug()<< "Session "<<name<<" is not valid anymore... deleting"<<endl;
+        action->setShortcut( KShortcut() );   // Clear shortcut
+        m_shortcuts->writeShortcutSettings();
       delete action; // Remove Action and Accel
-      if ( i == 0 ) i = 0;
+        if ( i == 0 ) i = 0;     // Reset index
       else i--;
       count--; // = m_shortcuts->count();
     }
   }
+  }
 
-  buildSessionMenus();
   m_shortcuts->readShortcutSettings();
 
@@ -3340,5 +3355,5 @@ void Konsole::addSessionCommand(const QS
   name.prepend("SSC_");  // Allows easy searching for Session ShortCuts
   name.replace(" ", "_");
-  QString cmd_id = QString("%1").arg(cmd_serial);
+  sl_sessionShortCuts << name;
 
   // Is there already this shortcut?

--- kdebase/konsole/konsole/konsole.h  #1.188:1.189
@@ -419,4 +419,5 @@ private:
 
   QSignalMapper* sessionNumberMapper;
+  QStringList    sl_sessionShortCuts;
 };