[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdepim/enterprise4/kdepimlibs/gpgme++
From: Marc Mutz <mutz () kde ! org>
Date: 2008-05-31 20:39:36
Message-ID: 1212266376.758447.15946.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 814979 by mutz:
++thread-safety for Error, even without changing the interface (it's used all over the place, so adding a \
string to keep the const char * alive for the lifetime of the Error is a quicker solution :/ I reviewed \
all uses of Error::asString() in kdepim to check that this is also a sufficient solution.
M +10 -3 context.cpp
M +4 -1 error.h
--- branches/kdepim/enterprise4/kdepimlibs/gpgme++/context.cpp #814978:814979
@@ -42,8 +42,6 @@
#include <gpgme.h>
-//#include <string>
-//using std::string;
#ifndef NDEBUG
#include <iostream>
using std::cerr;
@@ -57,12 +55,21 @@
return gpg_err_make( (gpg_err_source_t)22, code );
}
+ static void format_error( gpgme_error_t err, std::string & str ) {
+ char buffer[ 1024 ];
+ gpgme_strerror_r( err, buffer, sizeof buffer );
+ buffer[ sizeof buffer - 1 ] = '\0';
+ str = buffer;
+ }
+
const char * Error::source() const {
return gpgme_strsource( (gpgme_error_t)mErr );
}
const char * Error::asString() const {
- return gpgme_strerror( (gpgme_error_t)mErr );
+ if ( mMessage.empty() )
+ format_error( static_cast<gpgme_error_t>( mErr ), mMessage );
+ return mMessage.c_str();
}
int Error::code() const {
--- branches/kdepim/enterprise4/kdepimlibs/gpgme++/error.h #814978:814979
@@ -27,11 +27,13 @@
#include <gpgme++/gpgmefw.h>
#include <gpgme++/gpgme++_export.h>
+#include <string>
+
namespace GpgME {
class GPGMEPP_EXPORT Error {
public:
- explicit Error( unsigned int e=0 ) : mErr( e ) {}
+ explicit Error( unsigned int e=0 ) : mErr( e ), mMessage() {}
const char * source() const;
const char * asString() const;
@@ -50,6 +52,7 @@
operator unspecified_bool_type() const { return mErr && !isCanceled() ? \
&__safe_bool_dummy__::nonnull : 0 ; } private:
unsigned int mErr;
+ mutable std::string mMessage;
};
} // namespace GpgME
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic