HaikuDepot: Fix failing to show some packages after refreshing.
Since the package information is refreshed asynchronously, some packages may fit the current filter parameters. Check for this situation more generically in the MSG_PACKAGE_CHANGED notification. Before, it was only done for prominent packages to make them appear in the Featured packages view. The problem was visible by for example selecting a category and then refreshing packages. Many of the previously shown packages would be missing and magically appear when changing filter parameters slightly and back to what they were.
This commit is contained in:
parent
1b5e65f587
commit
57e51fff75
@ -451,13 +451,39 @@ MainWindow::MessageReceived(BMessage* message)
|
||||
BAutolock locker(fModel.Lock());
|
||||
fModel.SetPackageState(ref, ref->State());
|
||||
}
|
||||
if ((changes & PKG_CHANGED_PROMINENCE) != 0) {
|
||||
|
||||
// Asynchronous updates to the package information
|
||||
// can mean that the package needs to be added or
|
||||
// removed to/from the visible packages when the current
|
||||
// filter parameters are re-evaluated on this package.
|
||||
bool wasVisible = fVisiblePackages.Contains(ref);
|
||||
bool isVisible;
|
||||
{
|
||||
BAutolock locker(fModel.Lock());
|
||||
// The package didn't get a chance yet to be in the
|
||||
// visible package list
|
||||
fVisiblePackages = fModel.CreatePackageList();
|
||||
if (ref->IsProminent() && fVisiblePackages.Contains(ref))
|
||||
fFeaturedPackagesView->AddPackage(ref);
|
||||
PackageList visiblePackages = fModel.CreatePackageList();
|
||||
isVisible = visiblePackages.Contains(ref);
|
||||
|
||||
// Transfer this single package, otherwise we miss
|
||||
// other packages if they appear or disappear along
|
||||
// with this one before receive a notification for
|
||||
// them.
|
||||
if (isVisible) {
|
||||
fVisiblePackages.Add(ref);
|
||||
} else if (wasVisible)
|
||||
fVisiblePackages.Remove(ref);
|
||||
}
|
||||
|
||||
if (wasVisible != isVisible) {
|
||||
if (!isVisible) {
|
||||
fPackageListView->RemovePackage(ref);
|
||||
fFeaturedPackagesView->RemovePackage(ref);
|
||||
} else {
|
||||
fPackageListView->AddPackage(ref);
|
||||
if (ref->IsProminent())
|
||||
fFeaturedPackagesView->AddPackage(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user