Don't crash if not enough memory to save a state. Very annoying.

Minor tweaks.
This commit is contained in:
Henrik Rydgård 2017-03-07 15:19:20 +01:00
parent 474db602ca
commit ed16096365
3 changed files with 12 additions and 5 deletions

View File

@ -576,6 +576,7 @@ public:
ERROR_NONE,
ERROR_BAD_FILE,
ERROR_BROKEN_STATE,
ERROR_BAD_ALLOC,
};
// May fail badly if ptr doesn't point to valid data.
@ -642,7 +643,13 @@ public:
{
// Get data
size_t const sz = MeasurePtr(_class);
u8 *buffer = new u8[sz];
u8 *buffer = nullptr;
try {
buffer = new u8[sz];
}
catch (std::bad_alloc e) {
return ERROR_BAD_ALLOC;
}
Error error = SavePtr(buffer, _class);
// SaveFile takes ownership of buffer

View File

@ -899,7 +899,7 @@ void ArmJit::CompNEON_Vmscl(MIPSOpcode op) {
MatrixSize msz = GetMtxSize(op);
bool overlap = GetMatrixOverlap(_VD, _VS, msz);
bool overlap = GetMatrixOverlap(_VD, _VS, msz) != OVERLAP_NONE;
if (overlap) {
DISABLE;
}

View File

@ -95,9 +95,9 @@ ShaderManagerD3D11::ShaderManagerD3D11(ID3D11Device *device, ID3D11DeviceContext
memset(&ub_lights, 0, sizeof(ub_lights));
memset(&ub_bones, 0, sizeof(ub_bones));
ILOG("sizeof(ub_base): %d", (int)sizeof(ub_base));
ILOG("sizeof(ub_lights): %d", (int)sizeof(ub_lights));
ILOG("sizeof(ub_bones): %d", (int)sizeof(ub_bones));
INFO_LOG(G3D, "sizeof(ub_base): %d", (int)sizeof(ub_base));
INFO_LOG(G3D, "sizeof(ub_lights): %d", (int)sizeof(ub_lights));
INFO_LOG(G3D, "sizeof(ub_bones): %d", (int)sizeof(ub_bones));
D3D11_BUFFER_DESC desc{sizeof(ub_base), D3D11_USAGE_DYNAMIC, D3D11_BIND_CONSTANT_BUFFER, D3D11_CPU_ACCESS_WRITE };
ASSERT_SUCCESS(device_->CreateBuffer(&desc, nullptr, &push_base));