[Top][All Lists]

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

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

From: Miguel de Benito Delgado
Subject: Re: [Texmacs-dev] QT interactive prompt bug (EXC_BAD_ACCESS) + solution
Date: Sun, 7 Nov 2010 00:18:44 +0100

Hmm... I did step 4 in order to have the status bar deleted and that's why I was removing myself (the QTMInteractivePrompt) from it before doing that, because otherwise it would have blown. But then, what you say makes sense and is perfectly consistent with my so-called fix preventing the crash, but just incidentally...

I'll have to be more careful next time, sorry.
Miguel de  Benito.

On Sat, Nov 6, 2010 at 23:35, Gubinelli Massimiliano <address@hidden> wrote:
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.


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

Texmacs-dev mailing list

reply via email to

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