Show MessageBox on Stream Fail

This commit is contained in:
Florian Märkl 2019-08-18 12:42:46 +02:00
commit 44e9142886
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
3 changed files with 25 additions and 20 deletions

View file

@ -161,7 +161,6 @@ int RunMain(QApplication &app, Settings *settings)
int RunStream(QApplication &app, const StreamSessionConnectInfo &connect_info)
{
StreamWindow window(connect_info);
window.show();
app.setQuitOnLastWindowClosed(true);
return app.exec();
}

View file

@ -225,15 +225,7 @@ void MainWindow::ServerItemWidgetTriggered()
QString host = server->GetHostAddr();
StreamSessionConnectInfo info(settings, host, server->registered_host.GetRPRegistKey(), server->registered_host.GetRPKey());
try
{
auto stream_window = new StreamWindow(info);
stream_window->show();
}
catch(const ChiakiException &e)
{
QMessageBox::critical(this, tr("Stream failed"), e.what());
}
new StreamWindow(info);
}
else
{

View file

@ -25,18 +25,29 @@
StreamWindow::StreamWindow(const StreamSessionConnectInfo &connect_info, QWidget *parent)
: QMainWindow(parent)
{
session = new StreamSession(connect_info, this);
try
{
session = new StreamSession(connect_info, this);
connect(session, &StreamSession::SessionQuit, this, &StreamWindow::SessionQuit);
connect(session, &StreamSession::SessionQuit, this, &StreamWindow::SessionQuit);
av_widget = new AVOpenGLWidget(session->GetVideoDecoder(), this);
setCentralWidget(av_widget);
av_widget = new AVOpenGLWidget(session->GetVideoDecoder(), this);
setCentralWidget(av_widget);
grabKeyboard();
grabKeyboard();
session->Start();
session->Start();
resize(connect_info.video_profile.width, connect_info.video_profile.height);
resize(connect_info.video_profile.width, connect_info.video_profile.height);
show();
}
catch(const Exception &e)
{
session = nullptr;
av_widget = nullptr;
QMessageBox::critical(this, tr("Stream failed"), tr("Failed to initialize Stream Session: %1").arg(e.what()));
close();
}
}
StreamWindow::~StreamWindow()
@ -47,17 +58,20 @@ StreamWindow::~StreamWindow()
void StreamWindow::keyPressEvent(QKeyEvent *event)
{
session->HandleKeyboardEvent(event);
if(session)
session->HandleKeyboardEvent(event);
}
void StreamWindow::keyReleaseEvent(QKeyEvent *event)
{
session->HandleKeyboardEvent(event);
if(session)
session->HandleKeyboardEvent(event);
}
void StreamWindow::closeEvent(QCloseEvent *)
{
session->Stop();
if(session)
session->Stop();
}
void StreamWindow::SessionQuit(ChiakiQuitReason reason, const QString &reason_str)