-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix) Controller: clear mapping pointer when unloading a mapping #13907
base: 2.5
Are you sure you want to change the base?
Conversation
void setMapping(std::shared_ptr<LegacyControllerMapping> pMapping) override; | ||
void clearMapping() override { | ||
m_pMapping = nullptr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just call setMapping
with a nullptr
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the first thing I tried.
Gives me this when selecting No mapping
DEBUG ASSERT: "pMapping.use_count() == 1" in function std::shared_ptr<_Tp> Controller::downcastAndTakeOwnership(std::shared_ptr<LegacyControllerMapping>&&) [with SpecificMappingType = LegacyMidiControllerMapping] at ./src/controllers/controller.h:89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mixxx/src/controllers/controller.h
Lines 82 to 96 in 815219d
std::shared_ptr<SpecificMappingType> downcastAndTakeOwnership( | |
std::shared_ptr<LegacyControllerMapping>&& pMapping) { | |
// Controller cannot take ownership if pMapping is referenced elsewhere because | |
// the controller polling thread needs exclusive accesses to the non-thread safe | |
// LegacyControllerMapping. | |
// Trying to cast a std::shared_ptr to a std::unique_ptr is not worth the trouble. | |
VERIFY_OR_DEBUG_ASSERT(pMapping.use_count() == 1) { | |
return nullptr; | |
} | |
auto pDowncastedMapping = std::dynamic_pointer_cast<SpecificMappingType>(pMapping); | |
VERIFY_OR_DEBUG_ASSERT(pDowncastedMapping) { | |
return nullptr; | |
} | |
return pDowncastedMapping; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, that function does not take that usecase into account. Simply add a if (pMapping == nullptr) { return nullptr; }
so it supports that usecase. Alternatively you can add the appropriate handling to the setMapping
implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I only took a brief look at this and didn't want to touch it.
But yeah, that's a straight forward solution.
Thanks!
Not that I know of, possibly lost during refactoring? |
eb6f94a
to
e6fb932
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conceptually LGTM. Thank you. Waiting for CI.
With #13842 I noticed that the controller's pMapping still points to the previously loaded mapping when loading 'No mapping'.
Is there any reason for that?