Results 1 to 4 of 4

Thread: QFile::copy only copies file after the GUI is closed?

  1. #1
    Join Date
    Feb 2016
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QFile::copy only copies file after the GUI is closed?

    Hi,

    I have a QtConcurrent::run method that copies a pdf file from one directory to the next. This copying is in a separate thread because the pdf files can be quite large and to prevent the main GUI thread from being blocked from doing other tasks.

    Qt Code:
    1. void MainWindow::CopyPDFsToDestDir()
    2. {
    3. //setup srcFile and destFile
    4. ...
    5. QFile::copy(srcFile, destFile);
    6. }
    7.  
    8. QFuture<void> result = QtConcurrent::run(this, &MainWindow::CopyPDFsToDestDir);
    To copy to clipboard, switch view to plain text mode 

    The QtConcurrent::run call is in a loop for x number of files depending on user selections.

    It works great on my linux machine (RedHat) and files are copied one by one, but a customer states that on his linux machine (RedHat), the directory only contains 1-2 pdf files. Only after he closes the GUI, suddenly there are 20+ pdf files.

    It is as if, the copying of pdf files are being buffered and only flushed upon closing of the GUI. Does this make any sense? ....isn't QFile::copy immediate? or perhaps the QtConcurrent::run threading the cause?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QFile::copy only copies file after the GUI is closed?

    How is the function determining which file to copy?

    Is it dequeing filenames from a container? Is that properly protected against concurrent access?

    Do you do anything with "result"?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    bobbayribs (9th December 2016)

  4. #3
    Join Date
    Feb 2016
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFile::copy only copies file after the GUI is closed?

    Quote Originally Posted by anda_skoa View Post
    How is the function determining which file to copy?

    Is it dequeing filenames from a container? Is that properly protected against concurrent access?

    Do you do anything with "result"?

    Cheers,
    _
    Oh my!!! I just got off a screen sharing call with the customer. He was viewing the files in Dolphin browser, which wasn't updating the list of pdf files in real time. (Need to hit F5 to refresh).

    The files were being created this whole time. Spent so many hours debugging and researching.

    Thank you for the suggestions though.

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QFile::copy only copies file after the GUI is closed?

    Customers. Can't live with them, can't live without them. It would be great if we could only sell to people who were qualified to use our software, but then we'd starve.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QFile Copy Video File problem
    By digimonkey in forum Qt Programming
    Replies: 1
    Last Post: 19th February 2015, 07:58
  2. Replies: 1
    Last Post: 20th July 2013, 18:16
  3. QFile::copy copies only 3kb
    By camol in forum Qt Programming
    Replies: 36
    Last Post: 20th April 2011, 19:52
  4. QTemporaryFile and Qfile::copy()
    By ChrisW67 in forum Newbie
    Replies: 2
    Last Post: 23rd April 2009, 23:32
  5. copies file doesn't work well
    By dreamer in forum Qt Programming
    Replies: 3
    Last Post: 10th May 2008, 22:00

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.