Skip to content

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

Closed
@ajtruckle

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

bugSomething isn't workingtrackedWe are tracking this work internally.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions