Thanks for the information, but this is just one temporary dialog 
brought up by a menu item from the main window of the program.  It looks 
like using Fl::wait() is doing the trick so I'll keep using that I believe.

Thanks,
Moses

On 01/25/2013 11:31 AM, Greg Ercolano wrote:
> On 01/25/13 08:46, Moses McKnight wrote:
>> On 01/25/2013 09:13 AM, Moses McKnight wrote:
>>> Ok, I think I figured it out.  The way I create the window is like this
>>> in a menu callback function:
>>>
>>> void gen_license_cb(Fl_Widget *w, void *ptr)
>>> {
>>>     licgen generator;
>>>     generator.make_window();
>>>     generator.hub_id_input->type(FL_INT_INPUT);
>>>     generator.hub_id_input->precision(0);
>>>     generator.hub_id_input->value(hub_id);
>>>     generator.window->show();
>>> }
>>>
>>> I think the object is being deleted after the show() even though the
>>> window is still there and active.
>>>
>>> What is the best way to keep the object around until the window is closed?
>>
>> I looked at the code in fl_ask.cxx and added the following after
>> window->show()
>>
>> while (generator.window->shown()) Fl::wait();
>> That worked.  If anyone has a better way to do this please let me know.
>
>       If this is the only window in your application,
>       calling Fl::run() is the better thing.
>
>       I took your two files and merged them into one, just to make it
>       easy to compile (and post here). See the *** lines for my changes.
>
>       I added a main() function so that the code compiles and runs
>       as a standalone app, and I added the method called
>       licgen::generate_license() which just runs: 
> info_output->value("Testing");
>
>       Seems to work fine, didn't crash on close and the Testing message
>       gets created OK.
>
>       Perhaps the problem was just in how you invoke the class..
>       ie. what I put in main() below.
>
> // generated by Fast Light User Interface Designer (fluid) version 1.0302
>
> #ifndef licensegen_h
> #define licensegen_h
> #include <FL/Fl.H>
> #include <FL/Fl_Double_Window.H>
> #include <FL/Fl_Value_Input.H>
> #include <FL/Fl_Output.H>
> #include <FL/Fl_Button.H>
>
> class licgen {
> public:
>     void generate_license();
>     Fl_Double_Window* make_window();
>     Fl_Double_Window *window;
>     Fl_Value_Input *hub_id_input;
>     Fl_Output *info_output;
> private:
>     inline void cb_Generate_i(Fl_Button*, void*);
>     static void cb_Generate(Fl_Button*, void*);
>     inline void cb_Close_i(Fl_Button*, void*);
>     static void cb_Close(Fl_Button*, void*);
> };
> #endif
>
> // *** COMMENTED FOLLOWING TWO LINES OUT TO GET CODE ALL IN ONE FILE ***
> // generated by Fast Light User Interface Designer (fluid) version 1.0302
> // #include "licensegen.h"
>
>
> void licgen::cb_Generate_i(Fl_Button*, void*) {
>     generate_license();
> }
> void licgen::cb_Generate(Fl_Button* o, void* v) {
>     ((licgen*)(o->parent()->user_data()))->cb_Generate_i(o,v);
> }
>
> void licgen::cb_Close_i(Fl_Button*, void*) {
>     window->hide();
> }
> void licgen::cb_Close(Fl_Button* o, void* v) {
>     ((licgen*)(o->parent()->user_data()))->cb_Close_i(o,v);
> }
>
> Fl_Double_Window* licgen::make_window() {
>     { window = new Fl_Double_Window(435, 130, "License Generator");
>       window->labelsize(12);
>       window->user_data((void*)(this));
>       { hub_id_input = new Fl_Value_Input(5, 30, 275, 25, "ID#");
>         hub_id_input->labelsize(12);
>         hub_id_input->textsize(12);
>         hub_id_input->align(Fl_Align(FL_ALIGN_TOP_LEFT));
>       } // Fl_Value_Input* hub_id_input
>       { info_output = new Fl_Output(5, 63, 420, 25);
>         info_output->color(FL_BACKGROUND_COLOR);
>         info_output->labelsize(12);
>         info_output->textsize(12);
>         info_output->align(Fl_Align(FL_ALIGN_TOP_LEFT));
>       } // Fl_Output* info_output
>       { Fl_Button* o = new Fl_Button(290, 30, 135, 25, "Generate License...");
>         o->labelsize(12);
>         o->callback((Fl_Callback*)cb_Generate);
>       } // Fl_Button* o
>       { Fl_Button* o = new Fl_Button(180, 98, 80, 25, "Close");
>         o->labelsize(12);
>         o->callback((Fl_Callback*)cb_Close);
>       } // Fl_Button* o
>       window->end();
>     } // Fl_Double_Window* window
>     return window;
> }
>
> // *** ADDED FOLLOWING THREE LINES AS PER YOUR EMAIL ***
> void licgen::generate_license() {
>      info_output->value("Testing");
> }
>
> // *** ADDED A MAIN FUNCTION TO MAKE USE OF YOUR CLASS ***
> int main() {
>      licgen lic;
>      Fl_Window *win = lic.make_window();
>      win->show();
>      return Fl::run();
> }
>
>
>
> _______________________________________________
> fltk mailing list
> [email protected]
> http://lists.easysw.com/mailman/listinfo/fltk
>

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to