From 2b7ee6fa74c528c312c1c205ade492165ac057bb Mon Sep 17 00:00:00 2001 From: Till Adam Date: Sat, 24 May 2008 15:33:45 +0000 Subject: [PATCH] At least on OSX and Windows the job can't be accessed after the nested event loop returns, as the primary event loop will be entered from quit(), which processes delete events (from deleteLater()) which nukes the job. Cache the audit log in the executor to work around this. Scary problem, this is probably relied upon a lot, with KJobs all over the place. svn path=/trunk/KDE/kdepim/; revision=812090 --- kleojobexecutor.cpp | 20 ++++++++++++++++++++ kleojobexecutor.h | 3 +++ objecttreeparser.cpp | 5 +++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/kleojobexecutor.cpp b/kleojobexecutor.cpp index 11507b81b..6205b5c0f 100644 --- a/kleojobexecutor.cpp +++ b/kleojobexecutor.cpp @@ -28,6 +28,8 @@ #include #include +#include + using namespace KMail; using namespace Kleo; using namespace GpgME; @@ -104,15 +106,21 @@ GpgME::ImportResult KleoJobExecutor::exec(Kleo::ImportJob* job, const QByteArray void KleoJobExecutor::verificationResult(const GpgME::VerificationResult & result) { kDebug() << "Detached verification job finished"; + Kleo::Job * job = dynamic_cast( sender() ); + assert(job); mVerificationResult = result; + mAuditLog = job->auditLogAsHtml(); mEventLoop->quit(); } void KleoJobExecutor::verificationResult(const GpgME::VerificationResult & result, const QByteArray & plainText) { kDebug() << "Opaque verification job finished"; + Kleo::Job * job = dynamic_cast( sender() ); + assert(job); mVerificationResult = result; mData = plainText; + mAuditLog = job->auditLogAsHtml(); mEventLoop->quit(); } @@ -122,16 +130,28 @@ void KleoJobExecutor::decryptResult( const QByteArray & plainText ) { kDebug() << "Decryption job finished"; + Kleo::Job * job = dynamic_cast( sender() ); + assert(job); mVerificationResult = verificationresult; mDecryptResult = decryptionresult; mData = plainText; + mAuditLog = job->auditLogAsHtml(); mEventLoop->quit(); } void KleoJobExecutor::importResult(const GpgME::ImportResult & result) { + Kleo::Job * job = dynamic_cast( sender() ); + assert(job); mImportResult = result; + mAuditLog = job->auditLogAsHtml(); mEventLoop->quit(); } + +QString KleoJobExecutor::auditLogAsHtml() const +{ + return mAuditLog; +} + #include "kleojobexecutor.moc" diff --git a/kleojobexecutor.h b/kleojobexecutor.h index 1562eb9de..2ac258c77 100644 --- a/kleojobexecutor.h +++ b/kleojobexecutor.h @@ -58,6 +58,8 @@ class KleoJobExecutor : public QObject QByteArray &plainText ); GpgME::ImportResult exec( Kleo::ImportJob* job, const QByteArray &certData ); + QString auditLogAsHtml() const; + private slots: void verificationResult( const GpgME::VerificationResult &result ); void verificationResult( const GpgME::VerificationResult &result, const QByteArray &plainText ); @@ -72,6 +74,7 @@ class KleoJobExecutor : public QObject GpgME::DecryptionResult mDecryptResult; GpgME::ImportResult mImportResult; QByteArray mData; + QString mAuditLog; }; } diff --git a/objecttreeparser.cpp b/objecttreeparser.cpp index a0402c53c..7d9b0cd2c 100644 --- a/objecttreeparser.cpp +++ b/objecttreeparser.cpp @@ -104,6 +104,7 @@ using KPIMUtils::LinkLocator; #include #include #include +#include // other headers #include @@ -449,7 +450,7 @@ namespace KMail { if ( Kleo::VerifyDetachedJob * const job = cryptProto->verifyDetachedJob() ) { KleoJobExecutor executor; result = executor.exec( job, signaturetext, cleartext ); - messagePart.auditLog = job->auditLogAsHtml(); + messagePart.auditLog = executor.auditLogAsHtml(); } else { cryptPlugError = CANT_VERIFY_SIGNATURES; } @@ -457,7 +458,7 @@ namespace KMail { if ( Kleo::VerifyOpaqueJob * const job = cryptProto->verifyOpaqueJob() ) { KleoJobExecutor executor; result = executor.exec( job, signaturetext, cleartext ); - messagePart.auditLog = job->auditLogAsHtml(); + messagePart.auditLog = executor.auditLogAsHtml(); } else { cryptPlugError = CANT_VERIFY_SIGNATURES; }