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.
This commit is contained in:
Augustin Cavalier 2019-01-26 15:36:43 -05:00
parent 132990ecdc
commit 4bf8cf7a1b

View File

@ -169,9 +169,14 @@ static void
start_watching_for_parameter_changes(BControl* control, BParameter &parameter) start_watching_for_parameter_changes(BControl* control, BParameter &parameter)
{ {
BMediaRoster* roster = BMediaRoster::CurrentRoster(); BMediaRoster* roster = BMediaRoster::CurrentRoster();
if (roster != NULL) { if (roster == NULL)
roster->StartWatching(control, parameter.Web()->Node(), return;
B_MEDIA_NEW_PARAMETER_VALUE);
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 &parameter) stop_watching_for_parameter_changes(BControl* control, BParameter &parameter)
{ {
BMediaRoster* roster = BMediaRoster::CurrentRoster(); BMediaRoster* roster = BMediaRoster::CurrentRoster();
if (roster != NULL) { if (roster == NULL)
roster->StopWatching(control, parameter.Web()->Node(), return;
B_MEDIA_NEW_PARAMETER_VALUE);
} roster->StopWatching(control, parameter.Web()->Node(),
B_MEDIA_NEW_PARAMETER_VALUE);
} }
@ -296,6 +302,9 @@ CheckBox::~CheckBox()
void void
CheckBox::AttachedToWindow() CheckBox::AttachedToWindow()
{ {
BCheckBox::AttachedToWindow();
SetTarget(this);
start_watching_for_parameter_changes(this, fParameter); start_watching_for_parameter_changes(this, fParameter);
} }
@ -323,6 +332,9 @@ OptionPopUp::~OptionPopUp()
void void
OptionPopUp::AttachedToWindow() OptionPopUp::AttachedToWindow()
{ {
BOptionPopUp::AttachedToWindow();
SetTarget(this);
start_watching_for_parameter_changes(this, fParameter); start_watching_for_parameter_changes(this, fParameter);
} }
@ -350,6 +362,9 @@ Slider::~Slider()
void void
Slider::AttachedToWindow() Slider::AttachedToWindow()
{ {
BSlider::AttachedToWindow();
SetTarget(this);
start_watching_for_parameter_changes(this, fParameter); start_watching_for_parameter_changes(this, fParameter);
} }
@ -377,9 +392,10 @@ ChannelSlider::~ChannelSlider()
void void
ChannelSlider::AttachedToWindow() ChannelSlider::AttachedToWindow()
{ {
start_watching_for_parameter_changes(this, fParameter);
BChannelSlider::AttachedToWindow(); BChannelSlider::AttachedToWindow();
SetTarget(this);
start_watching_for_parameter_changes(this, fParameter);
} }