Skip to content
Extraits de code Groupes Projets
Vérifiée Valider bcfcba8c rédigé par Kubat's avatar Kubat
Parcourir les fichiers

FIX: Dead lock with MPV on exit

When closing the window before closing the document where MPV is
initialized, don't close MPV and let the memory leak.

This is OK because the application will close imediatly after that.
parent 4ac3dbcc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!27Draft: Fix mpv deadlock on quit main window
#include "PreCompiledHeaders.hh"
#include "UI/DocumentViews/MpvContainer.hh"
#include "UI/MainWindow.hh"
using namespace Vivy;
using namespace std::string_literals;
......@@ -97,7 +98,17 @@ MpvContainer::closeMpv() noexcept
}
}
MpvContainer::~MpvContainer() noexcept { closeMpv(); }
MpvContainer::~MpvContainer() noexcept
{
if (!(vivyApp->getMainWindow()->isBeingClosed()))
closeMpv();
else {
logWarning() << "The main window was already destroyed, "
"don't destroy MPV and let it leak, "
"the OS will collect the garbage.";
}
}
void
MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept
......
......@@ -161,10 +161,17 @@ MainWindow::MainWindow() noexcept
newDocument();
}
bool
MainWindow::isBeingClosed() const noexcept
{
return privateIsBeingClosed;
}
void
MainWindow::closeEvent(QCloseEvent *event) noexcept
{
logDebug() << "Closing the main window!";
privateIsBeingClosed = true;
forEachViews<VivyDocumentView>([](VivyDocumentView *view, int) { view->closeDocument(); });
QMainWindow::closeEvent(event);
}
......
......@@ -28,9 +28,13 @@ class MainWindow final : public QMainWindow {
QMutex aboutWindowMutex;
AboutWindow *aboutWindow{ nullptr };
bool privateIsBeingClosed{ false };
public:
explicit MainWindow() noexcept;
bool isBeingClosed() const noexcept;
AbstractDocument *getCurrentDocument() const;
template <class Document> Document *getCurrentDocument() const
{
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter