• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Utility Library
 

KDevelop Utility Library

  • lib
  • util
blockingkprocess.cpp
1/***************************************************************************
2* Copyright (C) 2006 by Andras Mantia *
3* amantia@kde.org *
4* *
5* This program is free software; you can redistribute it and/or modify *
6* it under the terms of the GNU General Public License as published by *
7* the Free Software Foundation; either version 2 of the License, or *
8* (at your option) any later version. *
9* *
10***************************************************************************/
11
12#include "blockingkprocess.h"
13
14#include <tqapplication.h>
15#include <tqtimer.h>
16
17BlockingTDEProcess::BlockingTDEProcess(TQObject *parent, const char *name)
18 : TDEProcess(parent, name)
19{
20 m_stdOut = "";
21 m_stdErr = "";
22 m_timeoutValue = 60;
23 m_timer = 0L;
24
25 connect(this, TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)),
26 this, TQ_SLOT(slotReceivedStdOut(TDEProcess *, char *, int)));
27 connect(this, TQ_SIGNAL(receivedStderr(TDEProcess *, char *, int)),
28 this, TQ_SLOT(slotReceivedStdErr(TDEProcess *, char *, int)));
29 connect(this, TQ_SIGNAL(processExited(TDEProcess *)),
30 this, TQ_SLOT(slotProcessExited(TDEProcess *)));
31}
32
33BlockingTDEProcess::BlockingTDEProcess()
34 : TDEProcess()
35{
36 m_stdOut = "";
37 m_stdErr = "";
38 m_timeoutValue = 60;
39 m_timer = 0L;
40 connect(this, TQ_SIGNAL(receivedStdout(TDEProcess *, char *, int)),
41 this, TQ_SLOT(slotReceivedStdOut(TDEProcess *, char *, int)));
42 connect(this, TQ_SIGNAL(receivedStderr(TDEProcess *, char *, int)),
43 this, TQ_SLOT(slotReceivedStdErr(TDEProcess *, char *, int)));
44 connect(this, TQ_SIGNAL(processExited(TDEProcess *)),
45 this, TQ_SLOT(slotProcessExited(TDEProcess *)));
46}
47
48
49BlockingTDEProcess::~BlockingTDEProcess()
50{
51}
52bool BlockingTDEProcess::start(RunMode runmode, Communication comm)
53{
54 if (TDEProcess::start(runmode, comm))
55 {
56 m_timeout = false;
57 m_timer = new TQTimer();
58 connect(m_timer, TQ_SIGNAL(timeout()), this, TQ_SLOT(slotTimeOut()));
59 m_timer->start(m_timeoutValue*1000, true);
60 enter_loop();
61 delete m_timer;
62 m_timer = 0L;
63 return !m_timeout;
64 } else
65 return false;
66}
67
68
69void BlockingTDEProcess::slotReceivedStdOut(TDEProcess *, char *buffer, int buflen)
70{
71 m_stdOut += TQString::fromLatin1(buffer, buflen);
72}
73
74void BlockingTDEProcess::slotReceivedStdErr(TDEProcess *, char *buffer, int buflen)
75{
76 m_stdErr += TQString::fromLatin1(buffer, buflen);
77}
78
79void BlockingTDEProcess::slotProcessExited(TDEProcess *)
80{
81 tqApp->exit_loop();
82}
83
84void BlockingTDEProcess::slotTimeOut()
85{
86 m_timeout = true;
87 kill();
88 tqApp->exit_loop();
89}
90
91
92void tqt_enter_modal( TQWidget *widget );
93void tqt_leave_modal( TQWidget *widget );
94
95void BlockingTDEProcess::enter_loop()
96{
97 TQWidget dummy(0,0,WType_Dialog | WShowModal);
98 dummy.setFocusPolicy( TQWidget::NoFocus );
99 tqt_enter_modal(&dummy);
100 tqApp->enter_loop();
101 tqt_leave_modal(&dummy);
102}
103
104
105#include "blockingkprocess.moc"

KDevelop Utility Library

Skip menu "KDevelop Utility Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Utility Library

Skip menu "KDevelop Utility Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Utility Library by doxygen 1.9.8
This website is maintained by Timothy Pearson.