From Andrew Lindesay <apl@xxxxxxxxxxxxxx>:
Andrew Lindesay has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/3735 ;)
Change subject: HaikuDepot: Remove Custom List
......................................................................
HaikuDepot: Remove Custom List
Further removal of the use of custom list class;
this time with the package action lists.
Also resolve an error created by a last minute
change in the last pull request for this ticket.
Relates To #15534
---
M src/apps/haikudepot/model/PackageAction.h
M src/apps/haikudepot/model/PackageActionHandler.h
M src/apps/haikudepot/ui/MainWindow.cpp
M src/apps/haikudepot/ui/MainWindow.h
M src/apps/haikudepot/ui/PackageInfoView.cpp
5 files changed, 17 insertions(+), 23 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/35/3735/1
diff --git a/src/apps/haikudepot/model/PackageAction.h
b/src/apps/haikudepot/model/PackageAction.h
index c549fba..f04077a 100644
--- a/src/apps/haikudepot/model/PackageAction.h
+++ b/src/apps/haikudepot/model/PackageAction.h
@@ -1,6 +1,7 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@xxxxxx>.
* Copyright 2013, Rene Gollent, <rene@xxxxxxxxxxx>
+ * Copyright 2021, Andrew Lindesay <apl@xxxxxxxxxxxxxx>
*
* All rights reserved. Distributed under the terms of the MIT License.
*/
@@ -64,7 +65,6 @@
typedef BReference<PackageAction> PackageActionRef;
-typedef List<PackageActionRef, false> PackageActionList;
#endif // PACKAGE_ACTION_H
diff --git a/src/apps/haikudepot/model/PackageActionHandler.h
b/src/apps/haikudepot/model/PackageActionHandler.h
index f8b996e..f15e68c 100644
--- a/src/apps/haikudepot/model/PackageActionHandler.h
+++ b/src/apps/haikudepot/model/PackageActionHandler.h
@@ -1,5 +1,6 @@
/*
* Copyright 2013, Rene Gollent <rene@xxxxxxxxxxx>.
+ * Copyright 2021, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
@@ -19,8 +20,8 @@
public:
virtual ~PackageActionHandler();
- virtual status_t SchedulePackageActions(
-
PackageActionList& list) = 0;
+ virtual status_t SchedulePackageAction(
+
PackageActionRef action) = 0;
virtual Model* GetModel() = 0;
};
diff --git a/src/apps/haikudepot/ui/MainWindow.cpp
b/src/apps/haikudepot/ui/MainWindow.cpp
index 72de375..1ffa9cb 100644
--- a/src/apps/haikudepot/ui/MainWindow.cpp
+++ b/src/apps/haikudepot/ui/MainWindow.cpp
@@ -429,7 +429,7 @@
BAutolock locker(fModel.Lock());
package = fModel.PackageForName(name);
}
- if (package.IsSet() || name != package->Name())
+ if (!package.IsSet() || name != package->Name())
debugger("unable to find the named
package");
else
_AdoptPackage(package);
@@ -605,15 +605,11 @@
status_t
-MainWindow::SchedulePackageActions(PackageActionList& list)
+MainWindow::SchedulePackageAction(PackageActionRef action)
{
AutoLocker<BLocker> lock(&fPendingActionsLock);
- for (int32 i = 0; i < list.CountItems(); i++) {
- if (!fPendingActions.Add(list.ItemAtFast(i)))
- return B_NO_MEMORY;
- }
-
- return release_sem_etc(fPendingActionsSem, list.CountItems(), 0);
+ fPendingActions.push(action);
+ return release_sem_etc(fPendingActionsSem, 1, 0);
}
@@ -989,7 +985,7 @@
}
-status_t
+/*static*/ status_t
MainWindow::_PackageActionWorker(void* arg)
{
MainWindow* window = reinterpret_cast<MainWindow*>(arg);
@@ -998,10 +994,10 @@
PackageActionRef ref;
{
AutoLocker<BLocker> lock(&window->fPendingActionsLock);
- ref = window->fPendingActions.ItemAt(0);
+ ref = window->fPendingActions.front();
+ window->fPendingActions.pop();
if (!ref.IsSet())
break;
- window->fPendingActions.Remove(0);
}
BMessenger messenger(window);
diff --git a/src/apps/haikudepot/ui/MainWindow.h
b/src/apps/haikudepot/ui/MainWindow.h
index e86c825..b50d4d6 100644
--- a/src/apps/haikudepot/ui/MainWindow.h
+++ b/src/apps/haikudepot/ui/MainWindow.h
@@ -2,7 +2,7 @@
* Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
* Copyright 2013, Rene Gollent <rene@xxxxxxxxxxx>.
* Copyright 2017, Julian Harnath <julian.harnath@xxxxxxxxxxxxxx>.
- * Copyright 2017-2020, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * Copyright 2017-2021, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef MAIN_WINDOW_H
@@ -66,8 +66,7 @@
private:
// PackageActionHandler
- virtual status_t SchedulePackageActions(
-
PackageActionList& list);
+ virtual status_t
SchedulePackageAction(PackageActionRef action);
virtual Model* GetModel();
private:
@@ -168,7 +167,8 @@
bool fSinglePackageMode;
thread_id fPendingActionsWorker;
- PackageActionList fPendingActions;
+ std::queue<PackageActionRef>
+ fPendingActions;
BLocker fPendingActionsLock;
sem_id fPendingActionsSem;
diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp
b/src/apps/haikudepot/ui/PackageInfoView.cpp
index 0f22a54..a7fe408 100644
--- a/src/apps/haikudepot/ui/PackageInfoView.cpp
+++ b/src/apps/haikudepot/ui/PackageInfoView.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 2013-2014, Stephan Aßmus <superstippi@xxxxxx>.
- * Copyright 2018-2020, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * Copyright 2018-2021, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
@@ -638,10 +638,7 @@
if (!action.IsSet())
return;
- PackageActionList actions;
- actions.Add(action);
- status_t result
- =
fPackageActionHandler->SchedulePackageActions(actions);
+ status_t result =
fPackageActionHandler->SchedulePackageAction(action);
if (result != B_OK) {
HDERROR("Failed to schedule action: %s '%s': %s",
--
To view, visit https://review.haiku-os.org/c/haiku/+/3735
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I85dd40b7ef664f93b24ca5041fa58cca17d72299
Gerrit-Change-Number: 3735
Gerrit-PatchSet: 1
Gerrit-Owner: Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Gerrit-MessageType: newchange