mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-10-06 09:17:07 +02:00
Fix long standing qml error internal crash
We now wait until the event loop is done until we call terminate. Before ScreenPlayWallpaper would crash internally and stay alive as a zombie process for some reason...
This commit is contained in:
parent
10eabc0a56
commit
d129bf5cf4
@ -1,10 +1,10 @@
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <QtGlobal>
|
||||
#include <QtWebEngineQuick>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include "ScreenPlayUtil/exitcodes.h"
|
||||
#include "ScreenPlayUtil/util.h"
|
||||
@ -114,5 +114,6 @@ int main(int argc, char* argv[])
|
||||
if (startStatus != ScreenPlay::WallpaperExitCode::Ok) {
|
||||
return static_cast<int>(startStatus);
|
||||
}
|
||||
emit window.qmlStart();
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
import QtQuick
|
||||
import ScreenPlayWallpaper
|
||||
|
||||
|
||||
AnimatedImage {
|
||||
Component.onCompleted: Wallpaper.requestFadeIn();
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ Item {
|
||||
|
||||
onIsPlayingChanged: isPlaying ? mediaPlayer.play() : mediaPlayer.pause()
|
||||
property bool isWindows: Qt.platform.os === "windows"
|
||||
property bool ready: false
|
||||
|
||||
property string source: Wallpaper.projectSourceFileAbsolute
|
||||
onSourceChanged: {
|
||||
@ -37,7 +36,7 @@ Item {
|
||||
id: mediaPlayer
|
||||
onPlaybackStateChanged: {
|
||||
if (mediaPlayer.playbackState == MediaPlayer.PlayingState) {
|
||||
root.ready = true;
|
||||
Wallpaper.requestFadeIn();
|
||||
}
|
||||
}
|
||||
loops: root.loops ? MediaPlayer.Infinite : 1
|
||||
|
@ -9,8 +9,6 @@ import ScreenPlayWallpaper
|
||||
Item {
|
||||
id: root
|
||||
|
||||
signal requestFadeIn
|
||||
|
||||
function getSetVideoCommand() {
|
||||
// TODO 30:
|
||||
// Currently wont work. Commit anyways til QtCreator and Qt work with js template literals
|
||||
@ -48,7 +46,7 @@ Item {
|
||||
onLoadProgressChanged: {
|
||||
if (loadProgress === 100) {
|
||||
webView.runJavaScript(root.getSetVideoCommand(), function (result) {
|
||||
requestFadeIn();
|
||||
Wallpaper.requestFadeIn();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,11 @@ Rectangle {
|
||||
//Image
|
||||
property real imgOpacity: 0.75
|
||||
|
||||
signal requestFadeIn
|
||||
|
||||
anchors.fill: parent
|
||||
color: Material.color(Material.Grey, Material.Shade800)
|
||||
border.width: 10
|
||||
border.color: "orange"
|
||||
Component.onCompleted: root.requestFadeIn()
|
||||
Component.onCompleted: Wallpaper.requestFadeIn();
|
||||
|
||||
MouseArea {
|
||||
|
||||
|
@ -9,8 +9,9 @@ Rectangle {
|
||||
id: root
|
||||
|
||||
property bool canFadeByWallpaperFillMode: true
|
||||
anchors.fill: parent
|
||||
|
||||
function init() {
|
||||
function start() {
|
||||
fadeInImageSetup();
|
||||
switch (Wallpaper.type) {
|
||||
case InstalledType.VideoWallpaper:
|
||||
@ -130,19 +131,15 @@ Rectangle {
|
||||
imgCover.opacity = 0;
|
||||
}
|
||||
|
||||
anchors.fill: parent
|
||||
color: {
|
||||
if (Qt.platform.os !== "windows")
|
||||
return "black";
|
||||
else
|
||||
return Wallpaper.windowsDesktopProperties.color;
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
init();
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Wallpaper
|
||||
function onQmlStart(){
|
||||
root.start()
|
||||
}
|
||||
function onFadeIn(){
|
||||
root.fadeIn()
|
||||
}
|
||||
function onQmlExit() {
|
||||
if (canFadeByWallpaperFillMode && Wallpaper.canFade)
|
||||
imgCover.state = "exit";
|
||||
@ -180,23 +177,31 @@ Rectangle {
|
||||
loader.source = "qrc:/qml/ScreenPlayWallpaper/qml/MultimediaView.qml";
|
||||
}
|
||||
|
||||
target: Wallpaper
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
// QML Engine deadlocks in 5.15.2 when a loader cannot load
|
||||
// an item. QApplication::quit(); waits for the destruction forever.
|
||||
// an item. QGuiApplication::quit(); waits for the destruction forever.
|
||||
//asynchronous: true
|
||||
onStatusChanged: {
|
||||
if (loader.status === Loader.Ready) {
|
||||
if (loader.item.ready)
|
||||
if(Wallpaper.type === InstalledType.QMLWallpaper) {
|
||||
root.fadeIn();
|
||||
}
|
||||
}
|
||||
if (loader.status === Loader.Error) {
|
||||
loader.source = "";
|
||||
imgCover.state = "exit";
|
||||
print("ScreenPlayWallpaper encountered an error and will be terminated.")
|
||||
// Must be callLater so we do not kill on startup
|
||||
// See emit window.qmlStart();
|
||||
Qt.callLater(function(){
|
||||
loader.source = ""
|
||||
Qt.callLater(function(){
|
||||
Wallpaper.terminate()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -316,21 +321,6 @@ Rectangle {
|
||||
font.pointSize: 14
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "sdk.type " + Wallpaper.sdk.type
|
||||
font.pointSize: 14
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "sdk.isConnected " + Wallpaper.sdk.isConnected
|
||||
font.pointSize: 14
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "sdk.appID " + Wallpaper.sdk.appID
|
||||
font.pointSize: 14
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "canFadeByWallpaperFillMode " + canFadeByWallpaperFillMode
|
||||
font.pointSize: 14
|
||||
|
@ -7,8 +7,6 @@ Item {
|
||||
|
||||
property string url
|
||||
|
||||
signal requestFadeIn
|
||||
|
||||
Component.onCompleted: {
|
||||
WebEngine.settings.localContentCanAccessFileUrls = true;
|
||||
WebEngine.settings.localContentCanAccessRemoteUrls = true;
|
||||
@ -27,8 +25,8 @@ Item {
|
||||
url: Qt.resolvedUrl(root.url)
|
||||
onJavaScriptConsoleMessage: print(lineNumber, message)
|
||||
onLoadProgressChanged: {
|
||||
if ((loadProgress === 100))
|
||||
root.requestFadeIn();
|
||||
if (loadProgress === 100)
|
||||
Wallpaper.requestFadeIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
|
||||
/*!
|
||||
\module ScreenPlayWallpaper
|
||||
\title ScreenPlayWallpaper
|
||||
@ -178,6 +177,15 @@ void BaseWindow::replaceWallpaper(
|
||||
emit reloadGIF(oldType);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief QML Convenience function for global fade in
|
||||
*/
|
||||
void BaseWindow::requestFadeIn()
|
||||
{
|
||||
emit fadeIn();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Used for loading shader. Loading shader relative to the qml file will be available in Qt 6
|
||||
*/
|
||||
@ -233,5 +241,5 @@ void BaseWindow::setVideoCodec(ScreenPlay::VideoCodec::VideoCodec newVideoCodec)
|
||||
if (m_videoCodec == newVideoCodec)
|
||||
return;
|
||||
m_videoCodec = newVideoCodec;
|
||||
emit videoCodecChanged();
|
||||
emit videoCodecChanged(newVideoCodec);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileSystemWatcher>
|
||||
@ -87,7 +86,9 @@ public:
|
||||
void setVideoCodec(ScreenPlay::VideoCodec::VideoCodec newVideoCodec);
|
||||
|
||||
signals:
|
||||
void qmlStart();
|
||||
void qmlExit();
|
||||
void fadeIn();
|
||||
void reloadQML(const ScreenPlay::InstalledType::InstalledType oldType);
|
||||
void reloadVideo(const ScreenPlay::InstalledType::InstalledType oldType);
|
||||
void reloadGIF(const ScreenPlay::InstalledType::InstalledType oldType);
|
||||
@ -114,10 +115,12 @@ signals:
|
||||
void projectPathChanged(const QString& rojectPath);
|
||||
void projectSourceFileChanged(const QString& projectSourceFile);
|
||||
void projectSourceFileAbsoluteChanged(const QUrl& rojectSourceFileAbsolute);
|
||||
void videoCodecChanged();
|
||||
void videoCodecChanged(ScreenPlay::VideoCodec::VideoCodec codec);
|
||||
|
||||
public slots:
|
||||
void requestFadeIn();
|
||||
virtual void destroyThis() { }
|
||||
virtual void terminate() { }
|
||||
virtual void setVisible(bool show) { Q_UNUSED(show) }
|
||||
virtual void messageReceived(QString key, QString value) final;
|
||||
virtual void clearComponentCache() { }
|
||||
|
@ -136,3 +136,8 @@ void LinuxX11Window::destroyThis()
|
||||
{
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
void LinuxX11Window::terminate()
|
||||
{
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QQmlContext>
|
||||
@ -26,6 +25,7 @@ signals:
|
||||
public slots:
|
||||
void setVisible(bool show) override;
|
||||
void destroyThis() override;
|
||||
void terminate() override;
|
||||
|
||||
private:
|
||||
QQuickView m_window;
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
class MacBridge : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QQmlContext>
|
||||
@ -26,7 +25,7 @@ signals:
|
||||
public slots:
|
||||
void setVisible(bool show) override;
|
||||
void destroyThis() override;
|
||||
void terminate();
|
||||
void terminate() override;
|
||||
void clearComponentCache() override;
|
||||
|
||||
private:
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QQmlContext>
|
||||
@ -33,7 +32,7 @@ public:
|
||||
public slots:
|
||||
void setVisible(bool show) override;
|
||||
void destroyThis() override;
|
||||
void terminate();
|
||||
void terminate() override;
|
||||
void clearComponentCache() override;
|
||||
|
||||
void setWindowsDesktopProperties(WindowsDesktopProperties* windowsDesktopProperties)
|
||||
|
@ -1,9 +1,9 @@
|
||||
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QStringList>
|
||||
#include <QtWebEngineQuick>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include "src/widgetwindow.h"
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileSystemWatcher>
|
||||
|
Loading…
Reference in New Issue
Block a user