Skip to content

Commit

Permalink
Fix random crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed Mar 6, 2025
1 parent 424a0e6 commit a77e847
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/qt/qt_machinestatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ MachineStatus::MachineStatus(QObject *parent)
, refreshTimer(new QTimer(this))
{
d = std::make_unique<MachineStatus::States>(this);
muteUnmuteAction = nullptr;
connect(refreshTimer, &QTimer::timeout, this, &MachineStatus::refreshIcons);
refreshTimer->start(75);
}
Expand Down Expand Up @@ -502,7 +503,7 @@ MachineStatus::refresh(QStatusBar *sbar)
sbar->removeWidget(d->sound.get());

if (!muteUnmuteAction) {
muteUnmuteAction = new QAction(this);
muteUnmuteAction = new QAction;
connect(muteUnmuteAction, &QAction::triggered, this, [this]() {
sound_muted ^= 1;
if (d->sound)
Expand All @@ -513,11 +514,13 @@ MachineStatus::refresh(QStatusBar *sbar)
}

if (!soundMenu) {
soundMenu = new QMenu(sbar);
soundMenu = new QMenu((QWidget*)parent());

soundMenu->addAction(muteUnmuteAction);
soundMenu->addSeparator();
soundMenu->addAction(soundGainAction);

muteUnmuteAction->setParent(soundMenu);
}

if (cassette_enable) {
Expand Down Expand Up @@ -689,7 +692,8 @@ MachineStatus::refresh(QStatusBar *sbar)

d->sound = std::make_unique<ClickableLabel>();
d->sound->setPixmap(sound_muted ? d->pixmaps.soundMuted : d->pixmaps.sound);
muteUnmuteAction->setText(sound_muted ? tr("&Unmute") : tr("&Mute"));
if (muteUnmuteAction)
muteUnmuteAction->setText(sound_muted ? tr("&Unmute") : tr("&Mute"));

connect(d->sound.get(), &ClickableLabel::clicked, this, [this](QPoint pos) {
this->soundMenu->popup(pos - QPoint(0, this->soundMenu->sizeHint().height()));
Expand Down

0 comments on commit a77e847

Please sign in to comment.