NOOP, remove trailing tabs/whitespace.
[ardour.git] / libs / pbd / pbd / abstract_ui.cc
index b0ac6766084bd5fabd9a1f6511d77cb2e17ed807..323435bdd9fd8b9edf1bc371711c3d42227cd30d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Paul Davis 
+    Copyright (C) 2012 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -39,22 +39,22 @@ DECLARE_DEFAULT_COMPARISONS(ptw32_handle_t)
 
 using namespace std;
 
-template<typename RequestBuffer> void 
+template<typename RequestBuffer> void
 cleanup_request_buffer (void* ptr)
 {
         RequestBuffer* rb = (RequestBuffer*) ptr;
-       
+
        /* this is called when the thread for which this request buffer was
         * allocated dies. That could be before or after the end of the UI
-        * event loop that the request buffer communicates.
+        * event loop for which this request buffer provides communication.
         *
-        * We are not modifying the UI's thread/buffer map, just marking it 
+        * We are not modifying the UI's thread/buffer map, just marking it
         * dead. If the UI is currently processing the buffers and misses
         * this "dead" signal, it will find it the next time it receives
         * a request. If the UI has finished processing requests, then
         * we will leak this buffer object.
         */
-        
+
        rb->dead = true;
 }
 
@@ -67,7 +67,7 @@ AbstractUI<RequestObject>::AbstractUI (const string& name)
 {
        void (AbstractUI<RequestObject>::*pmf)(string,pthread_t,string,uint32_t) = &AbstractUI<RequestObject>::register_thread;
 
-       /* better to make this connect a handler that runs in the UI event loop but the syntax seems hard, and 
+       /* better to make this connect a handler that runs in the UI event loop but the syntax seems hard, and
           register_thread() is thread safe anyway.
        */
 
@@ -112,14 +112,14 @@ AbstractUI<RequestObject>::register_thread (string target_gui, pthread_t thread_
                /* add the new request queue (ringbuffer) to our map
                   so that we can iterate over it when the time is right.
                   This step is not RT-safe, but is assumed to be called
-                  only at thread initialization time, not repeatedly, 
+                  only at thread initialization time, not repeatedly,
                   and so this is of little consequence.
                */
                Glib::Threads::Mutex::Lock lm (request_buffer_map_lock);
                request_buffers[thread_id] = b;
        }
 
-       /* set this thread's per_thread_request_buffer to this new 
+       /* set this thread's per_thread_request_buffer to this new
           queue/ringbuffer. remember that only this thread will
           get this queue when it calls per_thread_request_buffer.get()
 
@@ -127,7 +127,7 @@ AbstractUI<RequestObject>::register_thread (string target_gui, pthread_t thread_
           when the thread exits, and ensures that the buffer is marked
           dead. it will then be deleted during a call to handle_ui_requests()
        */
-       
+
        per_thread_request_buffer.set (b);
 }
 
@@ -188,7 +188,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
        for (i = request_buffers.begin(); i != request_buffers.end(); ++i) {
 
                 while (true) {
-                        
+
                         /* we must process requests 1 by 1 because
                            the request may run a recursive main
                            event loop that will itself call
@@ -198,9 +198,9 @@ AbstractUI<RequestObject>::handle_ui_requests ()
                            is even remotely consistent with
                            the condition before we called it.
                         */
-                        
+
                         i->second->get_read_vector (&vec);
-                        
+
                         if (vec.len[0] == 0) {
                                 break;
                         } else {
@@ -211,9 +211,10 @@ AbstractUI<RequestObject>::handle_ui_requests ()
                                         if (vec.buf[0]->invalidation) {
                                                 vec.buf[0]->invalidation->requests.remove (vec.buf[0]);
                                         }
+                                        delete vec.buf[0];
                                         i->second->increment_read_ptr (1);
                                 }
-                        } 
+                        }
                 }
         }
 
@@ -228,7 +229,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
                      ++tmp;
                      request_buffers.erase (i);
                      i = tmp;
-             } else {          
+             } else {
                      ++i;
              }
         }
@@ -245,7 +246,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
 
                 /* We need to use this lock, because its the one
                    returned by slot_invalidation_mutex() and protects
-                   against request invalidation. 
+                   against request invalidation.
                 */
 
                 request_buffer_map_lock.lock ();
@@ -263,7 +264,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
 
                 if (req->invalidation) {
                        DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 remove request from its invalidation list\n", name(), pthread_name()));
-                       
+
                        /* after this call, if the object referenced by the
                         * invalidation record is deleted, it will no longer
                         * try to mark the request as invalid.
@@ -275,16 +276,16 @@ AbstractUI<RequestObject>::handle_ui_requests ()
                /* at this point, an object involved in a functor could be
                 * deleted before we actually execute the functor. so there is
                 * a race condition that makes the invalidation architecture
-                * somewhat pointless. 
+                * somewhat pointless.
                 *
                 * really, we should only allow functors containing shared_ptr
                 * references to objects to enter into the request queue.
                 */
 
                 request_buffer_map_lock.unlock ();
-               
+
                /* unlock the request lock while we execute the request, so
-                * that we don't needlessly block other threads (note: not RT 
+                * that we don't needlessly block other threads (note: not RT
                 * threads since they have their own queue) from making requests.
                 */
 
@@ -326,7 +327,8 @@ AbstractUI<RequestObject>::send_request (RequestObject *req)
                */
                DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 direct dispatch of request type %3\n", name(), pthread_name(), req->type));
                do_request (req);
-       } else {        
+               delete req;
+       } else {
 
                /* If called from a different thread, we first check to see if
                 * the calling thread is registered with this UI. If so, there
@@ -372,7 +374,7 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
        }
 
        RequestObject *req = get_request (BaseUI::CallSlot);
-       
+
        if (req == 0) {
                return;
        }
@@ -382,9 +384,9 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
        /* copy semantics: copy the functor into the request object */
 
        req->the_slot = f;
-       
+
        /* the invalidation record is an object which will carry out
-        * invalidation of any requests associated with it when it is 
+        * invalidation of any requests associated with it when it is
         * destroyed. it can be null. if its not null, associate this
         * request with the invalidation record. this allows us to
         * "cancel" requests submitted to the UI because they involved
@@ -399,5 +401,5 @@ AbstractUI<RequestObject>::call_slot (InvalidationRecord* invalidation, const bo
         }
 
        send_request (req);
-}      
+}