[Interest] QFileSystemWatcher and accesing files in monitored directory...

Igor Mironchik igor.mironchik at gmail.com
Mon Aug 31 22:29:33 CEST 2015


Hi,


On 31.08.2015 23:13, John Weeks wrote:
>> On Aug 31, 2015, at 12:49 PM, Igor Mironchik <igor.mironchik at gmail.com> wrote:
>>
>> Pixmap is not null... Image was saved for the half and I read it... Pixmap successfully loaded but draws only first part of the image while the next one is grey...
> I forget how Linux works- can you try opening for write? On the systems I know, you can't open for write from two different processes. If you get an error for writing then the file is still being filled.
>
> Seems like I recall that Linux allows two processes write to file. There must be some way to open a file that excludes other processes, and that it would fail if already open elsewhere.
>
> (Horrible hack ahead) Or get the number of bytes in the file, wait a bit and get the number again. If it changes, it's still being filled.

Even if try to open file in ReadWrite mode it opens successfully...

I changed peace of code to

if( imgFile.open( QIODevice::ReadWrite ) )
     {
         if( !p.loadFromData( imgFile.readAll() ) )
             qDebug() << "loading of" << path << "failed";

         imgFile.close();

         qDebug() << path << "is pixmap null" << p.isNull();
     }

And sometimes I receive: loading failed and pixmap is null. Reloading of 
such images is successfull...

I can't reproduce reading of saved on the half image. May be ReadWrite 
mode has fixed the problem... I do not know.
>
> -John Weeks
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-- 
Best Regards,
Igor Mironchik.




More information about the Interest mailing list