Should KFilterDev::readData() and writeData() be protected access?

Thiago Macieira thiago at kde.org
Thu May 31 12:04:15 BST 2007


Richard Dale said:
> In QIODevice the readData() and writeData() pure virtual methods have
> protected access:
>
> protected:
> #ifdef QT_NO_QOBJECT
>     QIODevice(QIODevicePrivate &dd);
> #else
>     QIODevice(QIODevicePrivate &dd, QObject *parent = 0);
> #endif
>     virtual qint64 readData(char *data, qint64 maxlen) = 0;
>     virtual qint64 readLineData(char *data, qint64 maxlen);
>     virtual qint64 writeData(const char *data, qint64 len) = 0;
>
> KFilterDev subclasses QIODevice, and implements these methods with access
> public, but shouldn't they be protected?

Yes. My guess is someone ported the old readBlock, readLine and writeBlock
public virtual methods from Qt3's QIODevice, renamed them and forgot to
make them protected.

The *Data versions must not be called directly in a QIODevice because they
skip the QIODevice's buffering system and may lead to inconsistent
reading.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358






More information about the kde-core-devel mailing list