summaryrefslogtreecommitdiffstats
path: root/src/gui/embedded/qwssignalhandler.cpp
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2011-06-01 14:49:43 (GMT)
committerHarald Fernengel <harald.fernengel@nokia.com>2011-06-01 14:49:43 (GMT)
commit9f71cffea1d5cdac94ae7368ffa7f54183ac33a4 (patch)
tree6594f8e2f5d09d13b88de8fa95d40c069a9d1181 /src/gui/embedded/qwssignalhandler.cpp
parent6896244f266becfb5807985c5628c8f0a775ce76 (diff)
downloadQt-9f71cffea1d5cdac94ae7368ffa7f54183ac33a4.zip
Qt-9f71cffea1d5cdac94ae7368ffa7f54183ac33a4.tar.gz
Qt-9f71cffea1d5cdac94ae7368ffa7f54183ac33a4.tar.bz2
drop the SysV semaphores -specific code out from QWSSignalHandler
it is safe to call the QLock/QWSLock desctructors instead on normal exit where both lists should be empty; on crash, we don't care about semi-alive objects and the only important thing is to unregister the system semaphores. Merge-request: 1237 Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
Diffstat (limited to 'src/gui/embedded/qwssignalhandler.cpp')
-rw-r--r--src/gui/embedded/qwssignalhandler.cpp50
1 files changed, 19 insertions, 31 deletions
diff --git a/src/gui/embedded/qwssignalhandler.cpp b/src/gui/embedded/qwssignalhandler.cpp
index 2a20141..b13a57d 100644
--- a/src/gui/embedded/qwssignalhandler.cpp
+++ b/src/gui/embedded/qwssignalhandler.cpp
@@ -43,13 +43,10 @@
#ifndef QT_NO_QWS_SIGNALHANDLER
-#include <sys/types.h>
-#ifndef QT_NO_QWS_MULTIPROCESS
-# include <sys/ipc.h>
-# include <sys/sem.h>
+#include "qlock_p.h"
+#include "qwslock_p.h"
-# include <private/qcore_unix_p.h>
-#endif
+#include <sys/types.h>
#include <signal.h>
QT_BEGIN_NAMESPACE
@@ -87,39 +84,30 @@ QWSSignalHandler::QWSSignalHandler()
QWSSignalHandler::~QWSSignalHandler()
{
-#ifndef QT_NO_QWS_MULTIPROCESS
- while (!semaphores.isEmpty())
- removeSemaphore(semaphores.last());
-#endif
+ clear();
}
-#ifndef QT_NO_QWS_MULTIPROCESS
-void QWSSignalHandler::removeSemaphore(int semno)
+void QWSSignalHandler::clear()
{
- const int index = semaphores.lastIndexOf(semno);
- if (index != -1) {
- qt_semun semval;
- semval.val = 0;
- semctl(semaphores.at(index), 0, IPC_RMID, semval);
- semaphores.remove(index);
- }
+#if !defined(QT_NO_QWS_MULTIPROCESS)
+ // it is safe to call d-tors directly here since, on normal exit,
+ // lists should be empty; otherwise, we don't care about semi-alive objects
+ // and the only important thing here is to unregister the system semaphores.
+ while (!locks.isEmpty())
+ locks.takeLast()->~QLock();
+ while (!wslocks.isEmpty())
+ wslocks.takeLast()->~QWSLock();
+#endif
+ objects.clear();
}
-#endif // QT_NO_QWS_MULTIPROCESS
void QWSSignalHandler::handleSignal(int signum)
{
QWSSignalHandler *h = instance();
-
- signal(signum, h->oldHandlers[signum]);
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- qt_semun semval;
- semval.val = 0;
- for (int i = 0; i < h->semaphores.size(); ++i)
- semctl(h->semaphores.at(i), 0, IPC_RMID, semval);
-#endif
-
- h->objects.clear();
+ if (h) {
+ signal(signum, h->oldHandlers[signum]);
+ h->clear();
+ }
raise(signum);
}