Skip to content
Permalink
Browse files

D3D11 init: Release pFactory at the appropriate place.

  • Loading branch information...
hrydgard committed May 15, 2019
1 parent a5bbc9f commit 33c53eebe9012840db9abfd28ba2828dc1d591d0
Showing with 3 additions and 5 deletions.
  1. +3 −5 Windows/GPU/D3D11Context.cpp
@@ -103,14 +103,13 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
HRESULT hr = E_FAIL;
std::vector<std::string> adapterNames;
std::string chosenAdapterName;
IDXGIFactory* pFactory = nullptr;
if (result == LoadD3D11Error::SUCCESS) {
std::vector<IDXGIAdapter *> adapters;
int chosenAdapter = 0;
IDXGIFactory* pFactory = nullptr;

hr = ptr_CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&pFactory);
if (SUCCEEDED(hr)) {

IDXGIAdapter* pAdapter;
for (UINT i = 0; pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND; i++) {
adapters.push_back(pAdapter);
@@ -122,7 +121,6 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
chosenAdapter = i;
}
}

if (!adapters.empty()) {
chosenAdapterName = adapterNames[chosenAdapter];
hr = CreateTheDevice(adapters[chosenAdapter]);
@@ -133,12 +131,12 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
// No adapters found. Trip the error path below.
hr = E_FAIL;
}
pFactory->Release();
}
}

if (FAILED(hr)) {
if (pFactory)
pFactory->Release();

const char *defaultError = "Your GPU does not appear to support Direct3D 11.\n\nWould you like to try again using Direct3D 9 instead?";
I18NCategory *err = GetI18NCategory("Error");

0 comments on commit 33c53ee

Please sign in to comment.
You can’t perform that action at this time.