Skip to content

Commit e228c7f

Browse files
Fix memory error on quit
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
1 parent 60f3dd7 commit e228c7f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

tools/vrsplayer/FileReader.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ void FileReader::setState(FileReaderState newState) {
13031303
time_.pause();
13041304
}
13051305
}
1306-
cout << "Video state: " << FileReaderStateConverter::toString(newState) << "\n";
13071306
mediaStateChanged(state_);
13081307
}
13091308

tools/vrsplayer/PlayerWindow.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ void PlayerWindow::updateLayoutAndPresetMenu(
161161
const QVariant& currentPreset) {
162162
layoutMenu_->clear();
163163
layoutActionsAndPreset_.clear();
164+
if (player_.getFileReader().getState() == FileReaderState::NoMedia) {
165+
return;
166+
}
164167
if (visibleCount < frameCount) {
165168
unique_ptr<QAction> layoutAction = make_unique<QAction>(QString("Show All Streams"), this);
166169
connect(layoutAction.get(), &QAction::triggered, [this]() { player_.showAllStreams(); });
@@ -237,6 +240,9 @@ void PlayerWindow::updateLayoutAndPresetMenu(
237240

238241
void PlayerWindow::updateTextOverlayMenu() {
239242
textOverlayMenu_->clear();
243+
if (player_.getFileReader().getState() == FileReaderState::NoMedia) {
244+
return;
245+
}
240246
QColor color = player_.getOverlayColor();
241247
addColorAction(color, Qt::white, "Use White");
242248
addColorAction(color, Qt::black, "Use Black");
@@ -270,6 +276,9 @@ void PlayerWindow::updateTextOverlayMenu() {
270276
void PlayerWindow::updateAudioMenu() {
271277
audioMenu_->clear();
272278
audioActions_.clear();
279+
if (player_.getFileReader().getState() == FileReaderState::NoMedia) {
280+
return;
281+
}
273282
if (audioChannelCount_ == 0 || playbackChannelCount_ == 0) {
274283
auto noAudioAction = make_unique<QAction>(
275284
audioChannelCount_ == 0 ? "No Playable Audio" : "No Audio Playback Device", this);

0 commit comments

Comments
 (0)