| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
Hi all,
i'm trying to use a QSocketNotifier to watch a file for data to be read.
But my connected slot is called over and over again even though there are no
bytes available and i'm reading away all the data anyway.
QFile( path );
file.open( QIODevice::ReadOnly );
QSocketNotifier *notifier = new QSocketNotifier( file.handle(),
QSocketNotifier::Read, this );
connect(m_notifier, SIGNAL(activated(int)), this, SLOT(slotReadyRead(int)));
void slotReadyRead(int) {
file.readAll();
...
}
This is basicaly what i do. Documentation of QSocketNotifier gives no hints
on the problem.
I'm developing a non-gui application under linux.
Any ideas?
....Volker
--
[ signature omitted ]
On Monday 04 February 2008 11:27:54 Volker wrote:
> Hi all,
> i'm trying to use a QSocketNotifier to watch a file for data to be read.
> But my connected slot is called over and over again even though there are
> no bytes available and i'm reading away all the data anyway.
>
> QFile( path );
> file.open( QIODevice::ReadOnly );
> QSocketNotifier *notifier = new QSocketNotifier( file.handle(),
> QSocketNotifier::Read, this );
> connect(m_notifier, SIGNAL(activated(int)), this,
> SLOT(slotReadyRead(int)));
>
> void slotReadyRead(int) {
> file.readAll();
> ...
> }
>
> This is basicaly what i do. Documentation of QSocketNotifier gives no hints
> on the problem.
> I'm developing a non-gui application under linux.
>
>
> Any ideas?
QSocketNotifier's behaviour on files and other random-access devices is not
documented. It's entirely unsupported.
You shouldn't be using it for anything other than a socket. Using it on pipes
or character-special devices may work, but is also unsupported.
--
[ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
Thiago Macieira 04.02.2008 14:40:
> On Monday 04 February 2008 11:27:54 Volker wrote:
> > Hi all,
> > i'm trying to use a QSocketNotifier to watch a file for data to be read.
> > But my connected slot is called over and over again even though there are
> > no bytes available and i'm reading away all the data anyway.
> >
> > QFile( path );
> > file.open( QIODevice::ReadOnly );
> > QSocketNotifier *notifier = new QSocketNotifier( file.handle(),
> > QSocketNotifier::Read, this );
> > connect(m_notifier, SIGNAL(activated(int)), this,
> > SLOT(slotReadyRead(int)));
> >
> > void slotReadyRead(int) {
> > file.readAll();
> > ...
> > }
> >
> > This is basicaly what i do. Documentation of QSocketNotifier gives no
> > hints on the problem.
> > I'm developing a non-gui application under linux.
> >
> >
> > Any ideas?
>
> QSocketNotifier's behaviour on files and other random-access devices is not
> documented. It's entirely unsupported.
>
> You shouldn't be using it for anything other than a socket. Using it on
> pipes or character-special devices may work, but is also unsupported.
I see. Maybe this remark should go in the docs of QSocketNotifier.
Is there a recommended method for watching a file?
In my case its a logfile which is written by another process.
--
[ signature omitted ]
On Monday 04 February 2008 15:07:05 Volker wrote: > I see. Maybe this remark should go in the docs of QSocketNotifier. Isn't the fact that it is called *socket* notifier enough? Anything else is platform-specific behaviour. And undocumented stuff is not supported. -- [ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.
Volker wrote:
> Is there a recommended method for watching a file?
> In my case its a logfile which is written by another process.
Will the QFileSystemWatcher do what you want?
http://doc.trolltech.com/qfilesystemwatcher.html
D
--
[ signature omitted ]