haxeui / haxeui-core

The core library of the HaxeUI framework
http://haxeui.org
MIT License
340 stars 71 forks source link

ListViews don't work on latest version 1.2.3 #383

Closed Shallowmallow closed 2 years ago

Shallowmallow commented 3 years ago

When I try showing a listview, it freezes the app. Tested onlyy with hxwidgets for now.

Expected Behavior

The listBox should appear.

Current Behavior

It freezes.

Possible Solution

I have no idea.

Test app / minimal test case

var listBox =  new VBox();
        listBox.percentWidth   = 100;
        listBox.percentHeight = 70 ;
var xml = "<listview id='lv1' width='100%' selectedIndex='0'>
       <item-renderer layoutName='horizontal' width='100%'>
           <label id='value' width='100%' />
       </item-renderer>
       <data>
           <item value='item0' />
           <item value='item1' />
           <item value='item2' />
       </data>
   </listview>";
var listview:haxe.ui.containers.ListView = cast Toolkit.componentFromString(xml, "xml");
listBox.addComponent(listview);

Same for a code version of listview

      var ib = new Box();
        ib.percentWidth = 100;
        var lb = new Label();
        lb.id = "lala";
        lb.percentWidth = 100;
        var ir = new ItemRenderer();
        ir.percentWidth = 100;
        ib.addComponent( lb);
        ir.addComponent( ib );

        var lv1 = new ListView();
        lv1.width = 500;
        lv1.itemRenderer = ir;

        var data = new ArrayDataSource<DataInfo>();
        data.add( { value:"item1"} ); 
        data.add( { value:"item2"} );
        data.add( { value:"item3"} );

        lv1.dataSource = data;
        listBox.addComponent(lv1);

This one doesn't freeze but has a segmentation error.

Your Environment

