On Sat, 25 Dec 2010 13:36:37 +1100, Xavion <[email protected]> wrote:
> I think I've encountered a bug in PyQt v4.8.1 when loading Boolean types
> via
> QSettings.  I'm also using SIP v4.11.2 and Python v3.1.3.
> 
> Here's the code I'm using to save the setting:
> 
> if Main.uiSettings.cbPreferSUdo.checkState() == QtCore.Qt.Unchecked :
>>     User.System.bPreferSUdo = False
>> else :
>>     User.System.bPreferSUdo = True
>>
>> Settings.beginGroup( "System" )
>> Settings.setValue( "Prefer SUdo", User.System.bPreferSUdo )
>> Settings.endGroup()
>>
> 
> Here's the code I'm using to load the setting:
> 
> Settings.beginGroup( "System" )
>> oItems = Settings.value( "Prefer SUdo" )
>> if oItems :
>>     User.System.bPreferSUdo = oItems
>> Settings.endGroup()
>>
> 
> I think there's a bug in PyQt, because I'm getting inconsistent results.
> For this example, I've ensured that the check-box is set to 'False'
before
> saving the setting.
> 
> If I save the setting and load it again (while the application is still
> running), the correct 'False' value is returned (from cache).  If I save
> the
> setting, quit and restart the application, then load the setting, an
> incorrect 'false' value is returned (from the configuration file). 
Using a
> 'bool()' cast makes no difference.
> 
> In the second case, the lowercase 'f' in 'false' actually means that the
> check-box becomes set to 'True'.  This means that I'm effectively
getting
> black when I want white.  Can someone confirm whether this is a bug in
PyQt
> and how long it'll take to fix?  I was planning to release the next
version
> of my application today.

It's not a bug. You can't make assumptions about the capabilities of the
backend (platform specific) storage regarding saving type information. You
have to explicitly test for the values that might come back.

Phil
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to