QSettings - Sync issue between two process



  • Hi,

    I am using Qsettings for non gui products to store its settings into xml files. This is written as a library which gets used in C, C++ programs. There will be 1 xml file file for each product. Each product might have more than one sub products and they are written into xml by subproduct grouping as follows -

    File: "product1.xml"

    @<product1>
    <subproduct1>
    <settings1>..</settings1>
    ....
    <settingsn>..</settingsn>
    </subproduct1>
    ...
    <subproductn>
    <settings1>..</settings1>
    ....
    <settingsn>..</settingsn>
    </subproductn>

    </product1>@

    File: productn.xml

    @<productn>
    <subproduct1>
    <settings1>..</settings1>
    ....
    <settingsn>..</settingsn>
    </subproduct1>
    ...
    <subproductn>
    <settings1>..</settings1>
    ....
    <settingsn>..</settingsn>
    </subproductn>

    </productn>@

    The code in one process does the following -

    @settings = new QSettings("product1.xml", XmlFormat);
    settings.setValue("settings1",<value>)
    sleep(20);
    settings.setValue("settings2", <value2>)
    settings.sync();@

    When the first process goes to sleep, I start another process which does the following -

    @settings = new QSettings("product1.xml", XmlFormat);
    settings.remove("settings1")
    settings.setValue("settings3", <value3>)
    settings.sync();@

    I would expect the settings1 to go away from product1.xml file but it still persist in the file - product1.xml at the end of above two process. I am not using QCoreApplication(..) in my settings library. Please point issues if there is anything wrong in the above design.

    -Kartlee



  • The last sync wins and that's that of process 1.



  • Hi,

    Thanks for the reply. I realized the mistake am doing. Thanks again.

    -Karthik


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.