Making shutdown clean.

This commit is contained in:
Ben Vanik 2015-07-25 12:56:37 -07:00
parent 89adaf8e85
commit abf50b477e
4 changed files with 12 additions and 12 deletions

View File

@ -32,7 +32,9 @@ EmulatorWindow::EmulatorWindow(Emulator* emulator)
loop_(ui::Loop::Create()), loop_(ui::Loop::Create()),
window_(ui::Window::Create(loop_.get(), kBaseTitle)) {} window_(ui::Window::Create(loop_.get(), kBaseTitle)) {}
EmulatorWindow::~EmulatorWindow() = default; EmulatorWindow::~EmulatorWindow() {
loop_->PostSynchronous([this]() { window_.reset(); });
}
std::unique_ptr<EmulatorWindow> EmulatorWindow::Create(Emulator* emulator) { std::unique_ptr<EmulatorWindow> EmulatorWindow::Create(Emulator* emulator) {
std::unique_ptr<EmulatorWindow> emulator_window(new EmulatorWindow(emulator)); std::unique_ptr<EmulatorWindow> emulator_window(new EmulatorWindow(emulator));

View File

@ -83,6 +83,8 @@ int xenia_main(std::vector<std::wstring>& args) {
result = emulator->LaunchPath(abs_path); result = emulator->LaunchPath(abs_path);
if (XFAILED(result)) { if (XFAILED(result)) {
XELOGE("Failed to launch target: %.8X", result); XELOGE("Failed to launch target: %.8X", result);
emulator.reset();
emulator_window.reset();
return 1; return 1;
} }

View File

@ -104,12 +104,6 @@ void CommandProcessor::Shutdown() {
write_ptr_index_event_->Set(); write_ptr_index_event_->Set();
worker_thread_->Wait(0, 0, 0, nullptr); worker_thread_->Wait(0, 0, 0, nullptr);
worker_thread_.reset(); worker_thread_.reset();
all_pipelines_.clear();
all_shaders_.clear();
shader_cache_.clear();
context_.reset();
} }
void CommandProcessor::RequestFrameTrace(const std::wstring& root_path) { void CommandProcessor::RequestFrameTrace(const std::wstring& root_path) {
@ -227,7 +221,6 @@ void CommandProcessor::WorkerThreadMain() {
} }
ShutdownGL(); ShutdownGL();
context_->ClearCurrent();
} }
bool CommandProcessor::SetupGL() { bool CommandProcessor::SetupGL() {
@ -466,6 +459,12 @@ void CommandProcessor::ShutdownGL() {
texture_cache_.Shutdown(); texture_cache_.Shutdown();
draw_batcher_.Shutdown(); draw_batcher_.Shutdown();
scratch_buffer_.Shutdown(); scratch_buffer_.Shutdown();
all_pipelines_.clear();
all_shaders_.clear();
shader_cache_.clear();
context_.reset();
} }
void CommandProcessor::InitializeRingBuffer(uint32_t ptr, uint32_t page_count) { void CommandProcessor::InitializeRingBuffer(uint32_t ptr, uint32_t page_count) {

View File

@ -137,10 +137,7 @@ void Win32Window::EnableMMCSS() {
FreeLibrary(hLibrary); FreeLibrary(hLibrary);
} }
void Win32Window::OnDestroy() { void Win32Window::OnDestroy() { super::OnDestroy(); }
super::OnDestroy();
hwnd_ = nullptr;
}
void Win32Window::OnClose() { void Win32Window::OnClose() {
if (!closing_ && hwnd_) { if (!closing_ && hwnd_) {