Allow cross-thread request invalidators to cope with multiple requests
authorCarl Hetherington <carl@carlh.net>
Sat, 3 Apr 2010 00:42:39 +0000 (00:42 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 3 Apr 2010 00:42:39 +0000 (00:42 +0000)
being logged before they are handled, and to invalidate them all rather
than just the last one.  Fixes shutdown problems when the PortMatrix has
been opened during the session, during which PortRegisteredOrUnregistered
is emitted quite heavily.

git-svn-id: svn://localhost/ardour2/branches/3.0@6852 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/pbd/event_loop.cc
libs/pbd/pbd/abstract_ui.cc
libs/pbd/pbd/event_loop.h

index e95a938d63d65c7d1fe1bd998a76618a4931c82e..58ab891c4b09ece7ece023d57cf07112aa160a1b 100644 (file)
@@ -29,21 +29,15 @@ EventLoop::invalidate_request (void* data)
         InvalidationRecord* ir = (InvalidationRecord*) data;
 
         if (ir->event_loop) {
-                Glib::Mutex::Lock lm (ir->event_loop->slot_invalidation_mutex());
-                if (ir->request) {
-                        cerr << "Object deleted had outstanding event loop request, IR created @ "
-                             << ir->file << ':' << ir->line
-                             << endl;
-                        ir->request->valid = false;
-                        ir->request->invalidation = 0;
-                } else {
-                        cerr << "No queued request associated with object deletion from "
-                             << ir->file << ':' << ir->line
-                             << endl;
-                        
-                }
-
-                delete ir;
+               Glib::Mutex::Lock lm (ir->event_loop->slot_invalidation_mutex());
+               for (list<BaseRequestObject*>::iterator i = ir->requests.begin(); i != ir->requests.end(); ++i) {
+                       cerr << "Object deleted had outstanding event loop request, IR created @ "
+                            << ir->file << ':' << ir->line
+                            << endl;
+                       (*i)->valid = false;
+                       (*i)->invalidation = 0;
+               }
+               delete ir;
         }
 
         return 0;
index 71371fe4d99b551aa4cbad3b9e39cd95d9323858..a769246f3874a895247e42aaaee52ea98676f689 100644 (file)
@@ -105,7 +105,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
                                         do_request (vec.buf[0]);
                                         request_buffer_map_lock.lock ();
                                         if (vec.buf[0]->invalidation) {
-                                                vec.buf[0]->invalidation->request = 0;
+                                                vec.buf[0]->invalidation->requests.remove (vec.buf[0]);
                                         }
                                         i->second->increment_read_ptr (1);
                                 }
@@ -141,7 +141,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
                 */
 
                 if (req->invalidation) {
-                        req->invalidation->request = 0;
+                        req->invalidation->requests.remove (req);
                 }
 
                 request_buffer_map_lock.unlock ();
@@ -200,7 +200,7 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
         req->invalidation = invalidation;
 
         if (invalidation) {
-                invalidation->request = req;
+                invalidation->requests.push_back (req);
                 invalidation->event_loop = this;
         }
 
index 088b061826f413da2b29aada42971e2a1de3a8ef..6e7e42e9dd1a50fd164c01f870701cd6a77fda22 100644 (file)
@@ -40,12 +40,12 @@ class EventLoop
         struct BaseRequestObject;
     
         struct InvalidationRecord {
-            BaseRequestObject* request;
-            PBD::EventLoop* event_loop;
-            const char* file;
-            int line;
+           std::list<BaseRequestObject*> requests;
+           PBD::EventLoop* event_loop;
+           const char* file;
+           int line;
 
-            InvalidationRecord() : request (0), event_loop (0) {}
+           InvalidationRecord() : event_loop (0) {}
         };
 
         static void* invalidate_request (void* data);