Skip to content
New issue

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

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

Already on GitHub? # to your account

[Problem/Bug]: Inappropriate use of CHECK_FEATURE_RETURN in InitializeFindOptions sample code #5064

Open
ajtruckle opened this issue Jan 28, 2025 · 0 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@ajtruckle
Copy link

ajtruckle commented Jan 28, 2025

What happened?

The CHECK_FEATURE_RETURN macro can't be used in the proposed InitializeFindOptions method:

wil::com_ptr<ICoreWebView2FindOptions> AppWindow::InitializeFindOptions(const std::wstring& findTerm)
{
    // Query for the ICoreWebView2Environment5 interface.
    auto webView2Environment5 = m_webViewEnvironment.try_query<ICoreWebView2Environment5>();
    CHECK_FEATURE_RETURN(webView2Environment5);

    // Initialize Find options
    wil::com_ptr<ICoreWebView2FindOptions> find_options;
    CHECK_FAILURE(webView2Environment5->CreateFindOptions(&find_options));
    CHECK_FAILURE(find_options->put_FindTerm(findTerm.c_str()));

    return find_options;
}

This is because it returns true upon success. So I adapted by adding a new macro:

#define CHECK_FEATURE_RETURN_NULL(feature) { if (!feature) { FeatureNotAvailable(); return nullptr; } }

The sample code should be revised.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Prerelease (Edge Canary/Dev/Beta)

Runtime Version

134.0.3101.0 canary

SDK Version

1.0.3079 prerelease

Framework

Win32

Operating System

Windows 11

OS Version

10.0.26100 24H2

Repro steps

Try to use the sample in the Find documentation for Win32.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@ajtruckle ajtruckle added the bug Something isn't working label Jan 28, 2025
@prija-microsoft prija-microsoft added the tracked We are tracking this work internally. label Jan 29, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

3 participants