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) {
|
&& result.FindMessage("items", &items) == B_OK) {
|
||||||
|
|
||||||
BAutolock locker(&fLock);
|
BAutolock locker(&fLock);
|
||||||
|
package->ClearUserRatings();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -622,6 +623,7 @@ Model::PopulatePackage(const PackageInfoRef& package, uint32 flags)
|
|||||||
{
|
{
|
||||||
BAutolock locker(&fLock);
|
BAutolock locker(&fLock);
|
||||||
screenshotInfos = package->ScreenshotInfos();
|
screenshotInfos = package->ScreenshotInfos();
|
||||||
|
package->ClearScreenshots();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < screenshotInfos.CountItems(); i++) {
|
for (int i = 0; i < screenshotInfos.CountItems(); i++) {
|
||||||
const ScreenshotInfo& info = screenshotInfos.ItemAtFast(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)
|
if (categories.FindString(name, &category) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
package->ClearCategories();
|
||||||
for (int i = fCategories.CountItems() - 1; i >= 0; i--) {
|
for (int i = fCategories.CountItems() - 1; i >= 0; i--) {
|
||||||
const CategoryRef& categoryRef = fCategories.ItemAtFast(i);
|
const CategoryRef& categoryRef = fCategories.ItemAtFast(i);
|
||||||
if (categoryRef->Name() == category) {
|
if (categoryRef->Name() == category) {
|
||||||
@@ -940,6 +943,7 @@ Model::_PopulatePackageInfo(const PackageInfoRef& package, const BMessage& data)
|
|||||||
|
|
||||||
BMessage screenshots;
|
BMessage screenshots;
|
||||||
if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) {
|
if (data.FindMessage("pkgScreenshots", &screenshots) == B_OK) {
|
||||||
|
package->ClearScreenshotInfos();
|
||||||
bool foundScreenshot = false;
|
bool foundScreenshot = false;
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|||||||
@@ -813,6 +813,16 @@ PackageInfo::IsSystemPackage() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageInfo::ClearCategories()
|
||||||
|
{
|
||||||
|
if (!fCategories.IsEmpty()) {
|
||||||
|
fCategories.Clear();
|
||||||
|
_NotifyListeners(PKG_CHANGED_CATEGORIES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PackageInfo::AddCategory(const CategoryRef& category)
|
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
|
bool
|
||||||
PackageInfo::AddUserRating(const UserRating& rating)
|
PackageInfo::AddUserRating(const UserRating& rating)
|
||||||
{
|
{
|
||||||
@@ -930,6 +950,13 @@ PackageInfo::CalculateRatingSummary() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageInfo::ClearScreenshotInfos()
|
||||||
|
{
|
||||||
|
fScreenshotInfos.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PackageInfo::AddScreenshotInfo(const ScreenshotInfo& info)
|
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
|
bool
|
||||||
PackageInfo::AddScreenshot(const BitmapRef& screenshot)
|
PackageInfo::AddScreenshot(const BitmapRef& screenshot)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -312,20 +312,24 @@ public:
|
|||||||
{ return fDownloadProgress; }
|
{ return fDownloadProgress; }
|
||||||
void SetDownloadProgress(float progress);
|
void SetDownloadProgress(float progress);
|
||||||
|
|
||||||
|
void ClearCategories();
|
||||||
bool AddCategory(const CategoryRef& category);
|
bool AddCategory(const CategoryRef& category);
|
||||||
const CategoryList& Categories() const
|
const CategoryList& Categories() const
|
||||||
{ return fCategories; }
|
{ return fCategories; }
|
||||||
|
|
||||||
|
void ClearUserRatings();
|
||||||
bool AddUserRating(const UserRating& rating);
|
bool AddUserRating(const UserRating& rating);
|
||||||
const UserRatingList& UserRatings() const
|
const UserRatingList& UserRatings() const
|
||||||
{ return fUserRatings; }
|
{ return fUserRatings; }
|
||||||
void SetRatingSummary(const RatingSummary& summary);
|
void SetRatingSummary(const RatingSummary& summary);
|
||||||
RatingSummary CalculateRatingSummary() const;
|
RatingSummary CalculateRatingSummary() const;
|
||||||
|
|
||||||
|
void ClearScreenshotInfos();
|
||||||
bool AddScreenshotInfo(const ScreenshotInfo& info);
|
bool AddScreenshotInfo(const ScreenshotInfo& info);
|
||||||
const ScreenshotInfoList& ScreenshotInfos() const
|
const ScreenshotInfoList& ScreenshotInfos() const
|
||||||
{ return fScreenshotInfos; }
|
{ return fScreenshotInfos; }
|
||||||
|
|
||||||
|
void ClearScreenshots();
|
||||||
bool AddScreenshot(const BitmapRef& screenshot);
|
bool AddScreenshot(const BitmapRef& screenshot);
|
||||||
const BitmapList& Screenshots() const
|
const BitmapList& Screenshots() const
|
||||||
{ return fScreenshots; }
|
{ return fScreenshots; }
|
||||||
|
|||||||
Reference in New Issue
Block a user