Fixed crash when editing events in korganizer using the kmail-imap resource (kolab issue189).

The mResourceQuiet hack used here (to silence signals from kmfolder) broke
when the KMCommands were made async. Got rid of it, and introduced this instead:
+  // Ignore 'added' notifications for those incidences, we added them ourselves
+  // This is a temporary storage, between addIncidence and slotIncidenceAdded,
+  // which is called a bit later.
+  // We store the KMMessage* since we don't have a serial number yet.
+  QValueList<KMMessage*> mIgnoreAdded;
+  // Ignore 'deleted' notifications for those incidences, we deleted them ourselves
+  // This is a temporary storage, between deleteIncidence and slotIncidenceDeleted,
+  // which is called a bit later.
+  QValueList<Q_UINT32> mIgnoreDeleted;

svn path=/trunk/kdepim/; revision=321475
wilder-work
David Faure 22 years ago
parent bbe3a03b64
commit b3bde7a5ac
  1. 43
      kmailicalifaceimpl.cpp
  2. 13
      kmailicalifaceimpl.h

@ -105,7 +105,7 @@ static KMail::FolderContentsType folderContentsType( const QString& type )
KMailICalIfaceImpl::KMailICalIfaceImpl()
: DCOPObject( "KMailICalIface" ), QObject( 0, "KMailICalIfaceImpl" ),
mContacts( 0 ), mCalendar( 0 ), mNotes( 0 ), mTasks( 0 ), mJournals( 0 ),
mFolderLanguage( 0 ), mUseResourceIMAP( false ), mResourceQuiet( false ),
mFolderLanguage( 0 ), mUseResourceIMAP( false ),
mHideFolders( true )
{
// Listen to config changes
@ -127,8 +127,6 @@ bool KMailICalIfaceImpl::addIncidence( const QString& type,
return false;
bool rc = false;
bool quiet = mResourceQuiet;
mResourceQuiet = true;
// Find the folder
KMFolder* f = folderFromType( type, folder );
@ -151,13 +149,14 @@ bool KMailICalIfaceImpl::addIncidence( const QString& type,
// Mark the message as read and store it in the folder
msg->touch();
//kdDebug(5006) << "addIncidence: will ignore added notification for msg=" << msg << endl;
mIgnoreAdded.append( msg );
f->addMsg( msg );
rc = true;
} else
kdError(5006) << "Not an IMAP resource folder" << endl;
mResourceQuiet = quiet;
return rc;
}
@ -173,8 +172,6 @@ bool KMailICalIfaceImpl::deleteIncidence( const QString& type,
<< uid << " )" << endl;
bool rc = false;
bool quiet = mResourceQuiet;
mResourceQuiet = true;
// Find the folder and the incidence in it
KMFolder* f = folderFromType( type, folder );
@ -189,7 +186,6 @@ bool KMailICalIfaceImpl::deleteIncidence( const QString& type,
} else
kdError(5006) << "Not an IMAP resource folder" << endl;
mResourceQuiet = quiet;
return rc;
}
@ -288,8 +284,6 @@ bool KMailICalIfaceImpl::update( const QString& type, const QString& folder,
kdDebug(5006) << "Update( " << type << ", " << folder << ", " << uid << ")\n";
bool rc = true;
bool quiet = mResourceQuiet;
mResourceQuiet = true;
// Find the folder and the incidence in it
KMFolder* f = folderFromType( type, folder );
@ -310,7 +304,6 @@ bool KMailICalIfaceImpl::update( const QString& type, const QString& folder,
rc = false;
}
mResourceQuiet = quiet;
return rc;
}
@ -318,7 +311,7 @@ bool KMailICalIfaceImpl::update( const QString& type, const QString& folder,
void KMailICalIfaceImpl::slotIncidenceAdded( KMFolder* folder,
Q_UINT32 sernum )
{
if( mResourceQuiet || !mUseResourceIMAP )
if( !mUseResourceIMAP )
return;
QString type = icalFolderType( folder );
@ -332,12 +325,20 @@ void KMailICalIfaceImpl::slotIncidenceAdded( KMFolder* folder,
// Read the iCal or vCard
bool unget = !folder->isMessage( i );
QString s;
if( KMGroupware::vPartFoundAndDecoded( folder->getMsg( i ), s ) ) {
kdDebug(5006) << "Emitting DCOP signal incidenceAdded( " << type
<< ", " << folder->location() << ", " << s << " )" << endl;
incidenceAdded( type, folder->location(), s );
KMMessage* msg = folder->getMsg( i );
QValueList<KMMessage*>::iterator addit = mIgnoreAdded.find( msg );
if ( addit == mIgnoreAdded.end() ) {
if( KMGroupware::vPartFoundAndDecoded( msg, s ) ) {
kdDebug(5006) << "Emitting DCOP signal incidenceAdded( " << type
<< ", " << folder->location() << ", " << s << " )" << endl;
incidenceAdded( type, folder->location(), s );
}
} else {
//kdDebug(5006) << "slotIncidenceAdded: ignoring addition of " << msg << endl;
mIgnoreAdded.remove( addit );
}
if( unget ) folder->unGetMsg(i);
if( unget )
folder->unGetMsg(i);
} else
kdError(5006) << "Not an IMAP resource folder" << endl;
}
@ -346,8 +347,14 @@ void KMailICalIfaceImpl::slotIncidenceAdded( KMFolder* folder,
void KMailICalIfaceImpl::slotIncidenceDeleted( KMFolder* folder,
Q_UINT32 sernum )
{
if( mResourceQuiet || !mUseResourceIMAP )
if( !mUseResourceIMAP )
return;
QValueList<Q_UINT32>::iterator delit = mIgnoreDeleted.find( sernum );
if ( delit != mIgnoreDeleted.end() ) {
//kdDebug(5006) << "slotIncidenceDeleted: ignoring deletion of " << sernum << endl;
mIgnoreDeleted.remove( delit );
return;
}
QString type = icalFolderType( folder );
if( !type.isEmpty() ) {
@ -543,6 +550,8 @@ KMMessage *KMailICalIfaceImpl::findMessageByUID( const QString& uid, KMFolder* f
void KMailICalIfaceImpl::deleteMsg( KMMessage *msg )
{
if( !msg ) return;
//kdDebug(5006) << "deleteMsg: will ignore deleted notification for " << msg->getMsgSerNum() << endl;
mIgnoreDeleted.append( msg->getMsgSerNum() );
( new KMDeleteMsgCommand( msg->parent(), msg ) )->start();
}

@ -119,7 +119,7 @@ public:
static KMMessage* findMessageByUID( const QString& uid, KMFolder* folder );
/** Convenience function to delete a message. */
static void deleteMsg( KMMessage* msg );
void deleteMsg( KMMessage* msg );
bool isEnabled() const { return mUseResourceIMAP; }
@ -164,11 +164,20 @@ private:
KMFolderDir* mFolderParent;
KMFolderType mFolderType;
// Ignore 'added' notifications for those incidences, we added them ourselves
// This is a temporary storage, between addIncidence and slotIncidenceAdded,
// which is called a bit later.
// We store the KMMessage* since we don't have a serial number yet.
QValueList<KMMessage*> mIgnoreAdded;
// Ignore 'deleted' notifications for those incidences, we deleted them ourselves
// This is a temporary storage, between deleteIncidence and slotIncidenceDeleted,
// which is called a bit later.
QValueList<Q_UINT32> mIgnoreDeleted;
// groupware folder icons:
static QPixmap *pixContacts, *pixCalendar, *pixNotes, *pixTasks;
bool mUseResourceIMAP;
bool mResourceQuiet;
bool mHideFolders;
};

Loading…
Cancel
Save