Bug 100432

Summary: closing by CTRL+W crashes when no tabs are open
Product: [Applications] konversation Reporter: Mike Massonnet <mike.massonnet>
Component: generalAssignee: Konversation Developers <konversation-devel>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Mike Massonnet 2005-02-28 12:53:46 UTC
Version:           0.15.1 (using KDE 3.3.2,  (3.1))
Compiler:          gcc version 3.3.5 (Debian 1:3.3.5-6)
OS:                Linux (i686) release 2.6.10-1-k7

It is easy, when no tabs are open, I type CTRL+W and it craches Konversation.
Comment 1 Peter Simonsson 2005-02-28 14:17:42 UTC
CVS commit by psn: 

Don't crash when trying to close tabs that doesn't exist
BUG:100432


  M +10 -4     ledtabwidget.cpp   1.37


--- kdeextragear-2/konversation/konversation/ledtabwidget.cpp  #1.36:1.37
@@ -153,9 +153,15 @@ void LedTabWidget::tabClosed(int id)
 {
   //  if id is -1 then get identifier for currently visible tab
-  if(id==-1) id=tabBar()->tab(tabBar()->currentTab())->identifier();
+  if(id == -1) {
+    id = tabBar()->currentTab();
+  }
 
-  LedTab* tab=tabBar()->tab(id);
-  if(tab==0) kdWarning() << "LedTabWidget::closeTab(): tab==0!" << endl;
-  else emit closeTab(tab->getWidget());
+  LedTab* tab = tabBar()->tab(id);
+
+  if(tab == 0) {
+    kdWarning() << "LedTabWidget::closeTab(): tab == 0!" << endl;
+  } else {
+    emit closeTab(tab->getWidget());
+  }
 }
 


Comment 2 Peter Simonsson 2010-07-01 15:59:56 UTC
commit ebbdf541276ff0855d5b1003c6c11bf04266dde9
Author: Peter Simonsson <peter.simonsson@gmail.com>
Date:   Mon Feb 28 13:17:34 2005 +0000

    Don't crash when trying to close tabs that doesn't exist
    BUG:100432
    
    svn path=/trunk/kdeextragear-2/konversation/; revision=393786

diff --git a/konversation/ledtabwidget.cpp b/konversation/ledtabwidget.cpp
index 755d0a9..507bcd4 100644
--- a/konversation/ledtabwidget.cpp
+++ b/konversation/ledtabwidget.cpp
@@ -152,11 +152,17 @@ void LedTabWidget::moveTabToIndex(int oldIndex,int newIndex)
 void LedTabWidget::tabClosed(int id)
 {
   //  if id is -1 then get identifier for currently visible tab
-  if(id==-1) id=tabBar()->tab(tabBar()->currentTab())->identifier();
+  if(id == -1) {
+    id = tabBar()->currentTab();
+  }
 
-  LedTab* tab=tabBar()->tab(id);
-  if(tab==0) kdWarning() << "LedTabWidget::closeTab(): tab==0!" << endl;
-  else emit closeTab(tab->getWidget());
+  LedTab* tab = tabBar()->tab(id);
+
+  if(tab == 0) {
+    kdWarning() << "LedTabWidget::closeTab(): tab == 0!" << endl;
+  } else {
+    emit closeTab(tab->getWidget());
+  }
 }
 
 void LedTabWidget::tabClosed()