Bug? child panel still initialized after nav control page removed

Discussion in 'iOS Bugs & Wishlist' started by Jack Cole, Jun 23, 2019.

  1. Jack Cole

    Jack Cole Active Member Licensed User

    I have an app in which I check to see if a panel is initialized in the page_resize event. If it is, then I resize this child panel of the page's root panel. This is used to determine if the layout should be loaded or if the content just needs to be resized.

    When I remove a page from the navcontrol, the child panel still shows as being initialized. Is this a bug?

    I have attached an example app.

    To reproduce the problem:
    1) click Open Page.
    2) click Back
    3) click Open Page again. Notice that nothing loads because the resize event is seeing the panel as still being initialized.

    Here is the code where the problem happens.
    Code:
    Private Sub Page2_Resize(Width As Int, Height As Int)
        
    If ChildPanel.IsInitialized Then
            
    Log("Child is initialized")
            ChildPanel.Width=Width
            ChildPanel.Height=Height
        
    Else
            
    Log("Child is not initialized")
            ChildPanel.Initialize(
    "")
            Page2.RootPanel.AddView(ChildPanel,
    0,0,Width,Height)
            ChildPanel.LoadLayout(
    "newpage")
        
    End If
    End Sub
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    No. There is no relation between a view being initialized and its parent state.
    You can call Page.RootPanel.RemoveAllViews and then check whether the view's parent is initialized (assuming that the relevant view was added to the RootPanel and not to a child panel).
     
    Jack Cole likes this.
  3. Jack Cole

    Jack Cole Active Member Licensed User

    Ok, I understand that generally. I was thinking that removing the page from the nav control was the same as destroying the view.
     
  4. Jack Cole

    Jack Cole Active Member Licensed User

    I have the same problem even when using Page.RootPanel.RemoveAllViews. It even shows the panel as still being initialized when I remove it from the parent using ChildPanel.RemoveViewFromParent.
     
  5. LucaMs

    LucaMs Expert Licensed User

    Given that what I'm about to write is not about B4i and that I don't have B4i...

    This usually happens also with B4A Panels; you can remove a View from a Panel (or from an Activity) and assign it to another Panel. The view remains initialized and with all its properties set.

    This is a convenience rather than a bug; certainly we should know how to remove them permanently, so as not to waste memory.
     
    Jack Cole likes this.
  6. Jack Cole

    Jack Cole Active Member Licensed User

    I guess maybe you mean I'd have to check the following:

    ChildPanel.Parent.IsInitialized

    When I check that, it comes back as false. I can work with that.
     
    LucaMs likes this.
  7. LucaMs

    LucaMs Expert Licensed User

    After writing my previous post (almost certainly out of place), I realized that this can be a problem (again a memory problem "only") in CustomListViews.

    But the problem will be solved by Erel, as I think these my two posts will be removed :) (perhaps rightly)
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    True.

    That's expected. As I wrote, there is no relation between a view being initialized and its parent state.
     
    Jack Cole likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice