diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-12-02 13:08:45 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-12-02 22:25:23 +0900 |
commit | 5af24c40137c80c4de65f63ce816f77ef8b7bea3 (patch) | |
tree | a47b22ac3ff5b79df381ea09505bf82c2071c847 /lib/util/blockingtdeprocess.cpp | |
parent | 5a0afc9e219fe72a763af031a4b3ce385316f1ea (diff) | |
download | tdevelop-5af24c40137c80c4de65f63ce816f77ef8b7bea3.tar.gz tdevelop-5af24c40137c80c4de65f63ce816f77ef8b7bea3.zip |
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'lib/util/blockingtdeprocess.cpp')
-rw-r--r-- | lib/util/blockingtdeprocess.cpp | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/lib/util/blockingtdeprocess.cpp b/lib/util/blockingtdeprocess.cpp new file mode 100644 index 00000000..f57ae77d --- /dev/null +++ b/lib/util/blockingtdeprocess.cpp @@ -0,0 +1,105 @@ +/*************************************************************************** +* Copyright (C) 2006 by Andras Mantia * +* amantia@kde.org * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +***************************************************************************/ + +#include "blockingtdeprocess.h" + +#include <tqapplication.h> +#include <tqtimer.h> + +BlockingTDEProcess::BlockingTDEProcess(TQObject *parent, const char *name) + : TDEProcess(parent, name) +{ + m_stdOut = ""; + m_stdErr = ""; + m_timeoutValue = 60; + m_timer = 0L; + + connect(this, TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)), + this, TQ_SLOT(slotReceivedStdOut(TDEProcess *, char *, int))); + connect(this, TQ_SIGNAL(receivedStderr(TDEProcess *, char *, int)), + this, TQ_SLOT(slotReceivedStdErr(TDEProcess *, char *, int))); + connect(this, TQ_SIGNAL(processExited(TDEProcess *)), + this, TQ_SLOT(slotProcessExited(TDEProcess *))); +} + +BlockingTDEProcess::BlockingTDEProcess() + : TDEProcess() +{ + m_stdOut = ""; + m_stdErr = ""; + m_timeoutValue = 60; + m_timer = 0L; + connect(this, TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)), + this, TQ_SLOT(slotReceivedStdOut(TDEProcess *, char *, int))); + connect(this, TQ_SIGNAL(receivedStderr(TDEProcess *, char *, int)), + this, TQ_SLOT(slotReceivedStdErr(TDEProcess *, char *, int))); + connect(this, TQ_SIGNAL(processExited(TDEProcess *)), + this, TQ_SLOT(slotProcessExited(TDEProcess *))); +} + + +BlockingTDEProcess::~BlockingTDEProcess() +{ +} +bool BlockingTDEProcess::start(RunMode runmode, Communication comm) +{ + if (TDEProcess::start(runmode, comm)) + { + m_timeout = false; + m_timer = new TQTimer(); + connect(m_timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotTimeOut())); + m_timer->start(m_timeoutValue*1000, true); + enter_loop(); + delete m_timer; + m_timer = 0L; + return !m_timeout; + } else + return false; +} + + +void BlockingTDEProcess::slotReceivedStdOut(TDEProcess *, char *buffer, int buflen) +{ + m_stdOut += TQString::fromLatin1(buffer, buflen); +} + +void BlockingTDEProcess::slotReceivedStdErr(TDEProcess *, char *buffer, int buflen) +{ + m_stdErr += TQString::fromLatin1(buffer, buflen); +} + +void BlockingTDEProcess::slotProcessExited(TDEProcess *) +{ + tqApp->exit_loop(); +} + +void BlockingTDEProcess::slotTimeOut() +{ + m_timeout = true; + kill(); + tqApp->exit_loop(); +} + + +void tqt_enter_modal( TQWidget *widget ); +void tqt_leave_modal( TQWidget *widget ); + +void BlockingTDEProcess::enter_loop() +{ + TQWidget dummy(0,0,WType_Dialog | WShowModal); + dummy.setFocusPolicy( TQWidget::NoFocus ); + tqt_enter_modal(&dummy); + tqApp->enter_loop(); + tqt_leave_modal(&dummy); +} + + +#include "blockingtdeprocess.moc" |