title: Issue with fltk callback using this pointer
body: <pre><code>void MainMenu::cb_userinput(fltk::Input *in, void *v)
  {
      MainMenu *mm = (MainMenu*)v;
      memset(user_input, '\0', sizeof(user_input));
      strcpy((char*)user_input, in-&gt;value());
      in-&gt;value('\0');
      memset(user_input, '\0', sizeof(user_input));
      mm-&gt;ExitFromMenu();
  }
  void MainMenu::ExitFromMenu()
  {
      Menu-&gt;clear();
      Menu-&gt;end();
  }
  </code></pre>
  <p>the line I am calling callback</p>
  <pre><code>input-&gt;callback((fltk::Callback*)cb_userinput, this);
  </code></pre>
  <p>callback function is called successfully, if I remove both the lines from below function, then my program runs successfully but if I use both of these lines then program gives segmentation fault error,</p>
  <pre><code>void MainMenu::ExitFromMenu()
  {
      //Menu-&gt;clear();
      //Menu-&gt;end();
  }
  </code></pre>
  <p>I can't use gdb as this program is running on remote device, can anyone help me to find out the issue? thanks in advance.</p>
  <p>Full class</p>
  <pre><code>class MainMenu : public IUserOptions
  {
      protected:
          Group *Menu;
          void DisplayUserOptions(); 
          static char user_input[3];
          static void cb_userinput(fltk::Input *in, void *v);
          int user_choice;
          void ExitFromMenu();
      public:
          MainMenu(vector&lt;string&gt; userChoices);
          int GetUserOption();
          ~MainMenu();
  };
  
  char MainMenu::user_input[3];
  MainMenu::MainMenu(vector&lt;string&gt; userChoices) : IUserOptions(userChoices)
  {
      Menu = new fltk::Group(0, 0, 320, 220, &quot;&quot;);
  }
  void MainMenu::cb_userinput(fltk::Input *in, void *v)
  {
      MainMenu *mm = (MainMenu*)v;
    memset(user_input, '\0', sizeof(user_input));
    strcpy((char*)user_input, in-&gt;value());
      in-&gt;value('\0');
      memset(user_input, '\0', sizeof(user_input));
      mm-&gt;ExitFromMenu();
  }
  void MainMenu::ExitFromMenu()
  {
      Menu-&gt;clear();
      Menu-&gt;end();
  }
  void MainMenu::DisplayUserOptions()
  {
      Menu-&gt;set_vertical();
      Menu-&gt;begin();
  
      fltk::Widget *Wel = new fltk::Widget(0, 0,320, 220, &quot;&quot;);
      Wel-&gt;color((fltk::Color)0xf5751000);
      Wel-&gt;box(fltk::FLAT_BOX);
  
      fltk::Widget *MAIN_MENU_BOX = new Widget(0, 0, 320, 30, &quot;Genus Power Vers 1.0.0&quot;);
      MAIN_MENU_BOX-&gt;box(FLAT_BOX);
      MAIN_MENU_BOX-&gt;color((fltk::Color)0x6E040600);
      MAIN_MENU_BOX-&gt;labelfont(fltk::TIMES_BOLD);
      MAIN_MENU_BOX-&gt;labelsize(20);
      MAIN_MENU_BOX-&gt;labelcolor(WHITE);
  
      // first Menu Option Download Meter
      fltk::Button *mb1= new fltk::Button(10,40,200,30, &quot; 1. Download &quot;);//60
      mb1-&gt;labelfont(fltk::TIMES_BOLD);
      mb1-&gt;labelsize(16);
      mb1-&gt;argument(1);
      mb1-&gt;take_focus();
      mb1-&gt;color((fltk::Color)0x6E040600);
      mb1-&gt;align(fltk::ALIGN_CENTER);
      mb1-&gt;labelcolor(WHITE);
      mb1-&gt;box(ROUNDED_BOX);
  
    fltk::Input* input = new fltk::Input(400, 60, 120, 25, &quot;key :&quot;);
    input-&gt;labelsize(14);
    input-&gt;callback((fltk::Callback*)cb_userinput, this);
    input-&gt;take_focus();
    input-&gt;argument(2);
    input-&gt;labelfont(HELVETICA_BOLD_ITALIC);
    input-&gt;textsize(14);
    input-&gt;textfont(fltk::COURIER_BOLD);
    input-&gt;when(fltk::WHEN_ENTER_KEY_CHANGED);
  
  
      // Second Menu Option to Print
      fltk::Button *mb2= new fltk::Button(10,80,200,30, &quot; 0. Quit &quot;);//60
      mb2-&gt;labelfont(fltk::TIMES_BOLD);
      mb2-&gt;labelsize(16);
      mb2-&gt;color((fltk::Color)0x6E040600);
      mb2-&gt;align(fltk::ALIGN_CENTER);
      mb2-&gt;labelcolor(WHITE);
      mb2-&gt;box(ROUNDED_BOX);
  
  
  
      Menu-&gt;end();
  }
  int MainMenu::GetUserOption()
  {
      cout &lt;&lt; endl &lt;&lt; &quot;Address of this:&quot; &lt;&lt; this &lt;&lt; endl;
      getchar();  
      DisplayUserOptions();
       
      return user_choice;
  }
  MainMenu::~MainMenu()
  {   
      delete Menu;
  }
  </code></pre>
  <p>and my base class is</p>
  <pre><code>class IUserOptions
  {
      protected:
          vector&lt;string&gt; UserChoices;
      public:
          IUserOptions(vector&lt;string&gt; userChoices);
          virtual int GetUserOption() = 0;
          virtual ~IUserOptions();
  };
  </code></pre>