[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdepim/enterprise4/kdepimlibs/qgpgme
From: Marc Mutz <mutz () kde ! org>
Date: 2009-12-04 10:33:27
Message-ID: 1259922807.199435.8912.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1058343 by mutz:
QIODeviceDataProvider: undo the last change for QIODevices other than QProcess
The new/old code broke other QIODevices (most notably KDPipeIODevice).
M +11 -14 dataprovider.cpp
M +2 -1 dataprovider.h
--- branches/kdepim/enterprise4/kdepimlibs/qgpgme/dataprovider.cpp #1058342:1058343
@@ -135,7 +135,8 @@
QIODeviceDataProvider::QIODeviceDataProvider( const boost::shared_ptr<QIODevice> & \
io ) : GpgME::DataProvider(),
mIO( io ),
- mErrorOccurred( false )
+ mErrorOccurred( false ),
+ mHaveQProcess( qobject_cast<QProcess*>( io.get() ) )
{
assert( mIO );
}
@@ -152,14 +153,6 @@
}
}
-namespace {
- struct Enabler {
- explicit Enabler( bool* b_ ) : b( b_) {}
- ~Enabler() { if ( b ) *b = true; }
- bool* const b;
- };
-}
-
static qint64 blocking_read( const boost::shared_ptr<QIODevice> & io, char * buffer, \
qint64 maxSize ) { while ( !io->bytesAvailable() )
if ( !io->waitForReadyRead( -1 ) )
@@ -186,19 +179,23 @@
errno = EINVAL;
return -1;
}
+ const qint64 numRead = mHaveQProcess
+ ? blocking_read( mIO, static_cast<char*>(buffer), bufSize )
+ : mIO->read( static_cast<char*>(buffer), bufSize ) ;
+
//workaround: some QIODevices (known example: QProcess) might not return 0 (EOF), \
but immediately -1 when finished. If no //errno is set, gpgme doesn't detect the \
error and loops forever. So return 0 on the very first -1 in case errno is 0
- const qint64 numRead = blocking_read( mIO, static_cast<char*>(buffer), bufSize );
-
- Enabler en( numRead < 0 ? &mErrorOccurred : 0 );
+ ssize_t rc = numRead;
if ( numRead < 0 && errno == 0 ) {
if ( mErrorOccurred )
errno = EIO;
else
- return 0;
+ rc = 0;
}
- return numRead;
+ if ( numRead < 0 )
+ mErrorOccurred = true;
+ return rc;
}
ssize_t QIODeviceDataProvider::write( const void * buffer, size_t bufSize ) {
--- branches/kdepim/enterprise4/kdepimlibs/qgpgme/dataprovider.h #1058342:1058343
@@ -83,7 +83,8 @@
private:
const boost::shared_ptr<QIODevice> mIO;
- bool mErrorOccurred;
+ bool mErrorOccurred : 1;
+ bool mHaveQProcess : 1;
};
} // namespace QGpgME
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic