Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #522 from lioncash/fix-dragdrop-crash
Fix crashes when dragging and dropping files outside of the gamelist
  • Loading branch information
lioncash committed Jun 28, 2014
2 parents aae1630 + 10dc1ef commit 91da031
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 40 deletions.
30 changes: 28 additions & 2 deletions Source/Core/DolphinWX/Frame.cpp
Expand Up @@ -21,6 +21,7 @@
#include <wx/chartype.h>
#include <wx/defs.h>
#include <wx/event.h>
#include <wx/filename.h>
#include <wx/frame.h>
#include <wx/gdicmn.h>
#include <wx/icon.h>
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
37 changes: 0 additions & 37 deletions Source/Core/DolphinWX/GameListCtrl.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()));
}
}
1 change: 0 additions & 1 deletion Source/Core/DolphinWX/GameListCtrl.h
Expand Up @@ -104,7 +104,6 @@ class CGameListCtrl : public wxListCtrl
void OnMultiCompressGCM(wxCommandEvent& event);
void OnMultiDecompressGCM(wxCommandEvent& event);
void OnInstallWAD(wxCommandEvent& event);
void OnDropFiles(wxDropFilesEvent& event);

void CompressSelection(bool _compress);
void AutomaticColumnWidth();
Expand Down

0 comments on commit 91da031

Please sign in to comment.