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

error C3861: 'weak_from_this': identifier not found in file xxx.xaml.g.hpp #4643

Closed
shelllet opened this issue Aug 14, 2024 · 1 comment
Closed
Labels
bug Something isn't working fix-released The fix has been in a release (experimental, preview, stable, or servicing). has-workaround Indicates whether the bug has a workaround Status: Fixed
Milestone

Comments

@shelllet
Copy link

Describe the bug

Compare the following two code snippets:

1

template <typename D, typename ... I>
 void MainWindowT<D, I...>::Connect(int32_t connectionId, IInspectable const& target)
 {
     switch (connectionId)
     {
     case 2:
         {
             auto targetElement = target.as<::winrt::Microsoft::UI::Xaml::Controls::Button>();
             this->myButton(targetElement);
             auto weakThis = ::winrt::make_weak<class_type>(*this);
             targetElement.Click([weakThis](::winrt::Windows::Foundation::IInspectable const& p0, ::winrt::Microsoft::UI::Xaml::RoutedEventArgs const& p1){
                 if (auto t = weakThis.get())
                 {
                     ::winrt::get_self<D>(t)->myButton_Click(p0, p1);
                 }
             });
         }
         break;
     }
     _contentLoaded = true;
 }

2

 obj4.RegisterPropertyChangedCallback(...,
     [weakThis{ weak_from_this() }, this] (DependencyObject const& sender, DependencyProperty const& prop)
     {
         if (auto strongThis{ weakThis.lock() })
         {
             if (IsInitialized())
             {
                 // Update Two Way binding
                 if (GetDataRoot() != nullptr)
                 {
                     if (GetDataRoot().Point() != nullptr)
                     {
                         GetDataRoot().Point().Y(obj4.Value());
                     }
                 }
             }
         }
     });

Steps to reproduce the bug

  1. upgrade to 1.6 preview1
  2. create winui project.
  3. add property
  4. compile code.

Expected behavior

No response

Screenshots

image

NuGet package version

Windows App SDK 1.6 Preview 1: 1.6.240807006-preview1

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

@codendone
Copy link
Contributor

If you're using /permissive- compiler flag, switching to /permissive should unblock you. We'll get this fixed for the next 1.6 build. (internal tracking bug)

@bpulliam bpulliam added has-workaround Indicates whether the bug has a workaround bug Something isn't working and removed needs-triage labels Aug 15, 2024
@bpulliam bpulliam added this to the 1.6 milestone Aug 15, 2024
@codendone codendone added the Status: Fixed internally The issue has been fixed but has not yet shipped in a release. label Aug 22, 2024
@codendone codendone added Status: Fixed fix-released The fix has been in a release (experimental, preview, stable, or servicing). and removed Status: Fixed internally The issue has been fixed but has not yet shipped in a release. labels Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix-released The fix has been in a release (experimental, preview, stable, or servicing). has-workaround Indicates whether the bug has a workaround Status: Fixed
Projects
None yet
Development

No branches or pull requests

3 participants