Results 1 to 5 of 5

Thread: Synchronize a config file handled QSettings on SMB

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    11
    Thanked 16 Times in 16 Posts

    Default Re: Synchronize a config file handled QSettings on SMB

    We already thought about this mechanism, but that is not our main problem. Our main problem is, that its not predicable when QSettings wants to write, but after looking into the sources we found out, that is responds to a QEvent::UpdateRequest
    Qt Code:
    1. bool QSettings::event(QEvent *event)
    2. {
    3. Q_D(QSettings);
    4. if (event->type() == QEvent::UpdateRequest) {
    5. d->update();
    6. return true;
    7. }
    8. return QObject::event(event);
    9. }
    10.  
    11. void QSettingsPrivate::update()
    12. {
    13. flush();
    14. pendingChanges = false;
    15. }
    16.  
    17.  
    18. void QConfFileSettingsPrivate::flush()
    19. {
    20. sync();
    21. }
    To copy to clipboard, switch view to plain text mode 

    sync is only called in the constructor/destructor and on request. So we think, that there is a good chance to get around this issue by using QObject#eventFilter and saving on our just before the destructor is called. (constructor is uncritical since it just reads the file)

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: Synchronize a config file handled QSettings on SMB

    Why don't you subclass QSettings? In the constructor you enable the lock (create the lock-file), and in the destructor you disable the lock.

    Then you use only local instances of your subclass - as the troll suggest for QSettings.

    HIH

    Johannes

  3. #3
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    11
    Thanked 16 Times in 16 Posts

    Default Re: Synchronize a config file handled QSettings on SMB

    That sounds to me like the best solution. But since in our current implementation we hold the QSettings we implemented it with the event filter. We're currently testing it, but it seems to work. But for the next release we're considering to use the local instances approach.

Similar Threads

  1. How to use QSettings to read INI file
    By Cantora in forum Newbie
    Replies: 8
    Last Post: 16th June 2011, 09:14
  2. QSettings, my own format of config-file
    By IPFreely in forum Qt Programming
    Replies: 2
    Last Post: 14th November 2007, 21:07
  3. Using QSettings to read pre-made INI file..
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 3rd May 2007, 06:36
  4. config file class
    By feizhou in forum Qt Programming
    Replies: 2
    Last Post: 23rd November 2006, 08:49
  5. Config file parsing
    By Vash5556 in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2006, 00:11

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
  •  
Qt is a trademark of The Qt Company.