[PyQt] [PyQt4] Bugs? Side effects of some python syntax on sqlite commit

IloChab ilochab at gmail.com
Sat Sep 27 14:34:15 BST 2008

It's awhile that I'm struggling with a strange behavior of my code on
different platforms.

My program is a GUI to a sqlite db that uses PyQt4 API's to access it.
In different situations it looks like it is working correctly (no error,
coherent db management at run-time) but when it ends no db modification is
written to disk (and I find a db-journal nearby my db file).

At the beginning I noticed that it worked onto some platforms and it didn't
on others
[ http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14774.html ].

Then I found which was the part of code responsible for the wrong behavior
[ http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14883.html ].

After avoiding the use of lambda forms, and proceeding in my code
development, I found an other statement that produced exactly the same
problem: it was a simple reference to an owner object.
I will explain it.
1- when my application starts it instantiates a MainWindow object
2- in its __init__ it instantiates many QtGui.QTableView objects
3- in their __init__ they instantiate one QtSql.QSqlQueryModel object each
=> If I pass through all this chain a reference to the mainWindow object (as
init parameter) and I use it just in the subsequent. init-functions, every
thing works fine.
=> If I store this reference in a queryModel object attribute, for
subsequent. uses, every thing LOOKS LIKE it's functioning correctly, I don't
get any error, but at the end of the execution all sqlite modifications are
NOT written to disk and I find a db-journal file near by my db file. Note
that it's enough that I store the reference to the mainWindow object, it
doesn't matter if I don't or do use it.
I was able to bypass this problem using a weakref.ref(mainW) instead of a
plain reference

Does this make any sense to you or it is a bug?

I hope to receive a followup to my question even if I didn't to the previous
ones (perhaps my English is too bad and no one can understand it ???)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080927/f8e3cf71/attachment.html

More information about the PyQt mailing list