https://bugs.kde.org/show_bug.cgi?id=260751
Tobias Koenig <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED --- Comment #3 from Tobias Koenig <tokoe kde org> 2011-01-02 16:47:01 --- commit e2af53f0794533454a372db970e5d8587294f084 branch master Author: Tobias Koenig <[email protected]> Date: Sun Jan 2 16:33:39 2011 +0100 Do not crash on invalid progress item A KPIM::ProgressItem can be deleted at any time, so keep a QPointer on it and check for validity before accessing it. BUG: 260751 diff --git a/libkdepim/agentprogressmonitor.cpp b/libkdepim/agentprogressmonitor.cpp index 320586a..afb6977 100644 --- a/libkdepim/agentprogressmonitor.cpp +++ b/libkdepim/agentprogressmonitor.cpp @@ -19,9 +19,11 @@ #include "agentprogressmonitor.h" +#include <Akonadi/AgentManager> + #include <KDebug> -#include <Akonadi/AgentManager> +#include <QtCore/QPointer> using namespace Akonadi; using namespace KPIM; @@ -43,7 +45,7 @@ class AgentProgressMonitor::Private AgentProgressMonitor *const q; AgentInstance agent; - ProgressItem *const item; + QPointer<ProgressItem> const item; }; void AgentProgressMonitor::Private::abort() @@ -53,10 +55,12 @@ void AgentProgressMonitor::Private::abort() void AgentProgressMonitor::Private::instanceProgressChanged( const AgentInstance &instance ) { - if( agent == instance ) { + if ( !item ) + return; + + if ( agent == instance ) { agent = instance; -// kDebug() << "Progress changed to" << agent.progress(); - if( agent.progress() >= 0 ) { + if ( agent.progress() >= 0 ) { item->setProgress( agent.progress() ); } } @@ -64,28 +68,25 @@ void AgentProgressMonitor::Private::instanceProgressChanged( const AgentInstance void AgentProgressMonitor::Private::instanceStatusChanged( const AgentInstance &instance ) { - if( agent == instance ) { + if ( !item ) + return; + + if ( agent == instance ) { agent = instance; -// kDebug() << "Status changed to" << agent.status() << "message" << agent.statusMessage(); item->setStatus( agent.statusMessage() ); - switch( agent.status() ) { + switch ( agent.status() ) { case AgentInstance::Idle: - { item->setComplete(); break; - } case AgentInstance::Running: - { break; - } case AgentInstance::Broken: - { item->disconnect( q ); // avoid abort call item->cancel(); item->setComplete(); break; - } - default: Q_ASSERT( false ); + default: + Q_ASSERT( false ); } } } diff --git a/libkdepim/agentprogressmonitor.h b/libkdepim/agentprogressmonitor.h index 30403d2..da3b252 100644 --- a/libkdepim/agentprogressmonitor.h +++ b/libkdepim/agentprogressmonitor.h @@ -40,8 +40,7 @@ class AgentProgressMonitor : public QObject protected: // used by our friend ProgressManager - AgentProgressMonitor( const Akonadi::AgentInstance &agent, - ProgressItem *item ); + AgentProgressMonitor( const Akonadi::AgentInstance &agent, ProgressItem *item ); ~AgentProgressMonitor(); private: @@ -51,7 +50,6 @@ class AgentProgressMonitor : public QObject Q_PRIVATE_SLOT( d, void abort() ) Q_PRIVATE_SLOT( d, void instanceProgressChanged( const Akonadi::AgentInstance& ) ) Q_PRIVATE_SLOT( d, void instanceStatusChanged( const Akonadi::AgentInstance& ) ) - }; } -- Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. _______________________________________________ Kdepim-bugs mailing list [email protected] https://mail.kde.org/mailman/listinfo/kdepim-bugs
