diff options
| author | Christoph Berg <myon@debian.org> | 2020-09-28 23:28:26 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-09-28 23:28:26 +0200 |
| commit | c345880e5818351aec994d60cfb9a42351a4a6bd (patch) | |
| tree | 82e554ce75a62e7cca37968ee6e8ce08972eef04 /main.cpp | |
| parent | d55aefc872a0b03ac40c44e8b7d635dc0fa19f4e (diff) | |
| parent | 7aa3c56b01768ba7d38fccedc17b30a4046b3fbb (diff) | |
Update upstream source from tag 'upstream/2.3.0_rc1+repack'
Update to upstream version '2.3.0~rc1+repack'
with Debian dir 278ece20e94e89020b1ea45fb83e61a2cecbb31e
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 56 |
1 files changed, 44 insertions, 12 deletions
@@ -82,12 +82,12 @@ namespace } catch (std::exception const& e) { - MessageBox::critical_message (nullptr, translate ("main", "Fatal error"), e.what ()); + MessageBox::critical_message (nullptr, "Fatal error", e.what ()); throw; } catch (...) { - MessageBox::critical_message (nullptr, translate ("main", "Unexpected fatal error")); + MessageBox::critical_message (nullptr, "Unexpected fatal error"); throw; } } @@ -97,7 +97,7 @@ namespace int main(int argc, char *argv[]) { // ### Add timestamps to all debug messages -// qSetMessagePattern ("[%{time yyyyMMdd HH:mm:ss.zzz t} %{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{message}"); + // qSetMessagePattern ("[%{time yyyyMMdd HH:mm:ss.zzz t} %{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{message}"); init_random_seed (); @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) // Multiple instances communicate with jt9 via this QSharedMemory mem_jt9; - ExceptionCatchingApplication a(argc, argv); + QApplication a(argc, argv); try { // qDebug () << "+++++++++++++++++++++++++++ Resources ++++++++++++++++++++++++++++"; @@ -323,6 +323,7 @@ int main(int argc, char *argv[]) db.exec ("PRAGMA locking_mode=EXCLUSIVE"); int result; + auto const& original_style_sheet = a.styleSheet (); do { #if WSJT_QDEBUG_TO_FILE @@ -352,14 +353,42 @@ int main(int argc, char *argv[]) // Multiple instances: use rig_name as shared memory key mem_jt9.setKey(a.applicationName ()); - if(!mem_jt9.attach()) { - if (!mem_jt9.create(sizeof(struct dec_data))) { + // try and shut down any orphaned jt9 process + for (int i = 3; i; --i) // three tries to close old jt9 + { + if (mem_jt9.attach ()) // shared memory presence implies + // orphaned jt9 sub-process + { + dec_data_t * dd = reinterpret_cast<dec_data_t *> (mem_jt9.data()); + mem_jt9.lock (); + dd->ipc[1] = 999; // tell jt9 to shut down + mem_jt9.unlock (); + mem_jt9.detach (); // start again + } + else + { + break; // good to go + } + QThread::sleep (1); // wait for jt9 to end + } + if (!mem_jt9.attach ()) + { + if (!mem_jt9.create (sizeof (dec_data))) + { + splash.hide (); + MessageBox::critical_message (nullptr, a.translate ("main", "Shared memory error"), + a.translate ("main", "Unable to create shared memory segment")); + throw std::runtime_error {"Shared memory error"}; + } + qDebug () << "shmem size:" << mem_jt9.size (); + } + else + { splash.hide (); - MessageBox::critical_message (nullptr, a.translate ("main", "Shared memory error"), - a.translate ("main", "Unable to create shared memory segment")); - throw std::runtime_error {"Shared memory error"}; + MessageBox::critical_message (nullptr, a.translate ("main", "Sub-process error"), + a.translate ("main", "Failed to close orphaned jt9 process")); + throw std::runtime_error {"Sub-process error"}; } - } mem_jt9.lock (); memset(mem_jt9.data(),0,sizeof(struct dec_data)); //Zero all decoding params in shared memory mem_jt9.unlock (); @@ -387,6 +416,9 @@ int main(int argc, char *argv[]) splash.raise (); QObject::connect (&a, SIGNAL (lastWindowClosed()), &a, SLOT (quit())); result = a.exec(); + + // ensure config switches start with the right style sheet + a.setStyleSheet (original_style_sheet); } while (!result && !multi_settings.exit ()); @@ -407,12 +439,12 @@ int main(int argc, char *argv[]) } catch (std::exception const& e) { - MessageBox::critical_message (nullptr, QApplication::translate ("main", "Fatal error"), e.what ()); + MessageBox::critical_message (nullptr, "Fatal error", e.what ()); std::cerr << "Error: " << e.what () << '\n'; } catch (...) { - MessageBox::critical_message (nullptr, QApplication::translate ("main", "Unexpected fatal error")); + MessageBox::critical_message (nullptr, "Unexpected fatal error"); std::cerr << "Unexpected fatal error\n"; throw; // hoping the runtime might tell us more about the exception } |
