gs_frame: fix the mysterious "second boot crash"

This commit is contained in:
Megamouse 2017-07-20 16:10:20 +02:00 committed by Ivan
parent f69e252c7a
commit f8c2e198c5

View file

@ -15,6 +15,16 @@ gs_frame::gs_frame(const QString& title, int w, int h, QIcon appIcon)
{ {
m_windowTitle = title; m_windowTitle = title;
if (!Emu.GetTitle().empty())
{
m_windowTitle += qstr(" | " + Emu.GetTitle());
}
if (!Emu.GetTitleID().empty())
{
m_windowTitle += qstr(" | [" + Emu.GetTitleID() + ']');
}
if (!appIcon.isNull()) if (!appIcon.isNull())
{ {
setIcon(appIcon); setIcon(appIcon);
@ -24,6 +34,8 @@ gs_frame::gs_frame(const QString& title, int w, int h, QIcon appIcon)
resize(w, h); resize(w, h);
setVisibility(QWindow::Visibility::AutomaticVisibility);
// Change cursor when in fullscreen. // Change cursor when in fullscreen.
connect(this, &QWindow::visibilityChanged, this, &gs_frame::HandleCursor); connect(this, &QWindow::visibilityChanged, this, &gs_frame::HandleCursor);
} }
@ -85,7 +97,7 @@ void gs_frame::OnFullScreen()
void gs_frame::close() void gs_frame::close()
{ {
Emu.Stop(); Emu.Stop();
Emu.CallAfter([=]() {QWindow::close(); }); Emu.CallAfter([=]() {QWindow::close(); deleteLater(); });
} }
bool gs_frame::shown() bool gs_frame::shown()
@ -153,23 +165,6 @@ int gs_frame::client_height()
void gs_frame::flip(draw_context_t, bool /*skip_frame*/) void gs_frame::flip(draw_context_t, bool /*skip_frame*/)
{ {
QString title;
if (!m_windowTitle.isEmpty())
{
title += m_windowTitle;
}
if (!Emu.GetTitle().empty())
{
title += qstr(" | " + Emu.GetTitle());
}
if (!Emu.GetTitleID().empty())
{
title += qstr(" | [" + Emu.GetTitleID() + ']');
}
if (m_show_fps) if (m_show_fps)
{ {
++m_frames; ++m_frames;
@ -180,9 +175,9 @@ void gs_frame::flip(draw_context_t, bool /*skip_frame*/)
{ {
QString fps_title = qstr(fmt::format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec())); QString fps_title = qstr(fmt::format("FPS: %.2f", (double)m_frames / fps_t.GetElapsedTimeInSec()));
if (!title.isEmpty()) if (!m_windowTitle.isEmpty())
{ {
fps_title += " | " + title; fps_title += " | " + m_windowTitle;
} }
Emu.CallAfter([this, title = std::move(fps_title)]() {setTitle(title); }); Emu.CallAfter([this, title = std::move(fps_title)]() {setTitle(title); });
@ -193,9 +188,9 @@ void gs_frame::flip(draw_context_t, bool /*skip_frame*/)
} }
else else
{ {
if (this->title() != title) if (this->title() != m_windowTitle)
{ {
Emu.CallAfter([this, title = std::move(title)]() {setTitle(title); }); Emu.CallAfter([this, title = std::move(m_windowTitle)]() {setTitle(m_windowTitle); });
} }
} }
} }