From 10dc1ef135f28b87f759533f94ac52756ed437e0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 20 Jun 2014 20:59:07 -0400 Subject: [PATCH] Fix crashes when dragging and dropping files outside of the gamelist --- Source/Core/DolphinWX/Frame.cpp | 30 +++++++++++++++++++-- Source/Core/DolphinWX/GameListCtrl.cpp | 37 -------------------------- Source/Core/DolphinWX/GameListCtrl.h | 1 - 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 442ab2064f..73cf99a3c9 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ #include "Core/CoreParameter.h" #include "Core/Movie.h" #include "Core/State.h" +#include "Core/HW/DVDInterface.h" #include "DolphinWX/Frame.h" #include "DolphinWX/GameListCtrl.h" @@ -146,10 +148,34 @@ void CRenderFrame::OnDropFiles(wxDropFilesEvent& event) { if (event.GetNumberOfFiles() != 1) return; - if (File::IsDirectory(event.GetFiles()[0].ToStdString())) + if (File::IsDirectory(WxStrToStr(event.GetFiles()[0]))) return; - State::LoadAs(event.GetFiles()[0].ToStdString()); + wxFileName file = event.GetFiles()[0]; + + if (file.GetExt() == "dtm") + { + if (Core::IsRunning()) + return; + + if (!Movie::IsReadOnly()) + { + // let's make the read-only flag consistent at the start of a movie. + Movie::SetReadOnly(true); + main_frame->GetMenuBar()->FindItem(IDM_RECORDREADONLY)->Check(true); + } + + if (Movie::PlayInput(WxStrToStr(file.GetFullPath()))) + main_frame->BootGame(""); + } + else if (!Core::IsRunning()) + { + main_frame->BootGame(WxStrToStr(file.GetFullPath())); + } + else + { + DVDInterface::ChangeDisc(WxStrToStr(file.GetFullPath())); + } } #ifdef _WIN32 diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp index aaf43639de..31b8dcdfc6 100644 --- a/Source/Core/DolphinWX/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/GameListCtrl.cpp @@ -52,7 +52,6 @@ #include "Core/CoreParameter.h" #include "Core/Movie.h" #include "Core/Boot/Boot.h" -#include "Core/HW/DVDInterface.h" #include "DiscIO/Blob.h" #include "DiscIO/Volume.h" #include "DiscIO/VolumeCreator.h" @@ -216,8 +215,6 @@ CGameListCtrl::CGameListCtrl(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxListCtrl(parent, id, pos, size, style), toolTip(nullptr) { - DragAcceptFiles(true); - Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(CGameListCtrl::OnDropFiles), nullptr, this); } CGameListCtrl::~CGameListCtrl() @@ -1324,37 +1321,3 @@ void CGameListCtrl::UnselectAll() SetItemState(i, 0, wxLIST_STATE_SELECTED); } } - -void CGameListCtrl::OnDropFiles(wxDropFilesEvent& event) -{ - if (event.GetNumberOfFiles() != 1) - return; - if (File::IsDirectory(WxStrToStr(event.GetFiles()[0]))) - return; - - wxFileName file = event.GetFiles()[0]; - - if (file.GetExt() == "dtm") - { - if (Core::IsRunning()) - return; - - if (!Movie::IsReadOnly()) - { - // let's make the read-only flag consistent at the start of a movie. - Movie::SetReadOnly(true); - main_frame->GetMenuBar()->FindItem(IDM_RECORDREADONLY)->Check(true); - } - - if (Movie::PlayInput(WxStrToStr(file.GetFullPath()))) - main_frame->BootGame(""); - } - else if (!Core::IsRunning()) - { - main_frame->BootGame(WxStrToStr(file.GetFullPath())); - } - else - { - DVDInterface::ChangeDisc(WxStrToStr(file.GetFullPath())); - } -} diff --git a/Source/Core/DolphinWX/GameListCtrl.h b/Source/Core/DolphinWX/GameListCtrl.h index b21c4e2259..0b71003a08 100644 --- a/Source/Core/DolphinWX/GameListCtrl.h +++ b/Source/Core/DolphinWX/GameListCtrl.h @@ -104,7 +104,6 @@ private: void OnMultiCompressGCM(wxCommandEvent& event); void OnMultiDecompressGCM(wxCommandEvent& event); void OnInstallWAD(wxCommandEvent& event); - void OnDropFiles(wxDropFilesEvent& event); void CompressSelection(bool _compress); void AutomaticColumnWidth();