From bd2bfe6e2cf2d58fdc5a8ff7d9fb3ecf8a6848c1 Mon Sep 17 00:00:00 2001 From: Till Adam Date: Sat, 17 Jul 2004 14:29:53 +0000 Subject: [PATCH] Don't crash when trying to create the imap resource folders on an online imap account. Set the account of the newly created folders. This fixes the crash, but the folders are still not created properly, especially on startup, as the account is potentially not connected yet. Will look into that next. CCMAIL: 85298-done@bugs.kde.org svn path=/trunk/kdepim/; revision=330304 --- kmailicalifaceimpl.cpp | 18 +++++++++++------- kmailicalifaceimpl.h | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/kmailicalifaceimpl.cpp b/kmailicalifaceimpl.cpp index 6b71b243b..5e37ddc10 100644 --- a/kmailicalifaceimpl.cpp +++ b/kmailicalifaceimpl.cpp @@ -687,6 +687,7 @@ void KMailICalIfaceImpl::readConfig() " and the IMAP resource will be disabled").arg(folderParent!=0?folderParent->name():folderParentDir->name()), i18n("IMAP Resource Folders") ) == KMessageBox::No ) { mUseResourceIMAP = false; + mFolderParentDir = 0; mFolderParent = 0; reloadFolderTree(); return; @@ -694,7 +695,7 @@ void KMailICalIfaceImpl::readConfig() } // Check if something changed - if( mUseResourceIMAP && !makeSubFolders && mFolderParent == folderParentDir + if( mUseResourceIMAP && !makeSubFolders && mFolderParentDir == folderParentDir && mFolderType == folderType ) { // Nothing changed if ( hideFolders != mHideFolders ) { @@ -708,7 +709,8 @@ void KMailICalIfaceImpl::readConfig() // Make the new settings work mUseResourceIMAP = true; mFolderLanguage = folderLanguage; - mFolderParent = folderParentDir; + mFolderParentDir = folderParentDir; + mFolderParent = folderParent; mFolderType = folderType; mHideFolders = hideFolders; @@ -757,15 +759,17 @@ KMFolder* KMailICalIfaceImpl::initFolder( KFolderTreeItem::Type itemType, // Find the folder KMFolder* folder = 0; - KMFolderNode* node = mFolderParent->hasNamedFolder( folderName( itemType ) ); + KMFolderNode* node = mFolderParentDir->hasNamedFolder( folderName( itemType ) ); if( node && !node->isDir() ) folder = static_cast(node); if( !folder ) { // The folder isn't there yet - create it folder = - mFolderParent->createFolder( folderName( itemType ), false, type ); - if( mFolderType == KMFolderTypeImap ) - static_cast( folder->storage() )-> - createFolder( folderName( itemType ) ); + mFolderParentDir->createFolder( folderName( itemType ), false, type ); + if( mFolderType == KMFolderTypeImap ) { + KMFolderImap* parentFolder = static_cast( mFolderParent->storage() ); + parentFolder->createFolder( folderName( itemType ) ); + static_cast( folder->storage() )->setAccount( parentFolder->account() ); + } } if( folder->canAccess() != 0 ) { diff --git a/kmailicalifaceimpl.h b/kmailicalifaceimpl.h index ed6c026d9..581e05f67 100644 --- a/kmailicalifaceimpl.h +++ b/kmailicalifaceimpl.h @@ -161,7 +161,8 @@ private: unsigned int mFolderLanguage; - KMFolderDir* mFolderParent; + KMFolderDir* mFolderParentDir; + KMFolder* mFolderParent; KMFolderType mFolderType; // groupware folder icons: