Andreas Pakulat | 1 Sep 2011 23:04
Picon
Picon
Gravatar

Small problem storing a list in QSettings

Hi,

I'm facing a small problem with QSettings and storing a python list in
it. It seems that I can't store an empty list properly into a QSettings
object, its always converted to an invalid QVariant somewhere along the
way. The attached sample script shows this, all is well until I create a
new QSettings object from the file and try to get the list again. The
printout of the ini file also shows this.

Specifying the type for the value() call does not work, that raises an
error that the conversion of the QVariant does not work due to different
typeids (0 vs.  256).

Am I doing something wrong or do I really need to serialize the list
manually into a string? (Can't even use QStringList here since thats not
available with the v2 API).

sip: 4.12.1
PyQt: 4.8.3
Qt: 4.7.3

Attachment (test.py): text/x-python, 1452 bytes
Hi,

I'm facing a small problem with QSettings and storing a python list in
it. It seems that I can't store an empty list properly into a QSettings
object, its always converted to an invalid QVariant somewhere along the
way. The attached sample script shows this, all is well until I create a
(Continue reading)

Alan Ezust | 2 Sep 2011 01:32
Picon

QMovie and underlying C/C++ object has been deleted

Using PyQt Version: 4.6-1, I found this strange thing when I try to create a new QMovie, in response to a signal emit.

    self._movie = QMovie(self)
traceback (most recent call last):
  File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line 123, in setActive
    self._setActiveMethod(active)
  File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line 131, in _setActiveMovie
    self._createMovie()
  File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line 161, in _createMovie
    self._movie = QMovie(self)
RuntimeError: underlying C/C++ object has been deleted

I'm not sure I understand why I am seeing this at object creation time.
Any clues?

<div><p>Using PyQt Version: 4.6-1, I found this strange thing when I try to create a new QMovie, in response to a signal emit.<br><br>&nbsp;&nbsp;&nbsp; self._movie = QMovie(self)<br>traceback (most recent call last):<br>&nbsp; File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line 123, in setActive<br>
&nbsp;&nbsp;&nbsp; self._setActiveMethod(active)<br>&nbsp; File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line 131, in _setActiveMovie<br>&nbsp;&nbsp;&nbsp; self._createMovie()<br>&nbsp; File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line 161, in _createMovie<br>
&nbsp;&nbsp;&nbsp; self._movie = QMovie(self)<br>RuntimeError: underlying C/C++ object has been deleted<br><br>I'm not sure I understand why I am seeing this at object creation time.<br>Any clues?<br><br></p></div>
Andreas Pakulat | 2 Sep 2011 08:18
Picon
Picon
Gravatar

Re: QMovie and underlying C/C++ object has been deleted

On 01.09.11 16:32:36, Alan Ezust wrote:
> Using PyQt Version: 4.6-1, I found this strange thing when I try to create a
> new QMovie, in response to a signal emit.
> 
>     self._movie = QMovie(self)
> traceback (most recent call last):
>   File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line
> 123, in setActive
>     self._setActiveMethod(active)
>   File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line
> 131, in _setActiveMovie
>     self._createMovie()
>   File "/home/rats-user/rats-dev/build/py/ratsApp/ui/IconStuff.py", line
> 161, in _createMovie
>     self._movie = QMovie(self)
> RuntimeError: underlying C/C++ object has been deleted
> 
> I'm not sure I understand why I am seeing this at object creation time.
> Any clues?

Just a wild guess since QMovie takes a QObject-parent, maybe self is the
already-deleted object and not the new QMovie instance...

Andreas

Phil Thompson | 2 Sep 2011 17:12

Re: Small problem storing a list in QSettings

On Thu, 1 Sep 2011 23:04:06 +0200, Andreas Pakulat <apaku <at> gmx.de> wrote:
> Hi,
> 
> I'm facing a small problem with QSettings and storing a python list in
> it. It seems that I can't store an empty list properly into a QSettings
> object, its always converted to an invalid QVariant somewhere along the
> way. The attached sample script shows this, all is well until I create a
> new QSettings object from the file and try to get the list again. The
> printout of the ini file also shows this.
> 
> Specifying the type for the value() call does not work, that raises an
> error that the conversion of the QVariant does not work due to different
> typeids (0 vs.  256).
> 
> Am I doing something wrong or do I really need to serialize the list
> manually into a string? (Can't even use QStringList here since thats not
> available with the v2 API).
> 
> sip: 4.12.1
> PyQt: 4.8.3
> Qt: 4.7.3

The problem with specifying an explicit type should be fixed in tonight's
snapshot.

Thanks,
Phil
Detlev Offenbach | 2 Sep 2011 21:20
Picon
Favicon

Help needed for eric4/5

Hello,

as all of you know eric4/5 is an IDE for Python and Ruby. The Ruby debugger
backend does not work for ruby 1.9 anymore. Unfortunately I am not very 
good
in ruby. I need help in fixing this issue. Volunteers please contact me.

Regards,
Detlev
--

-- 
Detlev Offenbach
detlev <at> die-offenbachs.de
detlev | 4 Sep 2011 11:40
Picon
Favicon

ANN: eric 4.4.17 released

Hi,

I just uploaded eric 4.4.17. It is a maintenance release fixing some bugs. It 
is available via the eric web site.

http://eric-ide.python-projects.org/index.html

Regards,
Detlev
--

-- 
Detlev Offenbach
detlev <at> die-offenbachs.de
detlev | 4 Sep 2011 11:40
Picon
Favicon

ANN: eric 5.1.5 released

Hi,

I just uploaded eric 5.1.5. It is a maintenance release fixing some bugs. It 
is available via the eric web site.

http://eric-ide.python-projects.org/index.html

Regards,
Detlev
--

-- 
Detlev Offenbach
detlev <at> die-offenbachs.de
Andreas Pakulat | 4 Sep 2011 17:25
Picon
Picon
Gravatar

Re: Small problem storing a list in QSettings

On 02.09.11 16:12:49, Phil Thompson wrote:
> On Thu, 1 Sep 2011 23:04:06 +0200, Andreas Pakulat <apaku <at> gmx.de> wrote:
> > Hi,
> > 
> > I'm facing a small problem with QSettings and storing a python list in
> > it. It seems that I can't store an empty list properly into a QSettings
> > object, its always converted to an invalid QVariant somewhere along the
> > way. The attached sample script shows this, all is well until I create a
> > new QSettings object from the file and try to get the list again. The
> > printout of the ini file also shows this.
> > 
> > Specifying the type for the value() call does not work, that raises an
> > error that the conversion of the QVariant does not work due to different
> > typeids (0 vs.  256).
> > 
> > Am I doing something wrong or do I really need to serialize the list
> > manually into a string? (Can't even use QStringList here since thats not
> > available with the v2 API).
> > 
> > sip: 4.12.1
> > PyQt: 4.8.3
> > Qt: 4.7.3
> 
> The problem with specifying an explicit type should be fixed in tonight's
> snapshot.

Ok, but what about the  <at> Invalid being stored if I give
QSettings.setValue an empty list as value? Is that expected?

Andreas

Phil Thompson | 4 Sep 2011 17:43

Re: Small problem storing a list in QSettings

On Sun, 4 Sep 2011 17:25:56 +0200, Andreas Pakulat <apaku <at> gmx.de> wrote:
> On 02.09.11 16:12:49, Phil Thompson wrote:
>> On Thu, 1 Sep 2011 23:04:06 +0200, Andreas Pakulat <apaku <at> gmx.de>
wrote:
>> > Hi,
>> > 
>> > I'm facing a small problem with QSettings and storing a python list
in
>> > it. It seems that I can't store an empty list properly into a
QSettings
>> > object, its always converted to an invalid QVariant somewhere along
the
>> > way. The attached sample script shows this, all is well until I
create
>> > a
>> > new QSettings object from the file and try to get the list again. The
>> > printout of the ini file also shows this.
>> > 
>> > Specifying the type for the value() call does not work, that raises
an
>> > error that the conversion of the QVariant does not work due to
>> > different
>> > typeids (0 vs.  256).
>> > 
>> > Am I doing something wrong or do I really need to serialize the list
>> > manually into a string? (Can't even use QStringList here since thats
>> > not
>> > available with the v2 API).
>> > 
>> > sip: 4.12.1
>> > PyQt: 4.8.3
>> > Qt: 4.7.3
>> 
>> The problem with specifying an explicit type should be fixed in
tonight's
>> snapshot.
> 
> Ok, but what about the  <at> Invalid being stored if I give
> QSettings.setValue an empty list as value? Is that expected?

Yes because PyQt has no idea what it might be a list of.

Phil
Detlev Offenbach | 4 Sep 2011 18:09
Picon
Favicon

Re: Small problem storing a list in QSettings

Am Sonntag, 4. September 2011, 17:25:56 schrieb Andreas Pakulat:
> On 02.09.11 16:12:49, Phil Thompson wrote:
> > On Thu, 1 Sep 2011 23:04:06 +0200, Andreas Pakulat <apaku <at> gmx.de> wrote:
> > > Hi,
> > > 
> > > I'm facing a small problem with QSettings and storing a python list
> > > in
> > > it. It seems that I can't store an empty list properly into a
> > > QSettings
> > > object, its always converted to an invalid QVariant somewhere along
> > > the
> > > way. The attached sample script shows this, all is well until I
> > > create a new QSettings object from the file and try to get the list
> > > again. The printout of the ini file also shows this.
> > > 
> > > Specifying the type for the value() call does not work, that raises
> > > an
> > > error that the conversion of the QVariant does not work due to
> > > different typeids (0 vs.  256).
> > > 
> > > Am I doing something wrong or do I really need to serialize the list
> > > manually into a string? (Can't even use QStringList here since thats
> > > not available with the v2 API).
> > > 
> > > sip: 4.12.1
> > > PyQt: 4.8.3
> > > Qt: 4.7.3
> > 
> > The problem with specifying an explicit type should be fixed in
> > tonight's
> > snapshot.
> 
> Ok, but what about the  <at> Invalid being stored if I give
> QSettings.setValue an empty list as value? Is that expected?

In eric5 I had to deal with that issue as well. I solved it by writing a 
utility method like that.

def toList(value):
    """
    Module function to convert a value to a list.

     <at> param value value to be converted
     <at> return converted data
    """
    if value is None:
        return []
    elif not isinstance(value, list):
        return [value]
    else:
        return value

At that time I didn't find a better solution and it works well for quite some 
time now.

Regards,
Detlev
--

-- 
Detlev Offenbach
detlev <at> die-offenbachs.de

Gmane