fix problem with remove_window() removing too many windows

This commit is contained in:
David Rose 2004-03-03 14:15:19 +00:00
parent 3572444a67
commit cf6a95c0ed
4 changed files with 15 additions and 4 deletions

View File

@ -359,6 +359,9 @@ remove_window(GraphicsOutput *window) {
size_t count; size_t count;
{ {
MutexHolder holder(_lock); MutexHolder holder(_lock);
if (!_windows_sorted) {
do_resort_windows();
}
count = _windows.erase(ptwin); count = _windows.erase(ptwin);
} }
if (count == 0) { if (count == 0) {
@ -367,6 +370,8 @@ remove_window(GraphicsOutput *window) {
} }
do_remove_window(window); do_remove_window(window);
nassertr(count == 1, true);
return true; return true;
} }
@ -1167,6 +1172,7 @@ do_resort_windows() {
RenderThread *thread = (*ti).second; RenderThread *thread = (*ti).second;
thread->resort_windows(); thread->resort_windows();
} }
_windows.sort(); _windows.sort();
} }

View File

@ -130,7 +130,7 @@ private:
void *_data; void *_data;
}; };
typedef ov_multiset< PT(GraphicsOutput), IndirectLess<GraphicsOutput> > Windows; typedef ov_set< PT(GraphicsOutput), IndirectLess<GraphicsOutput> > Windows;
typedef pset< PT(GraphicsStateGuardian) > GSGs; typedef pset< PT(GraphicsStateGuardian) > GSGs;
typedef pset< Callback > Callbacks; typedef pset< Callback > Callbacks;

View File

@ -264,8 +264,11 @@ needs_context() const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE bool GraphicsOutput:: INLINE bool GraphicsOutput::
operator < (const GraphicsOutput &other) const { operator < (const GraphicsOutput &other) const {
if (_sort != other._sort) {
return _sort < other._sort; return _sort < other._sort;
} }
return this < &other;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -373,7 +373,8 @@ make_texture_buffer(const string &name, int x_size, int y_size) {
} }
// No good; delete the buffer and keep trying. // No good; delete the buffer and keep trying.
engine->remove_window(buffer); bool removed = engine->remove_window(buffer);
nassertr(removed, NULL);
buffer = (GraphicsOutput *)NULL; buffer = (GraphicsOutput *)NULL;
} }
} }
@ -390,7 +391,8 @@ make_texture_buffer(const string &name, int x_size, int y_size) {
return buffer; return buffer;
} }
engine->remove_window(buffer); bool removed = engine->remove_window(buffer);
nassertr(removed, NULL);
buffer = (GraphicsOutput *)NULL; buffer = (GraphicsOutput *)NULL;
} }