Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in explorer background context menu logic #8977

Merged
18 commits merged into from
Feb 1, 2021
Merged
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/cascadia/ShellExtension/OpenTerminalHere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,16 @@ std::wstring OpenTerminalHere::_GetPathFromExplorer() const
return path;
}

auto shell = create_instance<IShellWindows>(CLSID_ShellWindows);
com_ptr<IShellWindows> shell;
try
{
shell = create_instance<IShellWindows>(CLSID_ShellWindows, CLSCTX_ALL);
}
catch (...)
{
//look like try_create_intance is not available no more
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
}
zadjii-msft marked this conversation as resolved.
Show resolved Hide resolved

if (shell == nullptr)
{
return path;
Expand All @@ -285,6 +294,7 @@ std::wstring OpenTerminalHere::_GetPathFromExplorer() const
com_ptr<IWebBrowserApp> tmp;
if (FAILED(disp->QueryInterface(tmp.put())))
{
disp = nullptr; // get rid of DEBUG non-nullptr warning
continue;
}

Expand All @@ -293,8 +303,11 @@ std::wstring OpenTerminalHere::_GetPathFromExplorer() const
if (hwnd == tmpHWND)
{
browser = tmp;
disp = nullptr; // get rid of DEBUG non-nullptr warning
break; //found
}

disp = nullptr; // get rid of DEBUG non-nullptr warning
}

if (browser != nullptr)
Expand Down