Giter Site home page Giter Site logo

[Bug]: Putting RoutedViewHost inside a TabControl on Avalonia causes an app crash after navigating the second time about reactiveui HOT 7 CLOSED

kyurkchyan avatar kyurkchyan commented on April 27, 2024
[Bug]: Putting RoutedViewHost inside a TabControl on Avalonia causes an app crash after navigating the second time

from reactiveui.

Comments (7)

kyurkchyan avatar kyurkchyan commented on April 27, 2024

We've resolved this issue by copying the RoutedViewHost source code and adding the following inside the WhenActivated block

this.WhenActivated(disposables =>
            {
                ....

                Disposable.Create(() =>
                          {
                              Content = null;
                          })
                          .DisposeWith(disposables);
            });

This resolves the root cause of the issue. The problem is that once the view is reactivated, the same content is recreated through view location. However, that view is already attached to the parent. This means whenever the routed view host deactivates, we also need to clear its content. Otherwise, we are risking double-attaching the same view and causing this exception.

from reactiveui.

glennawatson avatar glennawatson commented on April 27, 2024

Probably worth raising this up with the Avalonia team. See if you can get the fix in.

from reactiveui.

kyurkchyan avatar kyurkchyan commented on April 27, 2024

@glennawatson you are actually right. I've extended the sample I've attached to this bug report. And instead of using RoutedViewHost when using bare TransitioningContentControl through assigning the Content property the same issue occurs. I will raise this Avalonia.

from reactiveui.

kyurkchyan avatar kyurkchyan commented on April 27, 2024

Closing this issue for the time being, for 2 reasons

  1. There's a workaround
  2. Most probably this should be fixed inside the TransitioningContentControl and not the RoutedViewHost. For that, an issue is opened inside the Avalonia repo

from reactiveui.

glennawatson avatar glennawatson commented on April 27, 2024

Worth noting that AvaloniaUI own both the RoutedViewHost and the TransitioningContentControl

https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.ReactiveUI/RoutedViewHost.cs

So bugs with that system aren't necessarily related directly with ReactiveUI.

from reactiveui.

kyurkchyan avatar kyurkchyan commented on April 27, 2024

@glennawatson thanks for the info, I actually didn't realize that. And the good news is the issue is already fixed in the latest CI beta release.

from reactiveui.

github-actions avatar github-actions commented on April 27, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from reactiveui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.