mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-21 09:21:08 +00:00
PEGASUS: Use an Array instead of a List for NotificationReceivers
Fixes occasional crashes with the norad sub controls. CodeWarrior's iterators used indices unlike our List iterators, thus necessitating the change here.
This commit is contained in:
parent
b07d03dedf
commit
a2454f6563
@ -38,8 +38,8 @@ Notification::Notification(const NotificationID id, NotificationManager *owner)
|
||||
}
|
||||
|
||||
Notification::~Notification() {
|
||||
for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
|
||||
it->receiver->newNotification(NULL);
|
||||
for (uint i = 0; i < _receivers.size(); i++)
|
||||
_receivers[i].receiver->newNotification(NULL);
|
||||
|
||||
if (_owner)
|
||||
_owner->removeNotification(this);
|
||||
@ -49,9 +49,9 @@ Notification::~Notification() {
|
||||
// Wherever mask is 0, leave existing bits untouched.
|
||||
// Wherever mask is 1, set bit equivalent to flags.
|
||||
void Notification::notifyMe(NotificationReceiver *receiver, NotificationFlags flags, NotificationFlags mask) {
|
||||
for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++) {
|
||||
if (it->receiver == receiver) {
|
||||
it->mask = (it->mask & ~mask) | (flags & mask);
|
||||
for (uint i = 0; i < _receivers.size(); i++) {
|
||||
if (_receivers[i].receiver == receiver) {
|
||||
_receivers[i].mask = (_receivers[i].mask & ~mask) | (flags & mask);
|
||||
receiver->newNotification(this);
|
||||
return;
|
||||
}
|
||||
@ -66,11 +66,11 @@ void Notification::notifyMe(NotificationReceiver *receiver, NotificationFlags fl
|
||||
}
|
||||
|
||||
void Notification::cancelNotification(NotificationReceiver *receiver) {
|
||||
for (ReceiverIterator it = _receivers.begin(); it != _receivers.end();) {
|
||||
if (it->receiver == receiver)
|
||||
it = _receivers.erase(it);
|
||||
else
|
||||
it++;
|
||||
for (uint i = 0; i < _receivers.size(); i++) {
|
||||
if (_receivers[i].receiver == receiver) {
|
||||
_receivers.remove_at(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,9 +82,9 @@ void Notification::checkReceivers() {
|
||||
NotificationFlags currentFlags = _currentFlags;
|
||||
_currentFlags = kNoNotificationFlags;
|
||||
|
||||
for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
|
||||
if (it->mask & currentFlags)
|
||||
it->receiver->receiveNotification(this, currentFlags);
|
||||
for (uint i = 0; i < _receivers.size(); i++)
|
||||
if (_receivers[i].mask & currentFlags)
|
||||
_receivers[i].receiver->receiveNotification(this, currentFlags);
|
||||
}
|
||||
|
||||
// Receiver entries are equal if their receivers are equal.
|
||||
|
@ -26,6 +26,7 @@
|
||||
#ifndef PEGASUS_NOTIFICATION_H
|
||||
#define PEGASUS_NOTIFICATION_H
|
||||
|
||||
#include "common/array.h"
|
||||
#include "common/list.h"
|
||||
|
||||
#include "pegasus/types.h"
|
||||
@ -44,7 +45,7 @@ struct ReceiverEntry {
|
||||
int operator==(const ReceiverEntry &entry1, const ReceiverEntry &entry2);
|
||||
int operator!=(const ReceiverEntry &entry1, const ReceiverEntry &entry2);
|
||||
|
||||
typedef Common::List<ReceiverEntry> ReceiverList;
|
||||
typedef Common::Array<ReceiverEntry> ReceiverList;
|
||||
|
||||
/*
|
||||
A notification can have 32 flags associated with it, which can be user-defined.
|
||||
|
Loading…
Reference in New Issue
Block a user