Re: NEWT :: selecting an item from a listbox

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hi Ken,

Here you've a working example using pointers as you first tried: http://openeuphoria.org/pastey/216.wc

Of course, your solution is the correct one, but to prove you could store a pointer as data I got this example working.

The problem was that you allocated memory and got a pointer to it but that memory was set to autofree. As the pointer is "forgotten" by Euphoria and passed to Newt, Euphoria deallocates it as thinks it's not used anymore. So the key was to allocate the memory and not free it until the end.

By the way, I've just realized my code has a memory leak since I only free the selected's item memory. So be sure to check that if you're going to store pointers as data in the listboxes :)

Cheers,
Guillermo

PS: Relevant documentation: http://openeuphoria.org/docs/std_machine.html#_5596_allocate_data

said...

Automatically - If the cleanup parameter is non-zero, then the memory is returned when the variable that receives the address goes out of scope and is not referenced by anything else.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu