Results 1 to 1 of 1

Thread: When QFile writes to a file, the contents of the file are sometimes incorrect.

  1. #1
    Join Date
    Jun 2024
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Question When QFile writes to a file, the contents of the file are sometimes incorrect.

    I'm using qt5.9.0 MinGW 32bit running under windows
    I have a program that receives data from a tcp socket and then writes it to a file. I used to have no problem with it, but recently suddenly the data written to the file may be incorrect, and the logic for writing it is very simple:

    QCryptographicHash n_hash(QCryptographicHash::Md5);

    while (bytesReceived < totalBytes){
    .....
    if (m_sockfd->waitForReadyRead(10000)){
    QByteArray data = m_sockfd->readAll();
    write_data = chunkFile.write(data);
    ......
    }

    n_hash.addData(data);
    ....
    }

    Of course I've left out some of the logic, the file close and flush I have called

    In order to verify the data from the tcp, I specifically on the data stream md5 checksum, every time the checksum is the correct md5, but write the file will always appear to have a small part of the data is wrong!

    And the strangest thing is, if I write another file at the same time to compare, then when the first file is wrong, the second file is right, but of course both are wrong, which is very strange to me!

    Then I used beyond compare to compare the correct and incorrect file data and didn't find any pattern, so I hope I can get some help!

    And it seems to work fine for me to receive files using other machines, only one win10 machine has this problem

    err.jpg
    Last edited by Kefear; 1st June 2024 at 07:14.

Similar Threads

  1. Incorrect .ELF file generated
    By MadMike in forum General Programming
    Replies: 1
    Last Post: 4th November 2020, 10:52
  2. Replies: 1
    Last Post: 22nd July 2015, 23:01
  3. Replies: 0
    Last Post: 23rd December 2013, 12:13
  4. Replies: 3
    Last Post: 28th March 2009, 16:37
  5. Replies: 3
    Last Post: 23rd June 2006, 18:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.