OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org) | 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org) |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) | 80 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) |
81 { | 81 { |
82 ASSERT(!m_timer.isActive()); | 82 ASSERT(!m_timer.isActive()); |
83 ASSERT(!m_pendingEvents.isEmpty()); | 83 ASSERT(!m_pendingEvents.isEmpty()); |
84 | 84 |
85 Vector<RefPtr<Event> > pendingEvents; | 85 Vector<RefPtr<Event> > pendingEvents; |
86 m_pendingEvents.swap(pendingEvents); | 86 m_pendingEvents.swap(pendingEvents); |
87 | 87 |
| 88 RefPtr<EventTarget> protect(m_owner); |
88 for (unsigned i = 0; i < pendingEvents.size(); ++i) { | 89 for (unsigned i = 0; i < pendingEvents.size(); ++i) { |
89 EventTarget* target = pendingEvents[i]->target() ? pendingEvents[i]->tar
get() : m_owner; | 90 EventTarget* target = pendingEvents[i]->target() ? pendingEvents[i]->tar
get() : m_owner; |
90 target->dispatchEvent(pendingEvents[i].release()); | 91 target->dispatchEvent(pendingEvents[i].release()); |
91 } | 92 } |
92 } | 93 } |
93 | 94 |
94 void GenericEventQueue::close() | 95 void GenericEventQueue::close() |
95 { | 96 { |
96 m_isClosed = true; | 97 m_isClosed = true; |
97 | 98 |
98 m_timer.stop(); | 99 m_timer.stop(); |
99 m_pendingEvents.clear(); | 100 m_pendingEvents.clear(); |
100 } | 101 } |
101 | 102 |
102 void GenericEventQueue::cancelAllEvents() | 103 void GenericEventQueue::cancelAllEvents() |
103 { | 104 { |
104 m_timer.stop(); | 105 m_timer.stop(); |
105 m_pendingEvents.clear(); | 106 m_pendingEvents.clear(); |
106 } | 107 } |
107 | 108 |
108 bool GenericEventQueue::hasPendingEvents() const | 109 bool GenericEventQueue::hasPendingEvents() const |
109 { | 110 { |
110 return m_pendingEvents.size(); | 111 return m_pendingEvents.size(); |
111 } | 112 } |
112 | 113 |
113 } | 114 } |
OLD | NEW |