summaryrefslogtreecommitdiff
path: root/qmake/tools/qbuffer.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qbuffer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qbuffer.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/qmake/tools/qbuffer.cpp b/qmake/tools/qbuffer.cpp
index b213dd9..0fc90e4 100644
--- a/qmake/tools/qbuffer.cpp
+++ b/qmake/tools/qbuffer.cpp
@@ -135,130 +135,130 @@ QBuffer::~QBuffer()
Replaces the buffer's contents with \a buf and returns TRUE.
Does nothing (and returns FALSE) if isOpen() is TRUE.
Note that if you open the buffer in write mode (\c IO_WriteOnly or
IO_ReadWrite) and write something into the buffer, \a buf is also
modified because QByteArray is an explicitly shared class.
\sa buffer(), open(), close()
*/
bool QBuffer::setBuffer( QByteArray buf )
{
if ( isOpen() ) {
#if defined(QT_CHECK_STATE)
qWarning( "QBuffer::setBuffer: Buffer is open" );
#endif
return FALSE;
}
a = buf;
a_len = a.size();
a_inc = (a_len > 512) ? 512 : a_len; // initial increment
if ( a_inc < 16 )
a_inc = 16;
ioIndex = 0;
return TRUE;
}
/*!
\fn QByteArray QBuffer::buffer() const
Returns this buffer's byte array.
\sa setBuffer()
*/
/*!
\reimp
Opens the buffer in mode \a m. Returns TRUE if successful;
otherwise returns FALSE. The buffer must be opened before use.
The mode parameter \a m must be a combination of the following flags.
\list
\i \c IO_ReadOnly opens the buffer in read-only mode.
\i \c IO_WriteOnly opens the buffer in write-only mode.
\i \c IO_ReadWrite opens the buffer in read/write mode.
\i \c IO_Append sets the buffer index to the end of the buffer.
\i \c IO_Truncate truncates the buffer.
\endlist
\sa close(), isOpen()
*/
bool QBuffer::open( int m )
{
if ( isOpen() ) { // buffer already open
#if defined(QT_CHECK_STATE)
qWarning( "QBuffer::open: Buffer already open" );
#endif
return FALSE;
}
setMode( m );
if ( m & IO_Truncate ) { // truncate buffer
- a.resize( 0 );
- a_len = 0;
+ a.resize( 1 );
+ a_len = 1;
}
if ( m & IO_Append ) { // append to end of buffer
ioIndex = a.size();
} else {
ioIndex = 0;
}
a_inc = 16;
setState( IO_Open );
setStatus( 0 );
return TRUE;
}
/*!
\reimp
Closes an open buffer.
\sa open()
*/
void QBuffer::close()
{
if ( isOpen() ) {
setFlags( IO_Direct );
ioIndex = 0;
a_inc = 16;
}
}
/*!
\reimp
The flush function does nothing for a QBuffer.
*/
void QBuffer::flush()
{
return;
}
/*!
\fn QIODevice::Offset QBuffer::at() const
\reimp
*/
/*!
\fn QIODevice::Offset QBuffer::size() const
\reimp
*/
/*!
\reimp
*/
bool QBuffer::at( Offset pos )
{
#if defined(QT_CHECK_STATE)
if ( !isOpen() ) {
qWarning( "QBuffer::at: Buffer is not open" );
return FALSE;
}