HaikuDepot: Lock model when selecting a package

This commit is contained in:
Stephan Aßmus 2014-12-27 22:09:57 +01:00
parent e1816b5a12
commit 75ba9dbfc3
1 changed files with 11 additions and 6 deletions

View File

@ -380,11 +380,13 @@ MainWindow::MessageReceived(BMessage* message)
{ {
BString title; BString title;
if (message->FindString("title", &title) == B_OK) { if (message->FindString("title", &title) == B_OK) {
BAutolock locker(fModel.Lock());
int count = fVisiblePackages.CountItems(); int count = fVisiblePackages.CountItems();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
const PackageInfoRef& package const PackageInfoRef& package
= fVisiblePackages.ItemAtFast(i); = fVisiblePackages.ItemAtFast(i);
if (package.Get() != NULL && package->Title() == title) { if (package.Get() != NULL && package->Title() == title) {
locker.Unlock();
_AdoptPackage(package); _AdoptPackage(package);
break; break;
} }
@ -662,12 +664,15 @@ MainWindow::_AdoptModel()
void void
MainWindow::_AdoptPackage(const PackageInfoRef& package) MainWindow::_AdoptPackage(const PackageInfoRef& package)
{ {
fPackageInfoView->SetPackage(package); {
BAutolock locker(fModel.Lock());
if (fFeaturedPackagesView != NULL) fPackageInfoView->SetPackage(package);
fFeaturedPackagesView->SelectPackage(package);
if (fPackageListView != NULL) if (fFeaturedPackagesView != NULL)
fPackageListView->SelectPackage(package); fFeaturedPackagesView->SelectPackage(package);
if (fPackageListView != NULL)
fPackageListView->SelectPackage(package);
}
// Trigger asynchronous package population from the web-app // Trigger asynchronous package population from the web-app
{ {