From 4bf8cf7a1b011c7e8a7fc75f1921fef8379baf9d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 26 Jan 2019 15:36:43 -0500 Subject: [PATCH] DefaultMediaTheme: Properly set control targets. In removing the "GroupView" class and replacing it with a real BGroupView, I missed that it its AttachedToWindow() implementation iterated over all child controls and set their targets to themselves. It seems this is how the Media Kit gets change messages from them, and so the lack of this broke changing parameter values. Whoops. But it seems that changing menu option values has been broken for a long time (perhaps forever?), as in order for a BOptionPopUp to send messages to anything, its AttachedToWindow() must be called (as this sets the BMenuItem's targets to itself, so it can forward the messages.) So now that is fixed too. --- src/kits/media/DefaultMediaTheme.cpp | 34 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/kits/media/DefaultMediaTheme.cpp b/src/kits/media/DefaultMediaTheme.cpp index ea921193cd..d2566939da 100644 --- a/src/kits/media/DefaultMediaTheme.cpp +++ b/src/kits/media/DefaultMediaTheme.cpp @@ -169,9 +169,14 @@ static void start_watching_for_parameter_changes(BControl* control, BParameter ¶meter) { BMediaRoster* roster = BMediaRoster::CurrentRoster(); - if (roster != NULL) { - roster->StartWatching(control, parameter.Web()->Node(), - B_MEDIA_NEW_PARAMETER_VALUE); + if (roster == NULL) + return; + + if (roster->StartWatching(control, parameter.Web()->Node(), + B_MEDIA_NEW_PARAMETER_VALUE) != B_OK) { + fprintf(stderr, "DefaultMediaTheme: Failed to start watching parameter" + "\"%s\"\n", parameter.Name()); + return; } } @@ -180,10 +185,11 @@ static void stop_watching_for_parameter_changes(BControl* control, BParameter ¶meter) { BMediaRoster* roster = BMediaRoster::CurrentRoster(); - if (roster != NULL) { - roster->StopWatching(control, parameter.Web()->Node(), - B_MEDIA_NEW_PARAMETER_VALUE); - } + if (roster == NULL) + return; + + roster->StopWatching(control, parameter.Web()->Node(), + B_MEDIA_NEW_PARAMETER_VALUE); } @@ -296,6 +302,9 @@ CheckBox::~CheckBox() void CheckBox::AttachedToWindow() { + BCheckBox::AttachedToWindow(); + + SetTarget(this); start_watching_for_parameter_changes(this, fParameter); } @@ -323,6 +332,9 @@ OptionPopUp::~OptionPopUp() void OptionPopUp::AttachedToWindow() { + BOptionPopUp::AttachedToWindow(); + + SetTarget(this); start_watching_for_parameter_changes(this, fParameter); } @@ -350,6 +362,9 @@ Slider::~Slider() void Slider::AttachedToWindow() { + BSlider::AttachedToWindow(); + + SetTarget(this); start_watching_for_parameter_changes(this, fParameter); } @@ -377,9 +392,10 @@ ChannelSlider::~ChannelSlider() void ChannelSlider::AttachedToWindow() { - start_watching_for_parameter_changes(this, fParameter); - BChannelSlider::AttachedToWindow(); + + SetTarget(this); + start_watching_for_parameter_changes(this, fParameter); }