forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TQtEvent.cxx
65 lines (55 loc) · 2.14 KB
/
TQtEvent.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// @(#)root/qt:$Id$
// Author: Valeri Fine 21/01/2002
/*************************************************************************
* Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
* Copyright (C) 2002 by Valeri Fine. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include <QObject>
#include "TQtEvent.h"
#include "TWaitCondition.h"
#include <assert.h>
//////////////////////////////////////////////////////////////////////////////
//
// class TQtEvent to send an event between two Qt threads
//
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
TQtEvent::TQtEvent(int code):QEvent(QEvent::Type(QEvent::User+code)), fCondition(0), fResult(0)
, fReceiver(0),fThatEvent(0)
{ }
////////////////////////////////////////////////////////////////////////////////
TQtEvent::TQtEvent(QObject *o, QEvent *e): QEvent(QEvent::User), fCondition(0)
, fResult(0), fReceiver(o),fThatEvent(e)
{ }
////////////////////////////////////////////////////////////////////////////////
bool TQtEvent::Notify()
{
bool r = FALSE;
if (fReceiver)
{
r = fReceiver->event(fThatEvent);
SetResult();
}
return r;
}
////////////////////////////////////////////////////////////////////////////////
void TQtEvent::SetResult(unsigned long e)
{
if (fResult) *fResult = e;
if (fCondition) fCondition->wakeOne();
}
////////////////////////////////////////////////////////////////////////////////
void TQtEvent::SetWait(TWaitCondition &condition)
{
fCondition = &condition;
}
////////////////////////////////////////////////////////////////////////////////
void TQtEvent::SetWait(TWaitCondition &condition,unsigned long &result)
{
SetWait(condition);
fResult = &result;
}