Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 5c1b1530 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 34632648
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!23Try to fix crashes when creating and deleting MPV
...@@ -19,6 +19,14 @@ MpvContainer::MpvContainer(QWidget *parent) ...@@ -19,6 +19,14 @@ MpvContainer::MpvContainer(QWidget *parent)
setAttribute(Qt::WA_DontCreateNativeAncestors); setAttribute(Qt::WA_DontCreateNativeAncestors);
setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_NativeWindow);
}
void
MpvContainer::intializeMpv()
{
if (isMpvAlreadyInitialized)
throw std::logic_error("MPV is already initialized!");
isMpvAlreadyInitialized = true;
quint64 wid = winId(); quint64 wid = winId();
mpv_set_option(mpv, "wid", MPV_FORMAT_INT64, &wid); mpv_set_option(mpv, "wid", MPV_FORMAT_INT64, &wid);
......
...@@ -32,6 +32,7 @@ class MpvContainer final : public QWidget { ...@@ -32,6 +32,7 @@ class MpvContainer final : public QWidget {
private: private:
bool isPlaybackPaused{ true }; bool isPlaybackPaused{ true };
bool isMpvAlreadyInitialized{ false };
mpv_handle *volatile mpv{ nullptr }; mpv_handle *volatile mpv{ nullptr };
qint64 sid{ -1 }; qint64 sid{ -1 };
std::function<void(double)> mpvTimeCallback{ nullptr }; std::function<void(double)> mpvTimeCallback{ nullptr };
...@@ -39,6 +40,7 @@ private: ...@@ -39,6 +40,7 @@ private:
public: public:
explicit MpvContainer(QWidget *parent); explicit MpvContainer(QWidget *parent);
void intializeMpv();
~MpvContainer() noexcept override; ~MpvContainer() noexcept override;
void loadFile(const QString &) noexcept; void loadFile(const QString &) noexcept;
......
...@@ -14,6 +14,8 @@ VideoView::VideoView(QWidget *parent) noexcept ...@@ -14,6 +14,8 @@ VideoView::VideoView(QWidget *parent) noexcept
centralLayout->addWidget(new MpvControls(mpv, this)); centralLayout->addWidget(new MpvControls(mpv, this));
setLayout(centralLayout); setLayout(centralLayout);
mpv->intializeMpv();
} }
void 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