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. Why QFile::close() call QIODevice::close() directly instead of call QFileDevice::close()

Why QFile::close() call QIODevice::close() directly instead of call QFileDevice::close()

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 350 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.
  • HansonH Offline
    HansonH Offline
    Hanson
    wrote on last edited by
    #1

    When I debugged the Qt source code, I found that QFile::close() call QIODevice::close() directly instead of call QFileDevice::close().
    362a3988-2320-4564-8362-bc06e226175b-image.png
    8fc61ed1-69e3-4582-abb2-187b99311791-image.png

    “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.”
    —— Martin Golding

    C 1 Reply Last reply
    0
    • HansonH Hanson

      When I debugged the Qt source code, I found that QFile::close() call QIODevice::close() directly instead of call QFileDevice::close().
      362a3988-2320-4564-8362-bc06e226175b-image.png
      8fc61ed1-69e3-4582-abb2-187b99311791-image.png

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      AFAICT QFile does not override QFileDevice::close() so QFile::close() is QFileDevice::close(). QFileDevice::close() calls QIODevice::close() after flush().

      Perhaps you can identify where the QFile source code calls QIODevice::close() directly.

      HansonH 1 Reply Last reply
      0
      • C ChrisW67

        AFAICT QFile does not override QFileDevice::close() so QFile::close() is QFileDevice::close(). QFileDevice::close() calls QIODevice::close() after flush().

        Perhaps you can identify where the QFile source code calls QIODevice::close() directly.

        HansonH Offline
        HansonH Offline
        Hanson
        wrote on last edited by
        #3

        @ChrisW67 I made a breakpoint at QFileDevice::close(),but the debugger never goes in.And only the QFileDevice::close() calls the QIODevice::close().How I found about this, because I found the file is still occupied after calls QFileDevice::close().But when not call close() explicitly and in QFile dctor call QFileDevice::close() implicit, the file will not be occupied.And this is only happend in my computer.
        e1ccc069-709c-4429-88e3-8803e12d9f98-image.png

        “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.”
        —— Martin Golding

        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