HaikuDepot: Make sure lists are cleared...
... in case the code runs multiple times for the same package-ref. (Did not happen, but it's just better form.)
This commit is contained in:
@@ -558,6 +558,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
|
||||
&& result.FindMessage("items", &items) == B_OK) {
|
||||
|
||||
BAutolock locker(&fLock);
|
||||
package->ClearUserRatings();
|
||||
|
||||
int index = 0;
|
||||
while (true) {
|
||||
@@ -622,6 +623,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
|
||||
{
|
||||
BAutolock locker(&fLock);
|
||||
screenshotInfos = package->ScreenshotInfos();
|
||||
package->ClearScreenshots();
|
||||
}
|
||||
for (int i = 0; i < screenshotInfos.CountItems(); i++) {
|
||||
const ScreenshotInfo& info = screenshotInfos.ItemAtFast(i);
|
||||
@@ -910,6 +912,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
|
||||
if (categories.FindString(name, &category) != B_OK)
|
||||
break;
|
||||
|
||||
package->ClearCategories();
|
||||
for (int i = fCategories.CountItems() - 1; i >= 0; i--) {
|
||||
const CategoryRef& categoryRef = fCategories.ItemAtFast(i);
|
||||
if (categoryRef->Name() == category) {
|
||||
@@ -940,6 +943,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
|
||||
|
||||
BMessage screenshots;
|
||||
if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) {
|
||||
package->ClearScreenshotInfos();
|
||||
bool foundScreenshot = false;
|
||||
int32 index = 0;
|
||||
while (true) {
|
||||
|
||||
@@ -813,6 +813,16 @@ PackageInfo::IsSystemPackage() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageInfo::ClearCategories()
|
||||
{
|
||||
if (!fCategories.IsEmpty()) {
|
||||
fCategories.Clear();
|
||||
_NotifyListeners(PKG_CHANGED_CATEGORIES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageInfo::AddCategory(const CategoryRef& category)
|
||||
{
|
||||
@@ -861,6 +871,16 @@ PackageInfo::SetDownloadProgress(float progress)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageInfo::ClearUserRatings()
|
||||
{
|
||||
if (!fUserRatings.IsEmpty()) {
|
||||
fUserRatings.Clear();
|
||||
_NotifyListeners(PKG_CHANGED_RATINGS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageInfo::AddUserRating(const UserRating& rating)
|
||||
{
|
||||
@@ -930,6 +950,13 @@ PackageInfo::CalculateRatingSummary() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageInfo::ClearScreenshotInfos()
|
||||
{
|
||||
fScreenshotInfos.Clear();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageInfo::AddScreenshotInfo(const ScreenshotInfo& info)
|
||||
{
|
||||
@@ -937,6 +964,16 @@ PackageInfo::AddScreenshotInfo(const ScreenshotInfo& info)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageInfo::ClearScreenshots()
|
||||
{
|
||||
if (!fScreenshots.IsEmpty()) {
|
||||
fScreenshots.Clear();
|
||||
_NotifyListeners(PKG_CHANGED_SCREENSHOTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageInfo::AddScreenshot(const BitmapRef& screenshot)
|
||||
{
|
||||
|
||||
@@ -312,20 +312,24 @@ public:
|
||||
{ return fDownloadProgress; }
|
||||
void SetDownloadProgress(float progress);
|
||||
|
||||
void ClearCategories();
|
||||
bool AddCategory(const CategoryRef& category);
|
||||
const CategoryList& Categories() const
|
||||
{ return fCategories; }
|
||||
|
||||
void ClearUserRatings();
|
||||
bool AddUserRating(const UserRating& rating);
|
||||
const UserRatingList& UserRatings() const
|
||||
{ return fUserRatings; }
|
||||
void SetRatingSummary(const RatingSummary& summary);
|
||||
RatingSummary CalculateRatingSummary() const;
|
||||
|
||||
void ClearScreenshotInfos();
|
||||
bool AddScreenshotInfo(const ScreenshotInfo& info);
|
||||
const ScreenshotInfoList& ScreenshotInfos() const
|
||||
{ return fScreenshotInfos; }
|
||||
|
||||
void ClearScreenshots();
|
||||
bool AddScreenshot(const BitmapRef& screenshot);
|
||||
const BitmapList& Screenshots() const
|
||||
{ return fScreenshots; }
|
||||
|
||||
Reference in New Issue
Block a user