mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
GUI: Fixed some GUI related start/stop crashes
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4223 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -17,9 +17,11 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include "MemoryUtil.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
#elif __GNUC__
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
@ -132,3 +134,28 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute)
|
||||
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
std::string MemUsage()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD processID = GetCurrentProcessId();
|
||||
HANDLE hProcess;
|
||||
PROCESS_MEMORY_COUNTERS pmc;
|
||||
std::string Ret;
|
||||
|
||||
// Print information about the memory usage of the process.
|
||||
|
||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
|
||||
if (NULL == hProcess) return "MemUsage Error";
|
||||
|
||||
if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))
|
||||
Ret = StringFromFormat("%s K", ThS(pmc.WorkingSetSize / 1024, true, 7).c_str());
|
||||
|
||||
CloseHandle(hProcess);
|
||||
return Ret;
|
||||
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
@ -18,11 +18,14 @@
|
||||
#ifndef _MEMORYUTIL_H
|
||||
#define _MEMORYUTIL_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
void* AllocateExecutableMemory(size_t size, bool low = true);
|
||||
void* AllocateMemoryPages(size_t size);
|
||||
void FreeMemoryPages(void* ptr, size_t size);
|
||||
void WriteProtectMemory(void* ptr, size_t size, bool executable = false);
|
||||
void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute = false);
|
||||
std::string MemUsage();
|
||||
|
||||
inline int GetPageSize() { return 4096; }
|
||||
|
||||
|
@ -452,7 +452,7 @@ std::string ThS(int Integer, bool Unsigned, int Spaces)
|
||||
|
||||
// Spaces
|
||||
std::string Spc = "";
|
||||
for (int i = 0; i < (Spaces - Sbuf.length()); i++) Spc += " ";
|
||||
for (int i = 0; i < (int)(Spaces - Sbuf.length()); i++) Spc += " ";
|
||||
return Spc + Sbuf;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,15 @@
|
||||
namespace Common
|
||||
{
|
||||
|
||||
int Thread::CurrentId()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return GetCurrentThreadId();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
void InitThreading()
|
||||
@ -81,14 +90,16 @@ Thread::~Thread()
|
||||
WaitForDeath();
|
||||
}
|
||||
|
||||
void Thread::WaitForDeath(const int _Wait)
|
||||
DWORD Thread::WaitForDeath(const int iWait)
|
||||
{
|
||||
if (m_hThread)
|
||||
{
|
||||
WaitForSingleObject(m_hThread, _Wait);
|
||||
DWORD Wait = WaitForSingleObject(m_hThread, iWait);
|
||||
CloseHandle(m_hThread);
|
||||
m_hThread = NULL;
|
||||
return Wait;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Thread::SetAffinity(int mask)
|
||||
|
@ -105,9 +105,10 @@ public:
|
||||
|
||||
void SetAffinity(int mask);
|
||||
static void SetCurrentThreadAffinity(int mask);
|
||||
#ifdef _WIN32
|
||||
static int CurrentId();
|
||||
#ifdef _WIN32
|
||||
void SetPriority(int priority);
|
||||
void WaitForDeath(const int _Wait = INFINITE);
|
||||
DWORD WaitForDeath(const int iWait = INFINITE);
|
||||
#else
|
||||
void WaitForDeath();
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user