(On 2.1.1, it worked not entirely ( couldn't remove the listview from some component for a reason) but stil it worked bascally )

ianharrigan commented 3 years ago

Hi sorry, been on holiday - ill check this out soon (just need to catch up on some other things)

Shallowmallow commented 2 years ago

Retested witth newer haxelib versions

Hereis the segmentationfaultwith gdb

#0  0x003a4600 in hx::widgets::Window_obj::get_size() ()
#1  0x0048386c in haxe::ui::backend::hxwidgets::size::WindowSize_obj::get_width() ()
#2  0x00532fe0 in haxe::ui::layouts::DelegateLayout_obj::calcAutoSize(Array<Dynamic>) ()
#3  0x0055e5cc in haxe::ui::core::Component_obj::validateComponentAutoSize() ()
#4  0x0056e3b0 in haxe::ui::core::Component_obj::validateComponentLayout() ()
#5  0x004c79a0 in haxe::ui::core::ComponentValidation_obj::validateComponentInternal(hx::Null<bool>) ()
#6  0x004253a4 in haxe::ui::containers::ScrollView_obj::validateComponentInternal(hx::Null<bool>) ()
#7  0x004c7c14 in haxe::ui::core::ComponentValidation_obj::validateComponent(hx::Null<bool>) ()
#8  0x00352f58 in haxe::ui::validation::ValidationManager_obj::process() ()
#9  0x003531f4 in haxe::ui::validation::__ValidationManager_objprocess(hx::Object*) ()
#10 0x005d26fc in hx::CMemberFunction0::__run() ()
#11 0x0051aaf4 in haxe::ui::backend::CallLaterImpl_obj::__construct(Dynamic) ()
#12 0x00439990 in haxe::ui::Toolkit_obj::callLater(Dynamic) ()
#13 0x00352cd0 in haxe::ui::validation::ValidationManager_obj::add(Dynamic) ()
#14 0x004c8600 in haxe::ui::core::ComponentValidation_obj::invalidateComponent(String, hx::Null<bool>) ()
#15 0x005a4318 in haxe::ui::backend::ComponentImpl_obj::createWindow(hx::ObjectPtr<hx::widgets::Object_obj>) ()
#16 0x005a5b4c in haxe::ui::backend::ComponentImpl_obj::handleReady() ()
#17 0x00565820 in haxe::ui::core::Component_obj::ready() ()
#18 0x0056760c in haxe::ui::core::Component_obj::addComponent(hx::ObjectPtr<haxe::ui::core::Component_obj>) ()
ianharrigan commented 2 years ago

Can you attach your / a test project?

EDIT: Actually, i see you have in the initial issue - is that still valid at reproducing it?

Shallowmallow commented 2 years ago

Here ! :)

Test.zip Click on the button in the middle of the screen.

ianharrigan commented 2 years ago

So just reading your code, isnt your listview line #187 always null?

listBox.addComponent(listview);

I never seen "listview" created anywhere.

ianharrigan commented 2 years ago

Also, with your original code snippet:

        var ib = new Box();
        ib.percentWidth = 100;
        var lb = new Label();
        lb.id = "lala";
        lb.percentWidth = 100;
        var ir = new ItemRenderer();
        ir.percentWidth = 100;
        ib.addComponent( lb);
        ir.addComponent( ib );

        var lv1 = new ListView();
        lv1.width = 500;
        lv1.itemRenderer = ir;

        var data = new ArrayDataSource<Dynamic>();
        data.add( { value:"item1"} ); 
        data.add( { value:"item2"} );
        data.add( { value:"item3"} );

        lv1.dataSource = data;
addComponent(lv1);

I get:

image

You are saying that crashes?

Shallowmallow commented 2 years ago

Oops I accidentally removed the line that creates the list view when doing the version to send to you .... But Yes, the second version also crashes for me. But maybe because I'm on raspberry or because I use 3.1.4 ? It reread my note, it seems that something between version 2.1.1 and 2.1.3 caused this, before it would show . ( but when I would try to remove it dynamically it would crash ) It seems that with the new haxelib when I put the list views in an external xml, it works. So I'll try doing this and modify it dynamically to see how it goes.

ianharrigan commented 2 years ago

Hmmm, weird... can you try latest git versions of everything? (haxeui-core, haxeui-hxwidgets, hxWidgets)... also, it might be useful to build wxWidgets from source (if you arent already - there are instructions on the hxWidgets readme).

Finally, if that still crashes, can you try to not use a custom itemrenderer, see if that works? (that might give me some more hints)

Shallowmallow commented 2 years ago

In fact everything works in the new version ! :) ( and in fact also in the latest haxelib version, I misadapted the program to the latest version, that's why it wasn't working) So thanks for everything. I'm closing the issue :)

Shallowmallow commented 2 years ago

Hmm, in fact, listviews don't work yeton hxwidgets.

If I simply add this component SentencesListView somewhereon the main view

@:xml(
    '
    <vbox>
        <listview id="listview" width="100%" height="100%" >
                <data>
                </data>
            </listview>
    </vbox>
    '
)*/
class SentencesListView extends VBox {

    public function new() {
        super();

    }

}

it freezes on hxWidgets , works on html5

The same if I do

class SentencesListView extends VBox {

   var listview:ListView = new ListView();

    public function new() {
        super();

        listview.percentWidth  = 100;
        listview.percentHeight = 100;

        var ds = new haxe.ui.data.ArrayDataSource<Dynamic>();
        listview.dataSource = ds;
        addComponent(listview);

    }
}

BUT if I add the list view only if the parent component is ready

class SentencesListView extends VBox {

   var listview:ListView = new ListView();

    public function new() {
        super();

        listview.percentWidth  = 100;
        listview.percentHeight = 100;
    }

    @:bind(this,haxe.ui.events.UIEvent.READY)
    private function createList(e) {
        var ds = new haxe.ui.data.ArrayDataSource<Dynamic>();
        listview.dataSource = ds;
        addComponent(listview);
    }

it works :)

Shallowmallow commented 2 years ago

Ohin fact, it is okay (lol ) . Hopefully some people will learn from this thread. I the lastest haxeui , there are some useful messages "You are trying to create a component before the toolkit has been initialized. This could have undefined results.". I thought you had to initialize the app to a component to the main view . But it is even for adding components to other components.