From 2c5a0b4ec6ecd013a4e9105879745ab7cb859ef8 Mon Sep 17 00:00:00 2001 From: ubbo Date: Sun, 30 Jan 2011 02:20:19 +0000 Subject: don't replace text if decryption failed, e.g. there was no text to decrypt git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@459 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- context.cpp | 1 + gpgwin.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/context.cpp b/context.cpp index 736eba5..46dcbc6 100644 --- a/context.cpp +++ b/context.cpp @@ -320,6 +320,7 @@ bool Context::decrypt(const QByteArray &inBuffer, QByteArray *outBuffer) } if (err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { QMessageBox::critical(0, tr("Error decrypting:"), gpgme_strerror(err)); + return false; } //if (err != GPG_ERR_NO_ERROR) diff --git a/gpgwin.cpp b/gpgwin.cpp index 0771e52..45247b2 100644 --- a/gpgwin.cpp +++ b/gpgwin.cpp @@ -503,7 +503,12 @@ void GpgWin::decrypt() QByteArray *decrypted = new QByteArray(); QByteArray text = edit->curTextPage()->toPlainText().toAscii(); // TODO: toUtf8() here? preventNoDataErr(&text); - mCtx->decrypt(text, decrypted); + + // try decrypt, if fail do nothing, especially don't replace text + if(!mCtx->decrypt(text, decrypted)) { + return; + } + ; /** * 1) is it mime (content-type:) * 2) parse header -- cgit v1.2.3