paperbox r253 - in trunk: . src



Author: markoa
Date: Sun Dec 28 21:21:37 2008
New Revision: 253
URL: http://svn.gnome.org/viewvc/paperbox?rev=253&view=rev

Log:
Pass a single document pointer in document retrieval


Modified:
   trunk/ChangeLog
   trunk/src/browser.cc
   trunk/src/browser.hh
   trunk/src/document-tile.cc
   trunk/src/tracker-phone.cc

Modified: trunk/src/browser.cc
==============================================================================
--- trunk/src/browser.cc	(original)
+++ trunk/src/browser.cc	Sun Dec 28 21:21:37 2008
@@ -146,8 +146,6 @@
     void
     Browser::on_documents(const std::queue<ustring>& uris)
     {
-        uri_queue_ = uris;
-
         signal_retrieval_started_.emit();
 
         vector<shared_ptr<Document> > docs;
@@ -155,7 +153,9 @@
 
         while (! uris_copy.empty()) {
             ustring uri = uris_copy.front();
-            docs.push_back(shared_ptr<Document>(new Document(uri)));
+            shared_ptr<Document> doc (new Document(uri));
+            docs.push_back(doc);
+            uri_queue_.push(doc);
             uris_copy.pop();
         }
 
@@ -179,17 +179,15 @@
             return false; // idle function done
         }
 
-        ustring uri = uri_queue_.front();
+        shared_ptr<Document> doc = uri_queue_.front();
+        ustring uri = doc->get_uri();
 
         // get metadata, emit for new documents
         try {
-            shared_ptr<Document> doc;
             tracker_client_->get_document(uri, doc);
 
-            if (doc.get()) {
-                docs_[uri.raw()] = doc;
-                signal_document_retrieved_.emit(doc);
-            }
+            docs_[uri.raw()] = doc;
+            signal_document_retrieved_.emit(doc);
         }
         catch (const Glib::FileError& ex) {
             // probably a nonexistent file in the index

Modified: trunk/src/browser.hh
==============================================================================
--- trunk/src/browser.hh	(original)
+++ trunk/src/browser.hh	Sun Dec 28 21:21:37 2008
@@ -116,7 +116,7 @@
                              const std::vector<Glib::ustring>& tags);
 
         std::tr1::shared_ptr<TrackerPhone> tracker_client_;
-        std::queue<Glib::ustring> uri_queue_;
+        std::queue<std::tr1::shared_ptr<Document> > uri_queue_;
         doc_map docs_;
 
         sigc::signal<void> signal_retrieval_started_;

Modified: trunk/src/document-tile.cc
==============================================================================
--- trunk/src/document-tile.cc	(original)
+++ trunk/src/document-tile.cc	Sun Dec 28 21:21:37 2008
@@ -131,8 +131,6 @@
     {
         if (doc_->get_uri() != doc->get_uri()) return;
 
-        doc_ = doc; // well we might get rid of this duplication
-
         set_title(doc->get_subject());
         set_summary(doc->get_author());
         break_title();

Modified: trunk/src/tracker-phone.cc
==============================================================================
--- trunk/src/tracker-phone.cc	(original)
+++ trunk/src/tracker-phone.cc	Sun Dec 28 21:21:37 2008
@@ -308,6 +308,8 @@
                                               this);
     }
 
+    /// If you pass an initialized document instance, it will be used
+    /// instead of instantiating a new object.
     void
     TrackerPhone::get_document(const Glib::ustring& uri,
                                shared_ptr<Document>& document)
@@ -317,8 +319,10 @@
         char** results = 0;
         GError* error = 0;
 
-        Document* null_doc = 0;
-        document.reset(null_doc);
+        if (! document) {
+            Document* null_doc = 0;
+            document.reset(null_doc);
+        }
 
         if (! Glib::file_test(uri.raw(), Glib::FILE_TEST_EXISTS)) {
             throw Glib::FileError(Glib::FileError::NO_SUCH_ENTITY,
@@ -360,7 +364,7 @@
 
         //LOG_DD("preparing a document object with metadata for uri " << uri);
 
-        document.reset(new Document(uri));
+        if (! document) document.reset(new Document(uri));
 
         if (! is_empty_string(keys[FILE_NAME])) {
             Glib::ustring file_name(keys[FILE_NAME]);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]