Georg Baum wrote:
Abdelrazak Younes wrote:
Georg Baum wrote:
I strongly disagree. In case you don't remember what we did please reread
the old mails. There was a lot of testing, and the outcome was that some
internal qt structures rely on the fact that the QApplication variable is
created at the very beginning of main() and destroyed at the end of
main(). Since we cannot do that (or maybe we can - make main() a thin
wrapper and move it to the frontends) we have to workaround it.
Look at the present code. That's exactly what I am doing.
No. main() is still in main.C. In case you mean the workaround: Yes, you do
it almost, apart from the destruction of the Application object.
Yes that's what I mean.
The old workaround was
a plain variable that was sitting in a function. This did not work on
windows for reasons we where not able to figure out, so the static trick
was used there.
I know exactly the reason why it didn't work. That was because the
QApplication creation was local to the lyx_gui::exec() function thus in
principle invisible to the exec2() function; Qt structure make this
instance visible even though part of it was still visible.
I don't understand the last sentence. Should I replace the first or the
second "visible" with "invisible"?
The second, yes. The Qt structure make this instance visible through the
static QApplication constructor and the qApp pointer. But part of it was
invisible at destruction time. Some QObject were accessed through some
destructors after the QApplication instance was destroyed.
The static
trick made the QApplication instance persistent accross the lyx
structure, that's all. Now that I moved the exec2() function out or
lyx_gui, the LyX class can safely access this instance without being
affraid that it disappeared.
The old code on non-windows that did not work on windows was:
lyx_gui::exec() {
// 1) create QApplication
// 2) call LyX::ref().exec2()
// 3) destroy QApplication
}
Therefore it was guaranteed that the QApplication object was valid during
the call of exec2.
The problem on windows was that 3) lead to some infinite loop/crash (I don't
remember which).
Your explanation above does not match this code.
The problem is that QApplication::exit() was called somewhere during
LyX::ref().exec2() which caused the QApplication instance to disappear.
The static trick enabled us to make this instance persistent across
functions.
This commit with only a short notification before in the context of your
recentr changes looked to me as if you where rushing through and where not
aware of any potential problems.
Come on, I participated quite extensively in this testing and the coding
if you remember. I am not going blindly here.
Abdel.