[glom] Catch unknown command-line options.



commit 1c586304524624b2eebbb6a6ed2883ffb1a16bfd
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jul 24 02:16:19 2009 +0200

    Catch unknown command-line options.
    
    	* glom/main.cc: Put try/catch around the Gtk::Main instantiation
    	because I noticed that it throws an exception if you provide an
    	unknown option.

 ChangeLog    |    8 ++++++++
 glom/main.cc |   12 +++++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9e2c130..3ad172c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-07-24  Murray Cumming  <murrayc murrayc com>
 
+	Catch unknown command-line options.
+
+	* glom/main.cc: Put try/catch around the Gtk::Main instantiation 
+	because I noticed that it throws an exception if you provide an 
+	unknown option.
+
+2009-07-24  Murray Cumming  <murrayc murrayc com>
+
 	Use CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE.
 
 	* glom/libglom/connectionpool_backends/postgres.cc:
diff --git a/glom/main.cc b/glom/main.cc
index 384a965..1773972 100644
--- a/glom/main.cc
+++ b/glom/main.cc
@@ -324,7 +324,17 @@ main(int argc, char* argv[])
   //We use python for calculated-fields:
   Py_Initialize();
   PySys_SetArgv(argc, argv);
-  Gtk::Main mainInstance(argc, argv, context);
+
+  std::auto_ptr<Gtk::Main> mainInstance;
+  try
+  {
+    mainInstance = std::auto_ptr<Gtk::Main>( new Gtk::Main(argc, argv, context) );
+  }
+  catch(const Glib::Error& ex)
+  {
+    std::cerr << "Glom: Error while initializing gtkmm: " << ex.what() << std::endl;
+    return 0;
+  }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   try



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]