Qt 4.8
Public Functions | Static Public Functions | Private Functions | Static Private Functions | Properties | Friends | List of all members
QWSSignalHandler Class Reference

#include <qwssignalhandler_p.h>

Inheritance diagram for QWSSignalHandler:
QWSSignalHandlerPrivate

Public Functions

void addLock (QLock *lock)
 
void addObject (QObject *object)
 
void addWSLock (QWSLock *wslock)
 
void removeLock (QLock *lock)
 
void removeWSLock (QWSLock *wslock)
 
 ~QWSSignalHandler ()
 

Static Public Functions

static QWSSignalHandlerinstance ()
 

Private Functions

void clear ()
 
 QWSSignalHandler ()
 

Static Private Functions

static void handleSignal (int signal)
 

Properties

QList< QLock * > locks
 
QObjectCleanupHandler objects
 
QHash< int, qt_sighandler_toldHandlers
 
QList< QWSLock * > wslocks
 

Friends

class QWSSignalHandlerPrivate
 

Detailed Description

Definition at line 73 of file qwssignalhandler_p.h.

Constructors and Destructors

◆ ~QWSSignalHandler()

QWSSignalHandler::~QWSSignalHandler ( )

Definition at line 85 of file qwssignalhandler.cpp.

86 {
87  clear();
88 }

◆ QWSSignalHandler()

QWSSignalHandler::QWSSignalHandler ( )
private

Definition at line 69 of file qwssignalhandler.cpp.

70 {
71  const int signums[] = { SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE,
72  SIGSEGV, SIGTERM, SIGBUS };
73  const int n = sizeof(signums)/sizeof(int);
74 
75  for (int i = 0; i < n; ++i) {
76  const int signum = signums[i];
77  qt_sighandler_t old = signal(signum, handleSignal);
78  if (old == SIG_IGN) // don't remove shm and semaphores when ignored
79  signal(signum, old);
80  else
81  oldHandlers[signum] = (old == SIG_ERR ? SIG_DFL : old);
82  }
83 }
QHash< int, qt_sighandler_t > oldHandlers
void(* qt_sighandler_t)(int)
static void handleSignal(int signal)

Functions

◆ addLock()

void QWSSignalHandler::addLock ( QLock lock)
inline

Definition at line 81 of file qwssignalhandler_p.h.

Referenced by QLock::QLock().

81 { locks.append(lock); }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QLock * > locks

◆ addObject()

void QWSSignalHandler::addObject ( QObject object)
inline

Definition at line 86 of file qwssignalhandler_p.h.

Referenced by QAhiScreenPrivate::QAhiScreenPrivate(), QDirectFBScreenPrivate::QDirectFBScreenPrivate(), QLinuxFbScreenPrivate::QLinuxFbScreenPrivate(), QVNCScreenPrivate::QVNCScreenPrivate(), and QWSTtyKbPrivate::QWSTtyKbPrivate().

86 { (void)objects.add(object); }
QObject * add(QObject *object)
Adds object to this cleanup handler and returns the pointer to the object.
QObjectCleanupHandler objects

◆ addWSLock()

void QWSSignalHandler::addWSLock ( QWSLock wslock)
inline

Definition at line 83 of file qwssignalhandler_p.h.

Referenced by QWSLock::QWSLock().

83 { wslocks.append(wslock); }
QList< QWSLock * > wslocks
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507

◆ clear()

void QWSSignalHandler::clear ( )
private

Definition at line 90 of file qwssignalhandler.cpp.

Referenced by handleSignal(), and ~QWSSignalHandler().

91 {
92 #if !defined(QT_NO_QWS_MULTIPROCESS)
93  // it is safe to call d-tors directly here since, on normal exit,
94  // lists should be empty; otherwise, we don't care about semi-alive objects
95  // and the only important thing here is to unregister the system semaphores.
96  while (!locks.isEmpty())
97  locks.takeLast()->~QLock();
98  while (!wslocks.isEmpty())
100 #endif
101  objects.clear();
102 }
~QWSLock()
Definition: qwslock.cpp:129
QList< QWSLock * > wslocks
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< QLock * > locks
QObjectCleanupHandler objects
T takeLast()
Removes the last item in the list and returns it.
Definition: qlist.h:492
~QLock()
Destroys a lock.
Definition: qlock.cpp:221
void clear()
Deletes all objects in this cleanup handler.

◆ handleSignal()

void QWSSignalHandler::handleSignal ( int  signal)
staticprivate

Definition at line 104 of file qwssignalhandler.cpp.

Referenced by QWSSignalHandler().

105 {
106  QWSSignalHandler *h = instance();
107  if (h) {
108  signal(signum, h->oldHandlers[signum]);
109  h->clear();
110  }
111  raise(signum);
112 }
static QWSSignalHandler * instance()
QHash< int, qt_sighandler_t > oldHandlers

◆ instance()

QWSSignalHandler * QWSSignalHandler::instance ( )
static

◆ removeLock()

void QWSSignalHandler::removeLock ( QLock lock)
inline

Definition at line 82 of file qwssignalhandler_p.h.

Referenced by QLock::~QLock().

82 { locks.removeOne(lock); }
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
QList< QLock * > locks

◆ removeWSLock()

void QWSSignalHandler::removeWSLock ( QWSLock wslock)
inline

Definition at line 84 of file qwssignalhandler_p.h.

Referenced by QWSLock::~QWSLock().

84 { wslocks.removeOne(wslock); }
QList< QWSLock * > wslocks
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796

Friends and Related Functions

◆ QWSSignalHandlerPrivate

Definition at line 102 of file qwssignalhandler_p.h.

Properties

◆ locks

QList<QLock *> QWSSignalHandler::locks
private

Definition at line 97 of file qwssignalhandler_p.h.

Referenced by clear().

◆ objects

QObjectCleanupHandler QWSSignalHandler::objects
private

Definition at line 100 of file qwssignalhandler_p.h.

Referenced by clear().

◆ oldHandlers

QHash<int, qt_sighandler_t> QWSSignalHandler::oldHandlers
private

Definition at line 95 of file qwssignalhandler_p.h.

Referenced by handleSignal(), and QWSSignalHandler().

◆ wslocks

QList<QWSLock *> QWSSignalHandler::wslocks
private

Definition at line 98 of file qwssignalhandler_p.h.

Referenced by clear().


The documentation for this class was generated from the following files: