PDA

View Full Version : Non-Reentrant method in overrided resizeEvent method problem



vertusd
25th November 2010, 08:17
I write a table class which can reload items after a resize event.

But the the reloadControls() method is non-reentrant

After i resize the table to a smaller size, two reloadControls() confilcts. The controls loaded twice,

So ,how can i prevent this situation, Cos when you resize a window,resizeEvent are raised several times.




class ClientTableWidget(QtGui.QTableWidget):

def resizeEvent(self,event):
if self.rowCount()!=0:
self.reloadControls()
QtGui.QTableWidget.resizeEvent(self, event)

def reloadControls(self):
self.clear()
if self.rowCount()==0:
for key in self.c_dict:
self.addItem( self.c_dict[key])

sample images:
after loading
http://i.imgur.com/cLD32.jpg
after enlarging the window size, items' number did not change, there is no conflict
http://i.imgur.com/yaNsv.jpg
but when i resize the window to a smaller size, items loaded twice :
http://i.imgur.com/qI7x1.jpg

wysota
25th November 2010, 12:37
Two resize events cannot be processed at the same time so they cannot cause conflicts, this is not a reentrancy issue. The behaviour has to be caused by something else.