KDE4 porting mailing list?

Simon Hausmann hausmann at kde.org
Mon Nov 28 06:47:37 GMT 2005


On Sunday 27 November 2005 18:39, Stefan Winter wrote:
> Hi,
>
> apologies for the dumb "I-can't-use-Google" question: is there any mailing
> list about the current status of porting KDE to Qt4, ideally where I could
> place questions about specific caveats?
> In case there isn't, my current problem with getting kdenetwork/wifi
> KWiFiManager to work properly again is:
>
> QFile apparently doesn't like reading from /proc any more. When I
> open /proc/net/dev with QIODevice::readOnly, I get pos()=0, atEnd=true and
> thus can't read anything out of the file. I've read about QIODevice
> changing behaviour wrt to sequential/non-sequential files, but I didn't
> find a solution to deal with the file properly.
>
> The code fragment and debug output for this problem is:
>
> QFile procnetdev("/proc/net/dev");
> if ( !procnetdev.open (QIODevice::ReadOnly) ) {
>   kdDebug () << "Unable to open /proc/net/dev" << endl;
>   return liste;
> };
> kdDebug () << "Autodetecting, QFile pos() = " << procnetdev.pos() << endl;
> kdDebug () << "QFile thinks it has"
>                  << (procnetdev.atEnd() ? " " : " not ")
>                  << "reached the end." << endl;
>
> kwifimanager: Autodetecting, QFile pos() = 0
> kwifimanager: QFile thinks it has reached the end.

The reason for this change is because in Qt 3 QFile::atEnd() was marked const 
but it actually behind the caller's back tried to read a byte from the given 
file. In this special case that worked, that's why it returned false. But 
otherwise I would say that one wouldn't expect 'atEnd() const' to implicitly 
read from the device.

In Qt 4 atEnd() is simply 'return size() == pos();', where size() is zero in 
your case because the kernel marks /proc/net/dev as regular file but reports 
zero bytes as size in stat.

IMHO it's a question of broken behavior (reading inside 'atEnd() const') 
versus supporting non-standard files (/proc/*) :-/

So if you're using QTextStream to read from the file then in this case you 
have to read the contents manually first ;(

Simon




More information about the kde-core-devel mailing list