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

append to parent and segfault #8

Open
kenietz opened this issue Apr 2, 2024 · 0 comments
Open

append to parent and segfault #8

kenietz opened this issue Apr 2, 2024 · 0 comments

Comments

@kenietz
Copy link

kenietz commented Apr 2, 2024

Hi,

i am trying to add some buttons dynamically to a frame. The frame itself is in another frame.

----------- SAMPLE CODE -----------
use IUP ':all';

my ($frame1,$subFrame,$hbox1,$dlg,$butt);

$subFrame=IUP::Frame->new(SIZE=>'200x200',TITLE=>'Projects',SCROLLBAR=>'VERTICAL');

sub create_project{
print "\n create proj\n";
$butt=IUP::Button->new(TITLE=>"proj",ACTION=>&bla);

$subFrame->Append($butt);

$butt->Map();

$subFrame->Refresh();

}

sub bla{
print " bla\n";
}

create the main dialog

sub init_dialog {
my $menu = IUP::Menu->new( child=>[
IUP::Item->new(TITLE=>"Message", ACTION=>&my_cb ),
IUP::Item->new(TITLE=>"Quit", ACTION=>sub { IUP_CLOSE } ),
]
);

$frame1 = IUP::Frame->new(SIZE=>'200x200',TITLE=>"PC", child=>
IUP::Vbox->new( child=>[
		IUP::Button->new( EXPAND=>'HORIZONTAL',TITLE=>"Create project", ACTION=>\&create_project ),
		$subFrame
	])
);

$hbox1 = IUP::Hbox->new( child=>$frame1);

return IUP::Dialog->new(SIZE=>'200x260',MENU=>$menu, TITLE=>"Custom Dialog Sample", child=>$hbox1 );

}

main program

$dlg = init_dialog();
$dlg->Show();
IUP->MainLoop();

----------- SAMPLE CODE -----------

So when i press on the button the in '$frame1' i can create one button without errors. Unfortunately the second time i press the main window closes with seg fault.

I was reading the manual and tried to find some examples of the exact procedures of dynamically adding widgets but could not find any, at least for perl-iup.

Any ideas what i might be doing wrong? Or how to resolve the issue?

Thank you for your time and efforts!

Cheers
D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant