Skip to content

Commit

Permalink
Fix memory error on quit
Browse files Browse the repository at this point in the history
Summary:
Users have reported a memory corruption on quit when working with some files. When I finaly was able to reproduce the issue in the debugger, I was able to see the error happened when destroying menus. When quitting, we end up updating the menus during teardown, which looks like it's the cause of the issues. By preventing menu updates during teardown, I can't repro the issue again.

note: this bug used to be fairly rare, but recent changes have made it much more frequent.

Differential Revision: D68998315

fbshipit-source-id: 7fc54436e49fac26fd8fabea2220fea192bf2455
  • Loading branch information
Georges Berenger authored and facebook-github-bot committed Feb 3, 2025
1 parent 60f3dd7 commit e228c7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion tools/vrsplayer/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,6 @@ void FileReader::setState(FileReaderState newState) {
time_.pause();
}
}
cout << "Video state: " << FileReaderStateConverter::toString(newState) << "\n";
mediaStateChanged(state_);
}

Expand Down
9 changes: 9 additions & 0 deletions tools/vrsplayer/PlayerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ void PlayerWindow::updateLayoutAndPresetMenu(
const QVariant& currentPreset) {
layoutMenu_->clear();
layoutActionsAndPreset_.clear();
if (player_.getFileReader().getState() == FileReaderState::NoMedia) {
return;
}
if (visibleCount < frameCount) {
unique_ptr<QAction> layoutAction = make_unique<QAction>(QString("Show All Streams"), this);
connect(layoutAction.get(), &QAction::triggered, [this]() { player_.showAllStreams(); });
Expand Down Expand Up @@ -237,6 +240,9 @@ void PlayerWindow::updateLayoutAndPresetMenu(

void PlayerWindow::updateTextOverlayMenu() {
textOverlayMenu_->clear();
if (player_.getFileReader().getState() == FileReaderState::NoMedia) {
return;
}
QColor color = player_.getOverlayColor();
addColorAction(color, Qt::white, "Use White");
addColorAction(color, Qt::black, "Use Black");
Expand Down Expand Up @@ -270,6 +276,9 @@ void PlayerWindow::updateTextOverlayMenu() {
void PlayerWindow::updateAudioMenu() {
audioMenu_->clear();
audioActions_.clear();
if (player_.getFileReader().getState() == FileReaderState::NoMedia) {
return;
}
if (audioChannelCount_ == 0 || playbackChannelCount_ == 0) {
auto noAudioAction = make_unique<QAction>(
audioChannelCount_ == 0 ? "No Playable Audio" : "No Audio Playback Device", this);
Expand Down

0 comments on commit e228c7f

Please sign in to comment.