Skip to content

Commit

Permalink
win32: explicitly decref dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlabbe committed Dec 31, 2018
1 parent 31fb845 commit 23c1450
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ release | what's new | date
1.1.2 | test_pickfolder() added | aug 2016
1.1.3 | zenity linux backend added | nov 2017
1.1.3 | fix char type in decls | nov 2017
1.1.4 | fix win32 memleaks | dec 2018
## Building ##
Expand Down
19 changes: 16 additions & 3 deletions src/nfd_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
http://www.frogtoss.com/labs
*/

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

/* only locally define UNICODE in this compilation unit */
#ifndef UNICODE
#define UNICODE
Expand Down Expand Up @@ -371,6 +375,7 @@ nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList,

if ( !SUCCEEDED(result))
{
fileOpenDialog = NULL;
NFDi_SetError("Could not initialize COM.");
goto end;
}
Expand Down Expand Up @@ -441,7 +446,8 @@ nfdresult_t NFD_OpenDialog( const nfdchar_t *filterList,
nfdResult = NFD_ERROR;
}

end:
end:
fileOpenDialog->Release();
::CoUninitialize();

return nfdResult;
Expand Down Expand Up @@ -472,6 +478,7 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,

if ( !SUCCEEDED(result) )
{
fileOpenDialog = NULL;
NFDi_SetError("Could not create dialog.");
goto end;
}
Expand Down Expand Up @@ -534,7 +541,10 @@ nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,
nfdResult = NFD_ERROR;
}

end:
end:
if ( fileOpenDialog )
fileOpenDialog->Release();

::CoUninitialize();

return nfdResult;
Expand Down Expand Up @@ -565,6 +575,7 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList,

if ( !SUCCEEDED(result) )
{
fileSaveDialog = NULL;
NFDi_SetError("Could not create dialog.");
goto end;
}
Expand Down Expand Up @@ -624,7 +635,9 @@ nfdresult_t NFD_SaveDialog( const nfdchar_t *filterList,
nfdResult = NFD_ERROR;
}

end:
end:
if ( fileSaveDialog )
fileSaveDialog->Release();
::CoUninitialize();

return nfdResult;
Expand Down

0 comments on commit 23c1450

Please sign in to comment.