diff options
author | Lubos Dolezel <lubos@dolezel.info> | 2015-06-04 22:18:12 +0200 |
---|---|---|
committer | Lubos Dolezel <lubos@dolezel.info> | 2015-06-04 22:18:12 +0200 |
commit | bcbbdf0b79d52c5ef40d11615954de35eda184e3 (patch) | |
tree | 05283199f05ff204a26b9b6138fe0907cebd5db3 /src/gui/main.cpp | |
parent | 85a753d68eb8900ba94ce89f9638269858645e19 (diff) | |
download | twinkle-bcbbdf0b79d52c5ef40d11615954de35eda184e3.tar twinkle-bcbbdf0b79d52c5ef40d11615954de35eda184e3.tar.gz twinkle-bcbbdf0b79d52c5ef40d11615954de35eda184e3.tar.lz twinkle-bcbbdf0b79d52c5ef40d11615954de35eda184e3.tar.xz twinkle-bcbbdf0b79d52c5ef40d11615954de35eda184e3.zip |
Qt 5 now supported
Diffstat (limited to 'src/gui/main.cpp')
-rw-r--r-- | src/gui/main.cpp | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/src/gui/main.cpp b/src/gui/main.cpp index a43c9bb..ff8ec00 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -17,6 +17,7 @@ */ #include "twinkle_config.h" +#include <QtDebug> #ifdef HAVE_KDE #include <kapplication.h> @@ -25,7 +26,6 @@ #include <qapplication.h> #include <qtranslator.h> -#include <qmime.h> #include <qtextcodec.h> #include "mphoneform.h" @@ -507,8 +507,10 @@ QApplication *create_user_interface(bool cli_mode, int argc, char **argv, QTrans qa = new t_twinkle_application(tmp, argv); MEMMAN_NEW(qa); #endif +#if QT_VERSION < 0x050000 // In Qt5, these functions are removed. UTF-8 is the default. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8")); +#endif // Install Qt translator // Do not report to memman as the translator will be deleted @@ -533,6 +535,37 @@ QApplication *create_user_interface(bool cli_mode, int argc, char **argv, QTrans return qa; } +void blockSignals() +{ + // Dedicated thread will catch SIGALRM, SIGINT, SIGTERM, SIGCHLD signals, + // therefore all threads must block these signals. Block now, then all + // created threads will inherit the signal mask. + // In LinuxThreads the sigwait does not work very well, so + // in LinuxThreads a signal handler is used instead. + + if (!threading_is_LinuxThreads) { + sigset_t sigset; + sigemptyset(&sigset); + sigaddset(&sigset, SIGALRM); + sigaddset(&sigset, SIGINT); + sigaddset(&sigset, SIGTERM); + sigaddset(&sigset, SIGCHLD); + sigprocmask(SIG_BLOCK, &sigset, NULL); + } else { + if (!phone->set_sighandler()) { + string msg = "Failed to register signal handler."; + log_file->write_report(msg, "::main", LOG_NORMAL, LOG_CRITICAL); + ui->cb_show_msg(msg, MSG_CRITICAL); + sys_config->delete_lock_file(); + exit(1); + } + } + + // Ignore SIGPIPE so read from broken sockets will not cause + // the process to terminate. + (void)signal(SIGPIPE, SIG_IGN); +} + int main( int argc, char ** argv ) { string error_msg; @@ -546,6 +579,8 @@ int main( int argc, char ** argv ) // Determine threading implementation threading_is_LinuxThreads = t_thread::is_LinuxThreads(); + blockSignals(); + QApplication *qa = NULL; QTranslator *qtranslator = NULL; @@ -913,33 +948,6 @@ int main( int argc, char ** argv ) log_msg += "\n"; log_file->write_report(log_msg, "::main", LOG_NORMAL, LOG_WARNING); } - - // Dedicated thread will catch SIGALRM, SIGINT, SIGTERM, SIGCHLD signals, - // therefore all threads must block these signals. Block now, then all - // created threads will inherit the signal mask. - // In LinuxThreads the sigwait does not work very well, so - // in LinuxThreads a signal handler is used instead. - if (!threading_is_LinuxThreads) { - sigset_t sigset; - sigemptyset(&sigset); - sigaddset(&sigset, SIGALRM); - sigaddset(&sigset, SIGINT); - sigaddset(&sigset, SIGTERM); - sigaddset(&sigset, SIGCHLD); - sigprocmask(SIG_BLOCK, &sigset, NULL); - } else { - if (!phone->set_sighandler()) { - string msg = "Failed to register signal handler."; - log_file->write_report(msg, "::main", LOG_NORMAL, LOG_CRITICAL); - ui->cb_show_msg(msg, MSG_CRITICAL); - sys_config->delete_lock_file(); - exit(1); - } - } - - // Ignore SIGPIPE so read from broken sockets will not cause - // the process to terminate. - (void)signal(SIGPIPE, SIG_IGN); // Create threads t_thread *thr_sender; |