Skip to content

Commit

Permalink
Remove modifyLock_ from ViewGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Nov 11, 2023
1 parent d4833b7 commit 5146a2a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
10 changes: 0 additions & 10 deletions Common/UI/ViewGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ ViewGroup::~ViewGroup() {
}

void ViewGroup::RemoveSubview(View *subView) {
std::lock_guard<std::mutex> guard(modifyLock_);
// loop counter needed, so can't convert loop.
for (size_t i = 0; i < views_.size(); i++) {
if (views_[i] == subView) {
Expand All @@ -68,16 +67,13 @@ bool ViewGroup::ContainsSubview(const View *view) const {
}

void ViewGroup::Clear() {
std::lock_guard<std::mutex> guard(modifyLock_);
for (View *view : views_) {
delete view;
}
views_.clear();
}

void ViewGroup::PersistData(PersistStatus status, std::string anonId, PersistMap &storage) {
std::lock_guard<std::mutex> guard(modifyLock_);

std::string tag = Tag();
if (tag.empty()) {
tag = anonId;
Expand All @@ -89,7 +85,6 @@ void ViewGroup::PersistData(PersistStatus status, std::string anonId, PersistMap
}

bool ViewGroup::Touch(const TouchInput &input) {
std::lock_guard<std::mutex> guard(modifyLock_);
bool any = false;
for (View *view : views_) {
// TODO: If there is a transformation active, transform input coordinates accordingly.
Expand Down Expand Up @@ -118,7 +113,6 @@ void ViewGroup::Query(float x, float y, std::vector<View *> &list) {
}

bool ViewGroup::Key(const KeyInput &input) {
std::lock_guard<std::mutex> guard(modifyLock_);
bool ret = false;
for (View *view : views_) {
// TODO: If there is a transformation active, transform input coordinates accordingly.
Expand All @@ -129,7 +123,6 @@ bool ViewGroup::Key(const KeyInput &input) {
}

void ViewGroup::Axis(const AxisInput &input) {
std::lock_guard<std::mutex> guard(modifyLock_);
for (View *view : views_) {
// TODO: If there is a transformation active, transform input coordinates accordingly.
if (view->GetVisibility() == V_VISIBLE)
Expand All @@ -138,14 +131,12 @@ void ViewGroup::Axis(const AxisInput &input) {
}

void ViewGroup::DeviceLost() {
std::lock_guard<std::mutex> guard(modifyLock_);
for (View *view : views_) {
view->DeviceLost();
}
}

void ViewGroup::DeviceRestored(Draw::DrawContext *draw) {
std::lock_guard<std::mutex> guard(modifyLock_);
for (View *view : views_) {
view->DeviceRestored(draw);
}
Expand Down Expand Up @@ -245,7 +236,6 @@ void ViewGroup::Update() {
}

bool ViewGroup::SetFocus() {
std::lock_guard<std::mutex> guard(modifyLock_);
if (!CanBeFocused() && !views_.empty()) {
for (View *view : views_) {
if (view->SetFocus())
Expand Down
5 changes: 0 additions & 5 deletions Common/UI/ViewGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class ViewGroup : public View {
// Takes ownership! DO NOT add a view to multiple parents!
template <class T>
T *Add(T *view) {
std::lock_guard<std::mutex> guard(modifyLock_);
views_.push_back(view);
return view;
}
Expand Down Expand Up @@ -76,9 +75,6 @@ class ViewGroup : public View {
void SetExclusiveTouch(bool exclusive) { exclusiveTouch_ = exclusive; }
void SetClickableBackground(bool clickableBackground) { clickableBackground_ = clickableBackground; }

void Lock() { modifyLock_.lock(); }
void Unlock() { modifyLock_.unlock(); }

void SetClip(bool clip) { clip_ = clip; }
std::string DescribeLog() const override { return "ViewGroup: " + View::DescribeLog(); }
std::string DescribeText() const override;
Expand All @@ -87,7 +83,6 @@ class ViewGroup : public View {
std::string DescribeListUnordered(const char *heading) const;
std::string DescribeListOrdered(const char *heading) const;

std::mutex modifyLock_; // Hold this when changing the subviews.
std::vector<View *> views_;
View *defaultFocusView_ = nullptr;
Drawable bg_;
Expand Down

0 comments on commit 5146a2a

Please sign in to comment.