Skip to content

Commit

Permalink
NFDFileBrowser: ensure window handle is set to null if we don't have …
Browse files Browse the repository at this point in the history
…a valid handle
  • Loading branch information
azonenberg committed Oct 19, 2024
1 parent 5f9ee88 commit a9c8bc1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/ngscopeclient/NFDFileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ NFDFileBrowser::NFDFileBrowser(
, m_saveDialog(saveDialog)
, m_cachedResultValid(false)
{
LogDebug("initialPath = %s\n", initialPath.c_str());

//Trim off filter name
size_t iparen = m_filterName.find('(');
if(iparen != string::npos)
Expand Down Expand Up @@ -126,28 +128,34 @@ optional<string> NFDFileBrowser::ThreadProc()
return {};
}

nfdchar_t* outPath;
nfdchar_t* outPath = nullptr;
nfdu8filteritem_t filterItem = { m_filterName.c_str(), m_filterMask.c_str() };
nfdresult_t result;
if(m_saveDialog)
{
//Fill out arguments
nfdsavedialogu8args_t args;
memset(&args, 0, sizeof(args));

args.filterList = &filterItem;
args.filterCount = 1;
args.defaultPath = nullptr;
NFD_GetNativeWindowFromGLFWWindow(m_parent->GetWindow(), &args.parentWindow);
if(!NFD_GetNativeWindowFromGLFWWindow(m_parent->GetWindow(), &args.parentWindow))
LogError("failed to get window handle\n");

result = NFD_SaveDialogU8_With(&outPath, &args);
}
else
{
//Fill out arguments
nfdopendialogu8args_t args;
memset(&args, 0, sizeof(args));

args.filterList = &filterItem;
args.filterCount = 1;
args.defaultPath = nullptr;
NFD_GetNativeWindowFromGLFWWindow(m_parent->GetWindow(), &args.parentWindow);
if(!NFD_GetNativeWindowFromGLFWWindow(m_parent->GetWindow(), &args.parentWindow))
LogError("failed to get window handle\n");

//And run the dialog
result = NFD_OpenDialogU8_With(&outPath, &args);
Expand Down

0 comments on commit a9c8bc1

Please sign in to comment.