Uncaught exception fix

This commit is contained in:
Markus Gans 2017-09-20 06:19:27 +02:00
parent a6c30bb2b5
commit 4eef45b8f0
3 changed files with 62 additions and 29 deletions

View File

@ -1,3 +1,3 @@
PROJECT_NAME = "The Final Cut" PROJECT_NAME = "The Final Cut"
EXCLUDE = debian, icon, logo, m4, scripts, test EXCLUDE = debian, icon, logo, m4, scripts, examples

View File

@ -88,19 +88,52 @@ int main (int, char**)
std::cout << " stream in: " << streamer9 << std::endl; std::cout << " stream in: " << streamer9 << std::endl;
// ...from long double // ...from long double
try
{
FString streamer10; FString streamer10;
streamer10 << lDouble(0.333333333333333333L); streamer10 << lDouble(0.333333333333333333L);
std::cout << " stream in: " << streamer10 << std::endl; std::cout << " stream in: " << streamer10 << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// ...from double // ...from double
try
{
FString streamer11; FString streamer11;
streamer11 << double(0.11111111111); streamer11 << double(0.11111111111);
std::cout << " stream in: " << streamer11 << std::endl; std::cout << " stream in: " << streamer11 << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// ...from float // ...from float
try
{
FString streamer12; FString streamer12;
streamer12 << float(0.22222222); streamer12 << float(0.22222222);
std::cout << " stream in: " << streamer12 << std::endl; std::cout << " stream in: " << streamer12 << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// Test: Streaming from a FString (operator >>)... // Test: Streaming from a FString (operator >>)...

View File

@ -9,20 +9,20 @@
#include <final/fswitch.h> #include <final/fswitch.h>
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class watch // class Watch
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class watch : public FDialog class Watch : public FDialog
{ {
public: public:
// Constructor // Constructor
explicit watch (FWidget* = 0); explicit Watch (FWidget* = 0);
// Destructor // Destructor
~watch(); ~Watch();
// Method // Method
void printTime(); void printTime();
@ -42,10 +42,10 @@ class watch : public FDialog
private: private:
// Disable copy constructor // Disable copy constructor
watch (const watch&); Watch (const Watch&);
// Disable assignment operator (=) // Disable assignment operator (=)
watch& operator = (const watch&); Watch& operator = (const Watch&);
// Data Members // Data Members
bool sec; bool sec;
@ -57,7 +57,7 @@ class watch : public FDialog
#pragma pack(pop) #pragma pack(pop)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
watch::watch (FWidget* parent) Watch::Watch (FWidget* parent)
: FDialog(parent) : FDialog(parent)
, sec(true) , sec(true)
, time_label(0) , time_label(0)
@ -91,32 +91,32 @@ watch::watch (FWidget* parent)
clock_sw->addCallback clock_sw->addCallback
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &watch::cb_clock) F_METHOD_CALLBACK (this, &Watch::cb_clock)
); );
// Connect switch signal "toggled" with a callback member function // Connect switch signal "toggled" with a callback member function
seconds_sw->addCallback seconds_sw->addCallback
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &watch::cb_seconds) F_METHOD_CALLBACK (this, &Watch::cb_seconds)
); );
// Connect button signal "clicked" with a callback member function // Connect button signal "clicked" with a callback member function
quit_btn->addCallback quit_btn->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &watch::cb_exitApp) F_METHOD_CALLBACK (this, &Watch::cb_exitApp)
); );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
watch::~watch() Watch::~Watch()
{ {
delOwnTimer(); delOwnTimer();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void watch::printTime() void Watch::printTime()
{ {
FString str; FString str;
std::tm now; std::tm now;
@ -135,13 +135,13 @@ void watch::printTime()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void watch::onTimer (FTimerEvent*) void Watch::onTimer (FTimerEvent*)
{ {
printTime(); printTime();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void watch::onClose (FCloseEvent* ev) void Watch::onClose (FCloseEvent* ev)
{ {
int ret = FMessageBox::info ( this, "Quit" int ret = FMessageBox::info ( this, "Quit"
, "Do you really want\n" , "Do you really want\n"
@ -155,7 +155,7 @@ void watch::onClose (FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void watch::cb_clock (FWidget*, data_ptr) void Watch::cb_clock (FWidget*, data_ptr)
{ {
if ( clock_sw->isChecked() ) if ( clock_sw->isChecked() )
{ {
@ -171,7 +171,7 @@ void watch::cb_clock (FWidget*, data_ptr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void watch::cb_seconds (FWidget*, data_ptr) void Watch::cb_seconds (FWidget*, data_ptr)
{ {
if ( seconds_sw->isChecked() ) if ( seconds_sw->isChecked() )
sec = true; sec = true;
@ -192,13 +192,13 @@ void watch::cb_seconds (FWidget*, data_ptr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void watch::cb_exitApp (FWidget*, data_ptr) void Watch::cb_exitApp (FWidget*, data_ptr)
{ {
close(); close();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void watch::adjustSize() void Watch::adjustSize()
{ {
int pw = getParentWidget()->getWidth(); int pw = getParentWidget()->getWidth();
setX (1 + (pw - 22) / 2, false); setX (1 + (pw - 22) / 2, false);
@ -214,7 +214,7 @@ int main (int argc, char* argv[])
FApplication app(argc, argv); FApplication app(argc, argv);
// Create a simple dialog box // Create a simple dialog box
watch w(&app); Watch w(&app);
// Set dialog w as main widget // Set dialog w as main widget
app.setMainWidget(&w); app.setMainWidget(&w);