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

UI: Try to fix crashes when creating MPV

Try to force the window creation before passing the WID to MPV to fix
the possibility where the window is not already created and thus
everything crashes.
parent 22c17bbc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -19,6 +19,14 @@ MpvContainer::MpvContainer(QWidget *parent)
setAttribute(Qt::WA_DontCreateNativeAncestors);
setAttribute(Qt::WA_NativeWindow);
}
void
MpvContainer::intializeMpv()
{
if (isMpvAlreadyInitialized)
throw std::logic_error("MPV is already initialized!");
isMpvAlreadyInitialized = true;
quint64 wid = winId();
mpv_set_option(mpv, "wid", MPV_FORMAT_INT64, &wid);
......
......@@ -29,6 +29,7 @@ class MpvContainer final : public QWidget {
private:
bool isPlaybackPaused{ true };
bool isMpvAlreadyInitialized{ false };
mpv_handle *volatile mpv{ nullptr };
qint64 sid{ -1 };
std::function<void(double)> mpvTimeCallback{ nullptr };
......@@ -36,6 +37,7 @@ private:
public:
explicit MpvContainer(QWidget *parent);
void intializeMpv();
~MpvContainer() noexcept override;
void loadFile(const QString &) noexcept;
......
......@@ -14,6 +14,8 @@ VideoView::VideoView(QWidget *parent) noexcept
centralLayout->addWidget(new MpvControls(mpv, this));
setLayout(centralLayout);
mpv->intializeMpv();
}
void
......
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