Bug 85803 - KMail crashes at startup with more than one IMAP account
Summary: KMail crashes at startup with more than one IMAP account
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: IMAP (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-23 17:58 UTC by Andre Woebbeking
Modified: 2007-09-14 12:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
startupfix.diff (5.61 KB, text/x-diff)
2004-08-05 23:57 UTC, Carsten Burghardt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Woebbeking 2004-07-23 17:58:25 UTC
Version:           unknown (using KDE 3.2.92 (3.3 beta2), compiled sources)
Compiler:          gcc version 3.4.1 (Debian 3.4.1-2)
OS:                Linux (i686) release 2.6.7-1-k7

Hi,

I've two IMAP accounts. If I start KMail it asks for the passwords of the accounts. If I enter them fast enough KMail crashes:

3  0x408a8684 in KListView::dragEnabled (this=0x0)
    at /src/kde/kdelibs/kdeui/klistview.cpp:1161
#4  0x408abf48 in KListViewItem::init (this=0x85429b8)
    at /src/kde/kdelibs/kdeui/klistview.cpp:2117
#5  0x408ace8b in KListViewItem (this=0x85429b8, parent=0x0, label1=)
    at /src/kde/kdelibs/kdeui/klistview.cpp:2088
#6  0x41ea1e9b in KFolderTreeItem (this=0x85429b8, parent=0x0, label=@0x0,
    protocol=Imap, type=Inbox, unread=0, total=0)
    at /src/kde/kdepim/libkdenetwork/kfoldertree.cpp:26
#7  0x420d4a8d in KMFolderTreeItem (this=0x8542990, parent=0x0,
    name=@0xbfffef90, folder=0x0) at /src/kde/kdepim/kmail/kmfoldertree.cpp:69
#8  0x420dc211 in KMFolderTree::addDirectory (this=0x8407cd0, fdir=0x8353800,
    parent=0x8537270) at /src/kde/kdepim/kmail/kmfoldertree.cpp:556
#9  0x420dc2d7 in KMFolderTree::addDirectory (this=0x8407cd0, fdir=0x831afdc,
    parent=0x0) at kmfolder.h:95
#10 0x420d76b8 in KMFolderTree::reload (this=0x8407cd0, openFolders=false)
    at /src/kde/kdepim/kmail/kmfoldertree.cpp:443
#11 0x422a9513 in KMMainWidget::slotShowStartupFolder (this=0x83a0ec8)
    at /src/kde/kdepim/kmail/kmmainwidget.cpp:3170
Comment 1 Urs Joss 2004-08-04 10:24:08 UTC
Same result here (KDE 3.3.0_beta2, Gentoo linux), even though maybe different cause:

Using host libthread_db library "/lib/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 18320)]
0x419f8008 in waitpid () from /lib/libpthread.so.0
#0  0x419f8008 in waitpid () from /lib/libpthread.so.0
#1  0x40c17320 in __JCR_LIST__ () from /usr/kde/3.3/lib/libkdecore.so.4
#2  0x40b3c52a in KCrash::defaultCrashHandler(int) ()
   from /usr/kde/3.3/lib/libkdecore.so.4
#3  0x40c1d5e4 in kde_malloc_is_used () from /usr/kde/3.3/lib/libkdecore.so.4
#4  0x00000010 in ?? ()
#5  0x40c1d600 in spinlock () from /usr/kde/3.3/lib/libkdecore.so.4
#6  0x40c17320 in __JCR_LIST__ () from /usr/kde/3.3/lib/libkdecore.so.4
#7  0x40c1d5e4 in kde_malloc_is_used () from /usr/kde/3.3/lib/libkdecore.so.4
#8  0x00000001 in ?? ()
Comment 2 Carsten Burghardt 2004-08-04 11:11:14 UTC
@Urs Joss: please compile kmail with --enable-debug=yes to get a better backtrace.
Comment 3 Andre Woebbeking 2004-08-04 17:01:00 UTC
This one if from one day old CVS:

#3  0x410f8236 in QListViewItem (this=0x8578798, parent=0x84d8468, label1=)
    at widgets/qlistview.cpp:592
#4  0x408b68d6 in KListViewItem (this=0x8578798, parent=0x0, label1=)
    at /src/kde/kdelibs/kdeui/klistview.cpp:2092
#5  0x41eb7ecb in KFolderTreeItem (this=0x8578798, parent=0x0, label=@0x0, 
    protocol=Imap, type=Inbox, unread=0, total=0)
    at /src/kde/kdepim/libkdenetwork/kfoldertree.cpp:26
#6  0x42100bcd in KMFolderTreeItem (this=0x8578770, parent=0x0, 
    name=@0xbfffef90, folder=0x0) at /src/kde/kdepim/kmail/kmfoldertree.cpp:69
#7  0x42108351 in KMFolderTree::addDirectory (this=0x8432da8, fdir=0x834ccb0, 
    parent=0x84d8440) at /src/kde/kdepim/kmail/kmfoldertree.cpp:556
#8  0x42108417 in KMFolderTree::addDirectory (this=0x8432da8, fdir=0x834adbc, 
    parent=0x0) at kmfolder.h:95
#9  0x421037f8 in KMFolderTree::reload (this=0x8432da8, openFolders=false)
    at /src/kde/kdepim/kmail/kmfoldertree.cpp:443
#10 0x422d5d53 in KMMainWidget::slotShowStartupFolder (this=0x83d5398)
    at /src/kde/kdepim/kmail/kmmainwidget.cpp:3144
Comment 4 Till Adam 2004-08-04 17:32:16 UTC
Andre, does changing the startup folder to something local "fix" the crash?
Comment 5 Andre Woebbeking 2004-08-04 19:07:29 UTC
On Wednesday 04 August 2004 17:32, Till Adam wrote:
> Andre, does changing the startup folder to something local 
> "fix" the crash?

Huh, I didn't know that is possible. Right now I cancel the first IMAP 
login and login when the second login is finished.

Comment 6 Carsten Burghardt 2004-08-05 23:57:26 UTC
Does the attached patch fix the crash (cvs HEAD)?


Created an attachment (id=7014)
startupfix.diff
Comment 7 Andre Woebbeking 2004-08-06 18:11:55 UTC
> Additional Comments From burghardt kde org  2004-08-05 23:57
> Does the attached patch fix the crash (cvs HEAD)?

I started Kontact several times and had no crash with your patch :-)

Comment 8 Carsten Burghardt 2004-08-06 19:39:49 UTC
CVS commit by burghard: 

Do not crash during startup. This patch is rather intrusive but I do not see a chance to fix it without
rewriting some stuff.
It also fixes a bug that I noticed recently: when an imap folder is selected and you expand a different
imap folder the readerwin was cleared.
I will backport this in a minute.
CCMAIL: 85803-done@bugs.kde.org


  M +32 -0     kmfoldertree.cpp   1.314
  M +4 -0      kmfoldertree.h   1.84
  M +13 -21    kmmainwidget.cpp   1.251


