summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-23 11:34:11 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-11-23 11:53:15 -0300
commitce1cadcacf01f4428f0f247dcd34ffdc38c9184e (patch)
treeaed3c1cc4bcc11a0214be385a965fb75646a7dbe
parent276f260f65e07dfb9778ba8d069f18e070852528 (diff)
downloadpyside-ce1cadcacf01f4428f0f247dcd34ffdc38c9184e.tar.gz
pyside-ce1cadcacf01f4428f0f247dcd34ffdc38c9184e.tar.xz
pyside-ce1cadcacf01f4428f0f247dcd34ffdc38c9184e.zip
Fixed GlobalReceiver destructor.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r--libpyside/globalreceiver.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libpyside/globalreceiver.cpp b/libpyside/globalreceiver.cpp
index 2c12604..d63ebdf 100644
--- a/libpyside/globalreceiver.cpp
+++ b/libpyside/globalreceiver.cpp
@@ -116,7 +116,8 @@ GlobalReceiver::GlobalReceiver()
GlobalReceiver::~GlobalReceiver()
{
- foreach(DynamicSlotData* data, m_slotReceivers) {
+ while(!m_slotReceivers.empty()) {
+ DynamicSlotData* data = m_slotReceivers.take(m_slotReceivers.begin().key());
data->clear();
delete data;
}
@@ -203,8 +204,10 @@ int GlobalReceiver::qt_metacall(QMetaObject::Call call, int id, void** args)
if (strcmp(slot.signature(), RECEIVER_DESTROYED_SLOT_NAME) == 0) {
QObject *arg = *(QObject**)args[1];
- QHash<int, DynamicSlotData*>::iterator i = m_slotReceivers.begin();
- while(i != m_slotReceivers.end()) {
+ //avoid hash changes during the destruction
+ QHash<int, DynamicSlotData*> copy = m_slotReceivers;
+ QHash<int, DynamicSlotData*>::iterator i = copy.begin();
+ while(i != copy.end()) {
if (i.value()->hasRefTo(arg)) {
disconnectNotify(arg, i.key());
break;