From 459dd32dc33a99da08f38b9d526d619633f648d4 Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 22 Jul 2002 18:56:04 +0000 Subject: [PATCH] add lyx_gui::exit() so Qt doesn't have to busy loop, which was eating CPU very badly git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4748 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/frontends/ChangeLog | 4 ++++ src/frontends/lyx_gui.h | 5 +++++ src/frontends/qt2/ChangeLog | 4 ++++ src/frontends/qt2/lyx_gui.C | 14 ++++++++------ src/frontends/xforms/ChangeLog | 4 ++++ src/frontends/xforms/lyx_gui.C | 10 +++++++++- src/lyx_cb.C | 6 +++--- src/lyx_main.C | 3 --- 9 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 608982807a..62ecb5b950 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2002-07-22 John Levon + + * lyx_gui.C: use lyx_gui::exit() + 2002-07-22 John Levon * LyXAction.C: show the failing pseudo action diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index e2cbb5afbd..333fb7c61d 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2002-07-22 John Levon + + * lyx_gui.h: add exit() + 2002-07-22 John Levon * Toolbar.h: diff --git a/src/frontends/lyx_gui.h b/src/frontends/lyx_gui.h index bcc68c7f94..741688a311 100644 --- a/src/frontends/lyx_gui.h +++ b/src/frontends/lyx_gui.h @@ -36,6 +36,11 @@ namespace lyx_gui { */ void start(string const & batch, std::vector files); + /** + * quit running LyX + */ + void exit(); + /** Eg, passing LColor::black returns "000000", * passing LColor::white returns "ffffff". */ diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 3c5db9fb8c..2227423fdd 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2002-07-22 John Levon + + * lyx_gui.C: add exit() so we don't busy loop ! + 2002-07-22 John Levon * QCommandEdit.C: complete if right at end of line diff --git a/src/frontends/qt2/lyx_gui.C b/src/frontends/qt2/lyx_gui.C index 0991a98181..952edde402 100644 --- a/src/frontends/qt2/lyx_gui.C +++ b/src/frontends/qt2/lyx_gui.C @@ -50,7 +50,6 @@ using std::vector; using std::hex; using std::endl; -extern bool finished; extern BufferList bufferlist; // FIXME: wrong place ! @@ -111,16 +110,19 @@ void lyx_gui::start(string const & batch, vector files) view.getLyXFunc()->dispatch(batch); } - // FIXME: something somewhere is EATING CPU - while (!finished) { - qApp->processEvents(); - } + qApp->exec(); - // FIXME + // FIXME delete lyxserver; } +void lyx_gui::exit() +{ + qApp->exit(0); +} + + string const lyx_gui::hexname(LColor::color col) { QColor color(lcolor.getX11Name(col).c_str()); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 12cab17920..0881b799f4 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2002-07-22 John Levon + + * lyx_gui.C: add lyx_gui::exit() + 2002-07-22 John Levon * Toolbar_pimpl.h: diff --git a/src/frontends/xforms/lyx_gui.C b/src/frontends/xforms/lyx_gui.C index 7d5139fb9a..8bb25f5288 100644 --- a/src/frontends/xforms/lyx_gui.C +++ b/src/frontends/xforms/lyx_gui.C @@ -55,7 +55,6 @@ using std::setbase; using std::setfill; using std::setw; -extern bool finished; extern BufferList bufferlist; // FIXME: wrong place ! @@ -63,6 +62,9 @@ LyXServer * lyxserver; namespace { +/// quit lyx +bool finished = false; + /// set default GUI configuration void setDefaults() { @@ -309,6 +311,12 @@ void lyx_gui::start(string const & batch, vector files) } +void lyx_gui::exit() +{ + finished = true; +} + + string const lyx_gui::hexname(LColor::color col) { string const name = lcolor.getX11Name(col); diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 1eb77860eb..ba68ea6323 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -17,7 +17,6 @@ #include "bufferview_funcs.h" #include "debug.h" #include "lastfiles.h" -#include "frontends/LyXView.h" #include "lyxrc.h" #include "lyxtext.h" #include "gettext.h" @@ -25,6 +24,8 @@ #include "insets/insetlabel.h" +#include "frontends/lyx_gui.h" +#include "frontends/LyXView.h" #include "frontends/Alert.h" #include "frontends/FileDialog.h" @@ -52,7 +53,6 @@ using std::make_pair; extern BufferList bufferlist; // this should be static, but I need it in buffer.C bool quitting; // flag, that we are quitting the program -extern bool finished; // all cleanup done just let it run through now. void ShowMessage(Buffer const * buf, @@ -239,7 +239,7 @@ void QuitLyX() DestroyLyXTmpDir(system_tempdir); - finished = true; + lyx_gui::exit(); } diff --git a/src/lyx_main.C b/src/lyx_main.C index ddb6e7bddd..b515374768 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -68,9 +68,6 @@ boost::scoped_ptr lastfiles; // This is the global bufferlist object BufferList bufferlist; -// this should be static, but I need it in buffer.C -bool finished = false; // flag, that we are quitting the program - // convenient to have it here. boost::scoped_ptr toplevel_keymap;