@@ -257,6 +257,7 @@ MachineStatus::MachineStatus(QObject *parent)
257
257
, refreshTimer(new QTimer(this ))
258
258
{
259
259
d = std::make_unique<MachineStatus::States>(this );
260
+ muteUnmuteAction = nullptr ;
260
261
connect (refreshTimer, &QTimer::timeout, this , &MachineStatus::refreshIcons);
261
262
refreshTimer->start (75 );
262
263
}
@@ -502,7 +503,7 @@ MachineStatus::refresh(QStatusBar *sbar)
502
503
sbar->removeWidget (d->sound .get ());
503
504
504
505
if (!muteUnmuteAction) {
505
- muteUnmuteAction = new QAction ( this ) ;
506
+ muteUnmuteAction = new QAction;
506
507
connect (muteUnmuteAction, &QAction::triggered, this , [this ]() {
507
508
sound_muted ^= 1 ;
508
509
if (d->sound )
@@ -513,11 +514,13 @@ MachineStatus::refresh(QStatusBar *sbar)
513
514
}
514
515
515
516
if (!soundMenu) {
516
- soundMenu = new QMenu (sbar );
517
+ soundMenu = new QMenu ((QWidget*) parent () );
517
518
518
519
soundMenu->addAction (muteUnmuteAction);
519
520
soundMenu->addSeparator ();
520
521
soundMenu->addAction (soundGainAction);
522
+
523
+ muteUnmuteAction->setParent (soundMenu);
521
524
}
522
525
523
526
if (cassette_enable) {
@@ -689,7 +692,8 @@ MachineStatus::refresh(QStatusBar *sbar)
689
692
690
693
d->sound = std::make_unique<ClickableLabel>();
691
694
d->sound ->setPixmap (sound_muted ? d->pixmaps .soundMuted : d->pixmaps .sound );
692
- muteUnmuteAction->setText (sound_muted ? tr (" &Unmute" ) : tr (" &Mute" ));
695
+ if (muteUnmuteAction)
696
+ muteUnmuteAction->setText (sound_muted ? tr (" &Unmute" ) : tr (" &Mute" ));
693
697
694
698
connect (d->sound .get (), &ClickableLabel::clicked, this , [this ](QPoint pos) {
695
699
this ->soundMenu ->popup (pos - QPoint (0 , this ->soundMenu ->sizeHint ().height ()));
0 commit comments