diff --git a/src/klayout_main/klayout_main/klayout.cc b/src/klayout_main/klayout_main/klayout.cc index 8091c7196..8d2fec11d 100644 --- a/src/klayout_main/klayout_main/klayout.cc +++ b/src/klayout_main/klayout_main/klayout.cc @@ -202,20 +202,6 @@ static int klayout_main_cont (int &argc, char **argv); */ int klayout_main (int &argc, char **argv) -{ - // This special initialization is required by the Ruby interpreter because it wants to mark the stack - int ret = rba::RubyInterpreter::initialize (argc, argv, &klayout_main_cont); - - // clean up all static data now, since we don't trust the static destructors. - // NOTE: this needs to happen after the Ruby interpreter went down since otherwise the GC will - // access objects that are already cleaned up. - tl::StaticObjects::cleanup (); - - return ret; -} - -int -klayout_main_cont (int &argc, char **argv) { // install the version strings lay::Version::set_exe_name (prg_exe_name); @@ -237,6 +223,37 @@ klayout_main_cont (int &argc, char **argv) about_text += prg_about_text; lay::Version::set_about_text (about_text.c_str ()); + // Capture the shortcut command line arguments + for (int i = 1; i < argc; ++i) { + + if (argv [i] == std::string ("-v")) { + + tl::info << lay::ApplicationBase::version (); + return 0; + + } else if (argv [i] == std::string ("-h")) { + + tl::info << lay::ApplicationBase::usage () << tl::noendl; + return 0; + + } + + } + + // This special initialization is required by the Ruby interpreter because it wants to mark the stack + int ret = rba::RubyInterpreter::initialize (argc, argv, &klayout_main_cont); + + // clean up all static data now, since we don't trust the static destructors. + // NOTE: this needs to happen after the Ruby interpreter went down since otherwise the GC will + // access objects that are already cleaned up. + tl::StaticObjects::cleanup (); + + return ret; +} + +int +klayout_main_cont (int &argc, char **argv) +{ #if QT_VERSION >= 0x050000 qInstallMessageHandler (myMessageOutput); #else diff --git a/src/lay/lay/gsiDeclLayApplication.cc b/src/lay/lay/gsiDeclLayApplication.cc index f499f921e..a578881dd 100644 --- a/src/lay/lay/gsiDeclLayApplication.cc +++ b/src/lay/lay/gsiDeclLayApplication.cc @@ -81,6 +81,12 @@ static std::string arch (C *) return tl::arch_string (); } +template +static std::string version (C *) +{ + return C::version (); +} + template static gsi::Methods application_methods () { @@ -213,7 +219,7 @@ static gsi::Methods application_methods () "\n" "This method has been added in version 0.22." ) + - method ("version", &C::version, + method_ext ("version", &version, "@brief Returns the application's version string\n" ) + method_ext ("arch", &arch, diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 21bc51c24..76a9000cd 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -483,16 +483,6 @@ ApplicationBase::parse_cmd (int &argc, char **argv) m_packages_with_dep = true; - } else if (a == "-v") { - - tl::info << lay::Version::name () << " " << lay::Version::version (); - exit (0); - - } else if (a == "-h") { - - tl::info << usage () << tl::noendl; - exit (0); - } else if (a == "-m" && (i + 1) < argc) { m_files.push_back (std::make_pair (rdb_file, std::make_pair (std::string (args [++i]), std::string ()))); @@ -929,7 +919,7 @@ ApplicationBase::instance () } std::string -ApplicationBase::version () const +ApplicationBase::version () { return std::string (lay::Version::name ()) + " " + lay::Version::version (); } diff --git a/src/lay/lay/layApplication.h b/src/lay/lay/layApplication.h index 6aedf8d41..0e28ae394 100644 --- a/src/lay/lay/layApplication.h +++ b/src/lay/lay/layApplication.h @@ -100,12 +100,12 @@ public: /** * @brief Return the program's version */ - std::string version () const; + static std::string version (); /** * @brief Return the program's usage string */ - std::string usage (); + static std::string usage (); /** * @brief Returns the main window's reference diff --git a/src/lay/lay/layHelpSource.cc b/src/lay/lay/layHelpSource.cc index 4b6f236f1..1460084d0 100644 --- a/src/lay/lay/layHelpSource.cc +++ b/src/lay/lay/layHelpSource.cc @@ -283,7 +283,7 @@ HelpSource::initialize_index () try { tl::XMLFileSource in (*c); help_index_structure.parse (in, *this); - if (m_klayout_version == lay::ApplicationBase::instance ()->version ()) { + if (m_klayout_version == lay::ApplicationBase::version ()) { ok = true; } } catch (tl::Exception &ex) { @@ -352,7 +352,7 @@ HelpSource::create_index_file (const std::string &path) std::string HelpSource::klayout_version () const { - return lay::ApplicationBase::instance ()->version (); + return lay::ApplicationBase::version (); } void diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 41cf82007..9a33b027f 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -3543,9 +3543,9 @@ MainWindow::update_window_title () if (current_view ()->is_dirty ()) { sep += "[+] "; } - setWindowTitle (tl::to_qstring (lay::ApplicationBase::instance ()->version () + sep + current_view ()->title ())); + setWindowTitle (tl::to_qstring (lay::ApplicationBase::version () + sep + current_view ()->title ())); } else { - setWindowTitle (tl::to_qstring (lay::ApplicationBase::instance ()->version ())); + setWindowTitle (tl::to_qstring (lay::ApplicationBase::version ())); } }