--- kdepim/kmail/kmfoldertree.cpp  #1.313:1.314
@@ -245,4 +245,5 @@ KMFolderTree::KMFolderTree( KMMainWidget
   mLastItem = 0;
   mMainWidget = mainWidget;
+  mReloading = false;
 
   addAcceptableDropMimetype(MailListDrag::format(), false);
@@ -424,4 +425,11 @@ void KMFolderTree::updateUnreadAll()
 void KMFolderTree::reload(bool openFolders)
 {
+  if ( mReloading ) {
+    // no parallel reloads are allowed
+    kdDebug(5006) << "KMFolderTree::reload - already reloading" << endl;
+    return;
+  }
+  mReloading = true;
+  
   int top = contentsY();
   mLastItem = 0;
@@ -430,4 +438,6 @@ void KMFolderTree::reload(bool openFolde
     writeIsListViewItemOpen( fti );
   }
+  // remember last
+  KMFolder* last = currentFolder();
   clear();
 
@@ -507,4 +517,12 @@ void KMFolderTree::reload(bool openFolde
   ensureVisible(0, top + visibleHeight(), 0, 0);
   refresh();
+  if ( last )
+  {
+    // if the current folder did not change set it again
+    for ( QListViewItemIterator it( this ) ; it.current() ; ++it )
+      if ( static_cast<KMFolderTreeItem*>( it.current() )->folder() == last )
+        mLastItem = static_cast<KMFolderTreeItem*>( it.current() );
+  }
+  mReloading = false;
 }
 
@@ -1100,4 +1118,6 @@ void KMFolderTree::writeIsListViewItemOp
 void KMFolderTree::cleanupConfigFile()
 {
+  if ( childCount() == 0 )
+    return; // just in case reload wasn't called before
   KConfig* config = KMKernel::config();
   QStringList existingFolders;
@@ -1606,4 +1626,16 @@ void KMFolderTree::slotResetFolderList( 
 }
 
+//-----------------------------------------------------------------------------
+void KMFolderTree::showFolder( KMFolder* folder )
+{
+  if ( !folder ) return;
+  QListViewItem* item = indexOfFolder( folder );
+  if ( item )
+  {
+    doFolderSelected( item );
+    ensureItemVisible( item );
+  }
+}
+
 #include "kmfoldertree.moc"
 

--- kdepim/kmail/kmfoldertree.h  #1.83:1.84
@@ -155,4 +155,7 @@ public:
   KMMainWidget * mainWidget() const { return mMainWidget; }
 
+  /** Select the folder and make sure it's visible */
+  void showFolder( KMFolder* );
+
 signals:
   /** The selected folder has changed */
@@ -311,4 +314,5 @@ private:
   bool mShowPopupAfterDnD;
   KMMainWidget *mMainWidget;
+  bool mReloading;
 };
 

--- kdepim/kmail/kmmainwidget.cpp  #1.250:1.251
@@ -370,11 +369,7 @@ void KMMainWidget::readConfig(void)
     }
 
+    // reload foldertree
     mFolderTree->reload();
-    QListViewItem *qlvi = mFolderTree->indexOfFolder(mFolder);
-    if (qlvi!=0) {
-      mFolderTree->setCurrentItem(qlvi);
-      mFolderTree->setSelected(qlvi,TRUE);
-    }
-
+    mFolderTree->showFolder( mFolder );
 
     // sanders - New code
@@ -3140,13 +3135,4 @@ void KMMainWidget::slotIntro()
 void KMMainWidget::slotShowStartupFolder()
 {
-  if (mFolderTree) {
-    // add the folders
-    mFolderTree->reload();
-    // read the config
-    mFolderTree->readConfig();
-    // get rid of old-folders
-    mFolderTree->cleanupConfigFile();
-  }
-
   connect( kmkernel->filterMgr(), SIGNAL( filterListUpdated() ),
            this, SLOT( initializeFilterActions() ));
@@ -3161,12 +3147,18 @@ void KMMainWidget::slotShowStartupFolder
 
   KMFolder* startup = 0;
-  if (!mStartupFolder.isEmpty()) {
+  if ( !mStartupFolder.isEmpty() ) {
     // find the startup-folder
-    startup = kmkernel->findFolderById(mStartupFolder);
+    startup = kmkernel->findFolderById( mStartupFolder );
   }
-  if (!startup)
+  if ( !startup )
     startup = kmkernel->inboxFolder();
-  mFolderTree->doFolderSelected(mFolderTree->indexOfFolder(startup));
-  mFolderTree->ensureItemVisible(mFolderTree->indexOfFolder(startup));
+
+  if ( mFolderTree ) 
+  {
+    mFolderTree->reload();
+    mFolderTree->showFolder( startup );
+    // get rid of old-folders
+    mFolderTree->cleanupConfigFile();
+  }
 }