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. Problem with QSettings in QT 5.7

Problem with QSettings in QT 5.7

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.4k Views 2 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
    MaryamTa
    wrote on last edited by MaryamTa
    #1

    I used QSettings in QT 5.2. It saved settings in an ini file in a directory which has deny permission set for delete. I upgrade QT to 5.7 but it has problem with it. QSettings could not create ini file and some files like MyFileName.ini.hp(some numbers) and MyFileName.ini.lock.rmlock.rmlock..... will be created. If ini file existed before, program gets stuck in QSettings.sync() operation and again creates mentioned files.If I remove permission, program will work fine. I guess in QSettings 5.2 ini file is overwrited to previous file but in 5.7 it tries to delete previous and create new on. Is there any solution?

    jsulmJ 1 Reply Last reply
    0
    • M MaryamTa

      I used QSettings in QT 5.2. It saved settings in an ini file in a directory which has deny permission set for delete. I upgrade QT to 5.7 but it has problem with it. QSettings could not create ini file and some files like MyFileName.ini.hp(some numbers) and MyFileName.ini.lock.rmlock.rmlock..... will be created. If ini file existed before, program gets stuck in QSettings.sync() operation and again creates mentioned files.If I remove permission, program will work fine. I guess in QSettings 5.2 ini file is overwrited to previous file but in 5.7 it tries to delete previous and create new on. Is there any solution?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @MaryamTa I think the problem is that QSettings cannot remove the *.lock files when the app is closed. Next time you start the app it detects those files and thinks the settings are already in use. You should remove that access right restriction.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @MaryamTa I think the problem is that QSettings cannot remove the *.lock files when the app is closed. Next time you start the app it detects those files and thinks the settings are already in use. You should remove that access right restriction.

        M Offline
        M Offline
        MaryamTa
        wrote on last edited by
        #3

        @jsulm Thanks for your quick reply. It seems to be true reason. But why every time it added a .rmlock and make new lock file?
        And why it couldn't create ini file even if there is no file before?
        At last, I really need to set the permission. Do you think there is another solution or not?

        jsulmJ 1 Reply Last reply
        0
        • M MaryamTa

          @jsulm Thanks for your quick reply. It seems to be true reason. But why every time it added a .rmlock and make new lock file?
          And why it couldn't create ini file even if there is no file before?
          At last, I really need to set the permission. Do you think there is another solution or not?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @MaryamTa I don't know how QSettings.sync() is implemented, but you could take a look at the source code.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • jsulmJ jsulm

            @MaryamTa I don't know how QSettings.sync() is implemented, but you could take a look at the source code.

            M Offline
            M Offline
            MaryamTa
            wrote on last edited by
            #5

            @jsulm I checked it but I couldn't find management on repeated lock files. Thanks anyway.

            kshegunovK 1 Reply Last reply
            0
            • M MaryamTa

              @jsulm I checked it but I couldn't find management on repeated lock files. Thanks anyway.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              QSettings tries to be smart. So it will use a lock file to provide scoping and synchronization for the actual settings file. This means it has to be able to create, lock, unlock and ultimately delete the lock file. Since you've removed the deletion it will fail (silently) when it has to clean up and will create a new lock file when the program's started again.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              3

              • Login

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