[haiku-commits] haiku: hrev48658 - src/apps/haikudepot/ui

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 11 Jan 2015 00:15:27 +0100 (CET)

hrev48658 adds 1 changeset to branch 'master'
old head: 84316965edb8b5280b5ab8997cae7240ef3526e0
new head: 788144656e52cf4cc1285449b43bffa664c6141c
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=7881446+%5E8431696

----------------------------------------------------------------------------

7881446: HaikuDepot: Fixed package content extraction
  
  When trying to find a matching parent item, we cannot rely on cached
  pointers to BPackageEntries, since those are re-used per entry level
  from the BPackageReader. Instead, we build the package entry path as
  a string and store that with the list item.
  
  Removed debug output.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48658
Commit:      788144656e52cf4cc1285449b43bffa664c6141c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7881446
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sat Jan 10 23:12:01 2015 UTC

----------------------------------------------------------------------------

1 file changed, 38 insertions(+), 27 deletions(-)
src/apps/haikudepot/ui/PackageContentsView.cpp | 65 +++++++++++++---------

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/ui/PackageContentsView.cpp 
b/src/apps/haikudepot/ui/PackageContentsView.cpp
index ebd8949..c57b81b 100644
--- a/src/apps/haikudepot/ui/PackageContentsView.cpp
+++ b/src/apps/haikudepot/ui/PackageContentsView.cpp
@@ -78,21 +78,23 @@ public:
 
 class PackageEntryItem : public BStringItem {
 public:
-       PackageEntryItem(const BPackageEntry* entry)
+       PackageEntryItem(const BPackageEntry* entry, const BString& path)
                :
                BStringItem(entry->Name()),
-               fEntry(entry)
+               fPath(path)
        {
-               printf("PackageEntryItem(%s)\n", entry->Name());
+               if (fPath.Length() > 0)
+                       fPath.Append("/");
+               fPath.Append(entry->Name());
        }
        
-       inline const BPackageEntry* PackageEntry() const
+       inline const BString& EntryPath() const
        {
-               return fEntry;
+               return fPath;
        }
 
 private:
-       const BPackageEntry* fEntry;
+       BString fPath;
 };
 
 
@@ -119,34 +121,43 @@ public:
 
        virtual status_t HandleEntry(BPackageEntry* entry)
        {
-               printf("HandleEntry(%s/%s)\n",
-                       entry->Parent() != NULL ? entry->Parent()->Name() : 
"NULL",
-                       entry->Name());
-
-               {
-                       // Check if we are still supposed to popuplate the list
-                       BAutolock lock(&fPackageLock);
-                       if (fPackageInfoRef.Get() != fPackageInfoToPopulate)
-                               return B_ERROR;
-               }
+//             printf("HandleEntry(%s/%s)\n",
+//                     entry->Parent() != NULL ? entry->Parent()->Name() : 
"NULL",
+//                     entry->Name());
 
                if (!fListView->LockLooper())
                        return B_ERROR;
 
-               PackageEntryItem* item = new PackageEntryItem(entry);
+               // Check if we are still supposed to popuplate the list
+               if (fPackageInfoRef.Get() != fPackageInfoToPopulate) {
+//                     printf("stopping package content population\n");
+                       fListView->UnlockLooper();
+                       return B_ERROR;
+               }
+
+               BString path;
+               const BPackageEntry* parent = entry->Parent();
+               while (parent != NULL) {
+                       if (path.Length() > 0)
+                               path.Prepend("/");
+                       path.Prepend(parent->Name());
+                       parent = parent->Parent();
+               }
+
+               PackageEntryItem* item = new PackageEntryItem(entry, path);
 
                if (entry->Parent() == NULL) {
-                       printf("  adding root entry\n");
+//                     printf("  adding root entry\n");
                        fListView->AddItem(item);
                        fLastParentEntry = NULL;
                        fLastParentItem = NULL;
                } else if (entry->Parent() == fLastEntry) {
-                       printf("  adding to last entry %s\n", 
fLastEntry->Name());
+//                     printf("  adding to last entry %s\n", 
fLastEntry->Name());
                        fListView->AddUnder(item, fLastItem);
                        fLastParentEntry = fLastEntry;
                        fLastParentItem = fLastItem;
                } else if (entry->Parent() == fLastParentEntry) {
-                       printf("  adding to last parent %s\n", 
fLastParentEntry->Name());
+//                     printf("  adding to last parent %s\n", 
fLastParentEntry->Name());
                        fListView->AddUnder(item, fLastParentItem);
                } else {
                        // Not the last parent entry, need to search for the 
parent
@@ -158,10 +169,10 @@ public:
                                                fListView->FullListItemAt(i));
                                if (listItem == NULL)
                                        continue;
-                               if (listItem->PackageEntry() == 
entry->Parent()) {
-                                       fLastParentEntry = 
listItem->PackageEntry();
+                               if (listItem->EntryPath() == path) {
+                                       fLastParentEntry = entry->Parent();
                                        fLastParentItem = listItem;
-                                       printf("  found parent %s\n", 
listItem->Text());
+//                                     printf("  found parent %s\n", 
listItem->Text());
                                        fListView->AddUnder(item, listItem);
                                        foundParent = true;
                                        break;
@@ -170,8 +181,8 @@ public:
                        if (!foundParent) {
                                // NOTE: Should not happen. Just add this entry 
at the
                                // root level.
-                               printf("Did not find parent entry for %s 
(%s)!\n",
-                                       entry->Name(), entry->Parent()->Name());
+//                             printf("Did not find parent entry for %s 
(%s)!\n",
+//                                     entry->Name(), entry->Parent()->Name());
                                fListView->AddItem(item);
                                fLastParentEntry = NULL;
                                fLastParentItem = NULL;
@@ -275,8 +286,8 @@ PackageContentsView::SetPackage(const PackageInfoRef& 
package)
        if (fPackage == package)
                return;
 
-       printf("PackageContentsView::SetPackage(%s)\n",
-               package.Get() != NULL ? package->Title().String() : "NULL");
+//     printf("PackageContentsView::SetPackage(%s)\n",
+//             package.Get() != NULL ? package->Title().String() : "NULL");
 
        Clear();
 


Other related posts:

  • » [haiku-commits] haiku: hrev48658 - src/apps/haikudepot/ui - superstippi