title: GTK+2 : My App is Crashing on quit
body: <p>Hi I'm tying to write  a Simple Text editor and i use this Callback to handle main Window delete-event </p>
  
  <pre><code>g_signal_connect(G_OBJECT(mainWindow),"delete-event",G_CALLBACK(quit),   (gpointer)textView);
  </code></pre>
  
  <p>this is my callback function to handle this event </p>
  
  <pre><code>    void quit(GtkWidget *wid,GdkEvent  *e,gpointer data)
  {
      GtkTextIter iStart,iEnd;
      GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textView));
      gtk_text_buffer_get_bounds(buffer,&amp;iStart,&amp;iEnd);
      gchar * text = gtk_text_buffer_get_text(buffer,&amp;iStart,&amp;iEnd,FALSE);
      if(docFile.isSaved == FALSE &amp;&amp; strcmp("",text) )  
      {
          GtkWidget * msgDialog;
          msgDialog = gtk_message_dialog_new(NULL,
                                             GTK_DIALOG_MODAL,
                                             GTK_MESSAGE_QUESTION,
                                             GTK_BUTTONS_YES_NO,
                                             "Do you manna save your file ?",
                                             NULL);
  
          switch (gtk_dialog_run (GTK_DIALOG(msgDialog)))
          {
              case GTK_RESPONSE_YES:
                  if(docFile.name == NULL)
                  {
                      if(saveAs(textView))
                      {
                          gtk_widget_destroy (msgDialog);
                          gtk_main_quit ();
                      }
                  }
                  else
                  {   
                      save(textView);
                      gtk_widget_destroy (msgDialog);
                      gtk_main_quit ();
                  }
                  break;
              case GTK_RESPONSE_NO:
                      gtk_widget_destroy (msgDialog);
                      gtk_main_quit ();
  
          }
      }else{
              gtk_main_quit();
          }
  }
  </code></pre>
  
  <p>but when i'm quit the window i found this in my terminal </p>
  
  <pre><code>(Black Hole) adil Tux : SimpleEditor 
  &gt;&gt;&gt;&gt; ./a.out 
  *** Error in `./a.out': free(): invalid pointer: 0x0000000000604570 ***
  ======= Backtrace: =========
  /usr/lib/libc.so.6(+0x7340e)[0x7fefc476a40e]
  /usr/lib/libc.so.6(+0x7884e)[0x7fefc476f84e]
  /usr/lib/libc.so.6(+0x7900b)[0x7fefc477000b]
  ./a.out[0x402ad0]
  /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7fefc4717040]
  ./a.out[0x402069]
  ======= Memory map: ========
  00400000-00404000 r-xp 00000000 08:06 2107681                            /home/adil/Src/SimpleEditor/a.out
  00604000-00605000 rw-p 00004000 08:06 2107681                            /home/adil/Src/SimpleEditor/a.out
  01a38000-01b83000 rw-p 00000000 00:00 0 
                               [heap]
  ....
  
  7fefc736b000-7fefc736c000 rw-p 00022000 08:06 920725                     /usr/lib/ld-2.20.so
  7fefc736c000-7fefc736d000 rw-p 00000000 00:00 0 
  7fff6fd1c000-7fff6fd3d000 rw-p 00000000 00:00 0                          [stack]
  7fff6fdfc000-7fff6fdfe000 r-xp 00000000 00:00 0                          [vdso]
  7fff6fdfe000-7fff6fe00000 r--p 00000000 00:00 0                          [vvar]
  ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
  Aborted (core dumped)
  </code></pre>
  
  <p>and thinks you .</p>