]> git.lyx.org Git - features.git/commitdiff
Alfredo's patches to the forkedcall controller and to the graphics loader.
authorAngus Leeming <leeming@lyx.org>
Tue, 25 Feb 2003 15:17:53 +0000 (15:17 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 25 Feb 2003 15:17:53 +0000 (15:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6256 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/ChangeLog
src/graphics/LoaderQueue.C
src/graphics/LoaderQueue.h
src/support/ChangeLog
src/support/forkedcontr.C

index 083977536e188e8b6710d1bfd1f38e0b0dd8b465..96431286a100ab4c73c50b67091d469ec894776d 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-25  Alfredo Braunstein  <abraunst@libero.it>
+
+       * LoaderQueue.[Ch]: a simplification of the code, eliminated
+       the unneeded input bucket.
+
 2003-02-25  Alfredo Braunstein  <abraunst@libero.it>
 
        * PreviewLoader.C (FindFirst): use ==, not < with std::find.
index f7332d06eb48ec5f495925ce6f54ffa977c85ebb..eb9d12a0a59838df1a997e91cfc84ce32f1a6510 100644 (file)
@@ -23,6 +23,7 @@ namespace grfx {
 int LoaderQueue::s_numimages_ = 5;
 int LoaderQueue::s_millisecs_ = 500;
 
+
 LoaderQueue & LoaderQueue::get()
 {
        static LoaderQueue singleton;
@@ -32,18 +33,18 @@ LoaderQueue & LoaderQueue::get()
 
 void LoaderQueue::loadNext()
 {
-       emptyBucket();
        lyxerr[Debug::GRAPHICS] << "LoaderQueue: "
                                << cache_queue_.size()
                                << " items in the queue" << endl;
        int counter = s_numimages_;
        while (cache_queue_.size() && counter--) {
-               if(cache_queue_.front()->status() == WaitingToLoad)
-                       cache_queue_.front()->startLoading();
-               cache_set_.erase(cache_queue_.front());
+               Cache::ItemPtr ptr = cache_queue_.front();
+               cache_set_.erase(ptr);
                cache_queue_.pop_front();
+               if (ptr->status() == WaitingToLoad)
+                       ptr->startLoading();
        }
-       if (cache_queue_.size() || bucket_.size()) {
+       if (cache_queue_.size()) {
                startLoader();
        } else {
                stopLoader();
@@ -69,17 +70,6 @@ LoaderQueue::LoaderQueue() : timer(s_millisecs_, Timeout::ONETIME),
 }
 
 
-void LoaderQueue::emptyBucket()
-{
-       lyxerr[Debug::GRAPHICS] << "LoaderQueue: emptying bucket"
-                               << endl;
-       while (! bucket_.empty()) {
-               addToQueue(bucket_.front());
-               bucket_.pop();
-       }
-}
-
-
 void LoaderQueue::startLoader()
 {
        lyxerr[Debug::GRAPHICS] << "LoaderQueue: waking up" << endl;
@@ -104,14 +94,6 @@ bool LoaderQueue::running() const
 
 
 void LoaderQueue::touch(Cache::ItemPtr const & item)
-{
-       if (! running_)
-               startLoader();
-       bucket_.push(item);
-}
-
-
-void LoaderQueue::addToQueue(Cache::ItemPtr const & item)
 {
        if (! cache_set_.insert(item).second) {
                list<Cache::ItemPtr>::iterator
@@ -124,6 +106,8 @@ void LoaderQueue::addToQueue(Cache::ItemPtr const & item)
                        cache_queue_.erase(it);
        }
        cache_queue_.push_front(item);
+       if (!running_)
+               startLoader();
 }
 
 
index 9ed1dd8d7e6341b9284b1405392b388fdb52d08e..50183c12b936fe0c2ea418166d95c9c7fd235599 100644 (file)
@@ -64,10 +64,6 @@ private:
        ///
        static int s_millisecs_ ;
 
-       /// Moves bucket_ to cache_queue_
-       void emptyBucket();
-       /// Adds or reprioritizes one element in cache_queue_
-       void addToQueue(Cache::ItemPtr const & item);
        /** This is the 'threaded' method, that does the loading in the
         *  background.
         */
index fa3ffcaeb724c4489109e4e2e8953224f3ed405c..8ee418578835ec5d5f8b79de17e0d67bbee74181 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-25  Alfredo Braunstein <abraunst@libero.it>
+
+       * forkedcontr.C (timer): Start the loop afresh if an item is deleted.
+       Emiting the signal can result in an arbitrary change to the list.
+
 2003-02-25  Angus Leeming  <leeming@lyx.org>
 
        * forkedcontr.C (timer): Use a while loop rather than for; makes it
index 1a2efbcf18bd32bc618f1ae723d6db92f8e8550e..d11fc142454db5f1e07b0928cb1ff38343f4a8e0 100644 (file)
@@ -131,11 +131,15 @@ void ForkedcallsController::timer()
                }
 
                if (remove_it) {
-                       // Emit signal and remove the item from the list
+                       forkedCalls.erase(it);
+
                        actCall->emitSignal();
                        delete actCall;
-                       // erase returns the next element in the list
-                       it = forkedCalls.erase(it);
+
+                       /* start all over: emiting the signal can result
+                        * in changing the list (Ab)
+                        */
+                       it = forkedCalls.begin();
                } else {
                        ++it;
                }