mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-05-24 10:22:26 -04:00
Exceptions caught in main() shown in message box.
'\' and '/' no longer allowed in --rig <rig-name> git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3932 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
50846fe90a
commit
2fa0ff273e
12
main.cpp
12
main.cpp
@ -11,6 +11,7 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#endif
|
#endif
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
@ -28,9 +29,9 @@ QString my_key;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
|
||||||
setlocale (LC_NUMERIC, "C"); // ensure number forms are in
|
setlocale (LC_NUMERIC, "C"); // ensure number forms are in
|
||||||
// consistent format, do this after
|
// consistent format, do this after
|
||||||
// instantiating QApplication so
|
// instantiating QApplication so
|
||||||
@ -49,6 +50,11 @@ int main(int argc, char *argv[])
|
|||||||
if ('-' != temp_name[0]
|
if ('-' != temp_name[0]
|
||||||
&& !temp_name.isEmpty ())
|
&& !temp_name.isEmpty ())
|
||||||
{
|
{
|
||||||
|
if (temp_name.contains (QRegularExpression {R"([\\/])"}))
|
||||||
|
{
|
||||||
|
throw std::runtime_error (QObject::tr ("Invalid rig name - \\ & / not allowed").toLocal8Bit ().data ());
|
||||||
|
}
|
||||||
|
|
||||||
a.setApplicationName (a.applicationName () + " - " + temp_name);
|
a.setApplicationName (a.applicationName () + " - " + temp_name);
|
||||||
}
|
}
|
||||||
multiple = true;
|
multiple = true;
|
||||||
@ -76,7 +82,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if(!mem_jt9.attach()) {
|
if(!mem_jt9.attach()) {
|
||||||
if (!mem_jt9.create(sizeof(jt9com_))) {
|
if (!mem_jt9.create(sizeof(jt9com_))) {
|
||||||
QMessageBox::critical( 0, "Error", "Unable to create shared memory segment.");
|
QMessageBox::critical (nullptr, "Error", "Unable to create shared memory segment.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,10 +117,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
catch (std::exception const& e)
|
catch (std::exception const& e)
|
||||||
{
|
{
|
||||||
|
QMessageBox::critical (nullptr, QObject::tr ("Error"), e.what ());
|
||||||
std::cerr << "Error: " << e.what () << '\n';
|
std::cerr << "Error: " << e.what () << '\n';
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
QMessageBox::critical (nullptr, QObject::tr ("Unexpected"), QObject::tr ("Error"));
|
||||||
std::cerr << "Unexpected error\n";
|
std::cerr << "Unexpected error\n";
|
||||||
throw; // hoping the runtime might tell us more about the exception
|
throw; // hoping the runtime might tell us more about the exception
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user