Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] How to make a code to wait while a file is written on hard drive?
Forum Updated to NodeBB v4.3 + New Features

[solved] How to make a code to wait while a file is written on hard drive?

Scheduled Pinned Locked Moved General and Desktop
17 Posts 3 Posters 8.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mlong
    wrote on last edited by
    #8

    (Please wrap your code in @ tags.)

    Have you tried running the program under the debugger to find out exactly where the crash is occurring?

    Again, just double checking... this is not running in a separate thread, correct?

    Software Engineer
    My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      peterm
      wrote on last edited by
      #9

      Actually, there is a question about threads, because AppWind::updateImage() is a time consuming routine and is run by a separate thread. Any advice? Thanks.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #10

        Is that separate thread using QPixmaps? If it is, that's going to cause you problems.

        QImages should be safe, if I remember correctly, though.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          peterm
          wrote on last edited by
          #11

          Debugging does not help in this case. When doing debugging step-by-step, then everything goes just fine, no crashes, I think because it's not fast enough. If I allow the code to run then it crashes with the error message "Fatal IO error 11 (Resource temporarily unavailable) on X server", and no other information can be obtained.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            peterm
            wrote on last edited by
            #12

            A separate thread calls AppWind::updateImage(), which in turn calls Tp2dFrame::saveImage(), which gets pixmap and saves it to a file: QPixmap* pm = getPixmap(); pm->save(imageFileName);

            1 Reply Last reply
            0
            • R Offline
              R Offline
              reactive
              wrote on last edited by
              #13

              Then you need a traffic cop so cars don't crash into one another at the intersection. See my links above.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                peterm
                wrote on last edited by
                #14

                I tried to use the safe-thread methods as well, by using QMutexLocker locker(&mutex), but nothing helps. Maybe the problem is that the image changes too fast while the save() operation is still in process. Could it cause a crash?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mlong
                  wrote on last edited by
                  #15

                  Again, if you're using QPixmaps in another thread (or in code that's called from another thread) you're going to have issues, whether you're using mutexes or not.

                  Software Engineer
                  My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    peterm
                    wrote on last edited by
                    #16

                    mlong,
                    I've fixed the problem as you advised: the main thread should operate on QPixmaps. Thank you so much.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mlong
                      wrote on last edited by
                      #17

                      Good deal. Glad to help! Please be sure and edit the title of the thread to add [Solved]. Thanks!

                      Software Engineer
                      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved