FLTK logo

Re: FLTK crashing after menu popup [General Use]

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: FLTK crashing after menu popup [General Use] Albrecht Schlosser Nov 01, 2016  
  On 01.11.2016 17:26 Will B wrote:
> On Tuesday, November 1, 2016 at 3:50:54 AM UTC-7, MacArthur, Ian
> (Leonardo, UK) wrote:
>
>     > As requested, here is full example code that reproduces the problem:
>
>     Hmmm - that's not how I'd have done it; I'm uneasy about that use of
>     Fl::add_handler() to catch "global events" that then in turn trigger
>     further events... it feels slightly "recursive" to me.
>
>     I didn't try to debug it, other than to run your code "as is" on
>     Win7, and it just spins somewhere - didn't segfault mind you, but
>     didn't work either, just went into some sort of spin!
>
>     Rather than try to figure out why, I just rewrote it in something a
>     bit more like (what I imagine is) the fltk canonical style for popup
>     menus.
>     You probably ought to take a look at the test/menubar demo too for
>     more worked examples.
>
>     This looks like it works fine for me, does it work for you? Does it
>     do what you actually need to do?
>
>
> I've tried your approach with a child window, but the menu won't pop up
> with the child window.
>
> I know you don't agree with my code, but I actually got it from
> http://seriss.com/people/erco/fltk/#PopupMenu under the 'without
> callbacks' section.  I figured since he listed that method that it
> should be okay to use, yes?  The code listed there is:
>
> |
> // Popup menu WITHOUT callbacks -erco 09/07/09
> #include<FL/Fl.H>
> #include<FL/fl_ask.H>
> #include<FL/Fl_Window.H>
> #include<FL/Fl_Button.H>
> #include<FL/Fl_Menu.H>
> #include<stdio.h>
> // Callback invoked when button pushed
> voidpush_cb(Fl_Widget*w,void*){
>  Fl_Menu_Itemrclick_menu[]={
>  {"Do Thing 1"},
>  {"Do Thing 2"},
>  {"Do Thing 3"},
>  {0}
>  };
>  constFl_Menu_Item*m =rclick_menu->popup(Fl::event_x(),Fl::event_y(),0,0,0);
>  if(!m ){
>  return;
>  }elseif(strcmp(m->label(),"Do Thing 1")==0){
>  fl_choice("Thing 1 happened","OK",NULL,NULL);
>  }elseif(strcmp(m->label(),"Do Thing 2")==0){
>  fl_choice("Thing 2 happened","OK",NULL,NULL);
>  }elseif(strcmp(m->label(),"Do Thing 3")==0){
>  fl_choice("Thing 3 happened","OK",NULL,NULL);
>  }
>  return;
> }
> intmain(){
>  Fl_Windowwin(140,45,"Simple Popup Menu (No callbacks)");
>  Fl_Buttonbutt(10,10,120,25,"Push For Menu");
>  butt.callback(push_cb);
>  win.show();
>  return(Fl::run());
> }
> |
>
> This type of menu popup works /perfectly/ on the main window but crashes
> on the child window. So my whole point, I guess, for posting this
> question is why is it crashing on a child window and not the main window?

Please read my other post (a few minutes ago) first...

I doubt that the crash has anything to do with the main window vs. a
"child window". If you still think there is something wrong with the
code "in a child window" after reading my other post, then please post a
full program with the "child window" showing the crash.

I'm really interested in finding a bug if there is one, particularly
since we're going to release the next FLTK version very soon now. So
please show us your full code. Thanks.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.