texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] QT interactive prompt bug (EXC_BAD_ACCESS) + solution


From: Gubinelli Massimiliano
Subject: Re: [Texmacs-dev] QT interactive prompt bug (EXC_BAD_ACCESS) + solution
Date: Sat, 6 Nov 2010 23:35:49 +0100

Hi Miguel,
 the fix is not quite correct. I've committed an alternative fix. The reasong for the crash is the following (according to my understanding)
in QTMInteractivePrompt::exec()
1. you create a temporary status bar
2. you add the prompt to the status bar (so it become children of the status bar, according to docs)
3. you add the status bar to the window (so it become children of the window, according to docs)
4. after execution you remove the status bar from the window (but its parent remains the window)
5. when the status bar is released (somewhere, somehow) it tries to release the interactive prompt which is allocated on the stack (and  already freed) so you get the crash.

My solution is to reset the parent of the interactive prompt and to explicitly delete the temporary status bar. Usually if you allocate an object you have to be sure that it will be deallocated at appropriate time. Maybe put comments to signal when you think it will be most probably deallocated.


Best
max

On 6 nov. 2010, at 19:20, Miguel de Benito Delgado wrote:

It looks like I'm on a roll! ;) First the fix, in case you don't have time to waste on my ramblings:

File qt_dialogues.cpp, line 718 onward, change to:

  QTMInteractivePrompt* _prompt = new QTMInteractivePrompt(label, items, to_qstring(it->type), tm_mainwindow());


  if (_prompt->exec() == QDialog::Accepted) {
    QString text = _prompt->currentText();
    ((qt_input_text_widget_rep*) int_input.rep) -> text = scm_quote (from_qstring (text));
    ((qt_input_text_widget_rep*) int_input.rep) -> cmd ();
  } else {
    // ((qt_input_text_widget_rep*) int_input.rep) -> text="#f";
  }
  delete _prompt;
}

And here's the bug: 
  1. Take any document and manually create a fake autosave file (i.e. with the trailing tilde) which is newer.
  2. Open the document in TeXmacs QT (svn), with the new interactive prompt and the option to show interactive messages on the status bar.
  3. The shiny new interactive prompt kicks in, asks whether you want to load the newer autosaved file.
  4. Say whatever you want, it crashes on you.
Seems like qt_tm_widget_rep::write is doing tw->removeWidget(old_canvas); and this kills because the QTMInteractivePrompt had been created on the stack and someone is trying to delete it. Or that's my guess.

Kind regards,
________________
Miguel de  Benito.
_______________________________________________
Texmacs-dev mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/texmacs-dev


reply via email to

[Prev in Thread] Current Thread [Next in Thread]