Skip to content

Commit

Permalink
handle loading errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rectalogic committed Apr 17, 2024
1 parent b294ad6 commit efd246b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/MediaFX/encoder.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ RenderWindow {
}

Loader {
id: loader
source: RenderSession.sourceUrl
anchors.fill: parent
Component.onCompleted: {
if (loader.status == Loader.Error)
RenderSession.fatalError();
}
}

Encoder {
Expand Down
5 changes: 3 additions & 2 deletions src/MediaFX/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ int encoder(QGuiApplication& app, QCommandLineParser& parser)
if (output == u"-"_s)
output = u"pipe:"_s;

// XXX connect to engine warnings and exit if parser.isSet(u"exitOnWarning"_s) flag set
QQmlApplicationEngine engine;
MediaContext mediaContext(url, output, frameSize, frameRate, sampleRate);
RenderSession* renderSession = engine.singletonInstance<RenderSession*>("MediaFX", "RenderSession");
Q_ASSERT(renderSession);
renderSession->initialize(mediaContext);

// XXX If an error occurs, the objectCreated signal is emitted with a null pointer as parameter and error messages are printed with qWarning.
if (parser.isSet(u"exitOnWarning"_s)) {
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, renderSession, &RenderSession::fatalError, Qt::QueuedConnection);
}
engine.load(QUrl(u"qrc:/qt/qml/MediaFX/encoder.qml"_s));

return app.exec();
Expand Down

0 comments on commit efd246b

Please sign in to comment.