Skip to content

Commit

Permalink
Fix for a potential crash
Browse files Browse the repository at this point in the history
  • Loading branch information
SirMangler committed Mar 24, 2023
1 parent a1cf68c commit 7003c24
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
3 changes: 1 addition & 2 deletions Source/Core/DolphinUWP/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ struct App : implements<App, IFrameworkViewSource, IFrameworkView>
std::unique_ptr<BootParameters> boot =
BootParameters::GenerateFromFile(path, BootSessionData("", DeleteSavestateAfterBoot::No));

UICommon::InitControllers(wsi);

if (!BootManager::BootCore(std::move(boot), wsi))
{
fprintf(stderr, "Could not boot the specified file\n");
Expand Down Expand Up @@ -290,6 +288,7 @@ struct App : implements<App, IFrameworkViewSource, IFrameworkView>
UICommon::SetUserDirectory(UWP::GetUserLocation());
UICommon::CreateDirectories();
UICommon::Init();
UICommon::InitControllers({});

std::string gamePath = filePath.str();
if (!gamePath.empty() && gamePath != "")
Expand Down
4 changes: 0 additions & 4 deletions Source/Core/DolphinUWP/ImGuiFrontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,13 @@ ImGuiFrontend::ImGuiFrontend()
WindowSystemInfo prepared_wsi(wsi);
g_video_backend->PrepareWindow(prepared_wsi);


VideoBackendBase::PopulateBackendInfo();
if (!g_video_backend->Initialize(wsi))
{
PanicAlertFmt("Failed to initialize video backend!");
return;
}

g_controller_interface.Initialize({});

ImGui::GetIO().KeyMap[ImGuiKey_Backspace] = '\b';

PopulateControls();
Expand Down Expand Up @@ -485,7 +482,6 @@ FrontendResult ImGuiFrontend::RunMainLoop()
}

g_renderer->EndUIFrame();
g_controller_interface.Shutdown();

return selection;
}
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinUWP/ImGuiFrontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ImGuiFrontend
ImGuiFrontend();
FrontendResult RunUntilSelection();
Core::TitleDatabase m_title_database;
std::mutex m_frontend_mutex;

private:
void PopulateControls();
Expand Down
14 changes: 4 additions & 10 deletions Source/Core/DolphinUWP/ImGuiNetplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "UWPUtils.h"
#include "WinRTKeyboard.h"

#include "imgui.h"

#include <algorithm>
#include <cctype>

Expand All @@ -26,9 +28,8 @@
#include "UICommon/GameFile.h"
#include "UICommon/UICommon.h"

#include "imgui.h"
#include <VideoCommon/NetPlayChatUI.h>
#include <VideoCommon/OnScreenDisplay.h>
#include "VideoCommon/NetPlayChatUI.h"
#include "VideoCommon/OnScreenDisplay.h"

using winrt::Windows::UI::Core::CoreWindow;
using namespace winrt;
Expand Down Expand Up @@ -459,9 +460,6 @@ void ImGuiNetPlay::BootGame(const std::string& filename,
CoreApplication::MainView().Dispatcher().RunAsync(
winrt::Windows::UI::Core::CoreDispatcherPriority::Normal,
[filename, data = std::move(boot_session_data)] {
// Todo, proper synchronisation
Sleep(100); // avoid a race condition where we initialise before the frontend closes

CoreWindow window = CoreWindow::GetForCurrentThread();
void* abi = winrt::get_abi(window);

Expand Down Expand Up @@ -490,8 +488,6 @@ void ImGuiNetPlay::BootGame(const std::string& filename,
std::unique_ptr<BootParameters> boot =
BootParameters::GenerateFromFile(filename, std::move(*data));

UICommon::InitControllers(wsi);

if (!BootManager::BootCore(std::move(boot), wsi))
{
fprintf(stderr, "Could not boot the specified file\n");
Expand Down Expand Up @@ -626,8 +622,6 @@ void ImGuiNetPlay::OnTraversalStateChanged(TraversalClient::State state)

void ImGuiNetPlay::OnGameStartAborted()
{
g_netplay_client->StopGame();

if (Core::IsRunningAndStarted())
{
UWP::g_shutdown_requested.Set();
Expand Down

0 comments on commit 7003c24

Please sign in to comment.