From 74e77476b5c6f39c0f98c5b64822710ac97911d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Fri, 4 Dec 2009 11:08:24 +0000 Subject: [PATCH] also process user input, trigger more processEvents git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32328 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/Systemcall.cpp | 47 ++++++++++++++++++++------------- src/support/SystemcallPrivate.h | 2 ++ 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index f1d3e75408..83373d012d 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -28,7 +28,7 @@ #include #include #include - +#include #define USE_QPROCESS @@ -138,7 +138,7 @@ int Systemcall::startscript(Starttype how, string const & what) SystemcallPrivate::SystemcallPrivate(const std::string& of) : - proc_(new QProcess), outindex_(0), + proc_(new QProcess), outindex_(0), process_events(false), errindex_(0), outfile(of), showout_(false), showerr_(false) { if (!outfile.empty()) { @@ -167,19 +167,28 @@ void SystemcallPrivate::startProcess(const QString& cmd) } } +void SystemcallPrivate::processEvents() +{ + if(process_events) { + //static int count = 0; qDebug() << count++ << ": waitAndProcessEvents"; + QCoreApplication::processEvents(QEventLoop::AllEvents); + } +} void SystemcallPrivate::waitAndProcessEvents() { Sleep::millisec(100); - QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + processEvents(); } -bool SystemcallPrivate::waitWhile(State waitwhile, bool process_events, int timeout) +bool SystemcallPrivate::waitWhile(State waitwhile, bool proc_events, int timeout) { if (!proc_) return false; + process_events = proc_events; + // Block GUI while waiting, // relay on QProcess' wait functions if (!process_events) { @@ -259,6 +268,7 @@ void SystemcallPrivate::stdOut() } } } + processEvents(); } @@ -276,6 +286,21 @@ void SystemcallPrivate::stdErr() } } } + processEvents(); +} + + +void SystemcallPrivate::processStarted() +{ + state = Running; + // why do we get two started signals? + //disconnect(proc_, SIGNAL(started()), this, SLOT(processStarted())); +} + + +void SystemcallPrivate::processFinished(int, QProcess::ExitStatus status) +{ + state = Finished; } @@ -319,20 +344,6 @@ QString SystemcallPrivate::errorMessage() const } -void SystemcallPrivate::processStarted() -{ - state = Running; - // why do we get two started signals? - //disconnect(proc_, SIGNAL(started()), this, SLOT(processStarted())); -} - - -void SystemcallPrivate::processFinished(int, QProcess::ExitStatus status) -{ - state = Finished; -} - - QString SystemcallPrivate::exitStatusMessage() const { if (!proc_) diff --git a/src/support/SystemcallPrivate.h b/src/support/SystemcallPrivate.h index ff4afed0ea..4151940278 100644 --- a/src/support/SystemcallPrivate.h +++ b/src/support/SystemcallPrivate.h @@ -80,8 +80,10 @@ private: bool showout_; /// bool showerr_; + bool process_events; void waitAndProcessEvents(); + void processEvents(); void killProcess(); -- 2.39.2