mirror of https://github.com/KLayout/klayout.git
Fixed #43 (crash when using Qt specific command line options)
This commit is contained in:
parent
4855231342
commit
b44f5ab156
|
|
@ -31,7 +31,7 @@ BD_PUBLIC int BD_TARGET (int argc, char *argv []);
|
|||
/**
|
||||
* @brief The continuation function to support Ruby's special top-level hook
|
||||
*/
|
||||
static int main_cont (int argc, char **argv)
|
||||
static int main_cont (int &argc, char **argv)
|
||||
{
|
||||
QCoreApplication app (argc, argv);
|
||||
return bd::_main_impl (&BD_TARGET, argc, argv);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
int klayout_main (int argc, char **argv);
|
||||
int klayout_main (int &argc, char **argv);
|
||||
|
||||
#ifdef _WIN32 // for VC++
|
||||
|
||||
|
|
@ -67,25 +67,25 @@ WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*prevInstance*/, LPSTR /*lpCmdLine*/
|
|||
|
||||
// fail safe behaviour
|
||||
if (!szArgList) {
|
||||
MessageBox(NULL, L"Unable to parse command line", L"Error", MB_OK);
|
||||
return 10;
|
||||
MessageBox(NULL, L"Unable to parse command line", L"Error", MB_OK);
|
||||
return 10;
|
||||
}
|
||||
|
||||
char **argv = new char *[argCount];
|
||||
for (int i = 0; i < argCount; i++) {
|
||||
QString a;
|
||||
for (WCHAR *wc = szArgList [i]; *wc; ++wc) {
|
||||
QString a;
|
||||
for (WCHAR *wc = szArgList [i]; *wc; ++wc) {
|
||||
a += QChar ((unsigned int) *wc);
|
||||
}
|
||||
QByteArray aa = a.toUtf8 ();
|
||||
argv [i] = new char [aa.size () + 1];
|
||||
strcpy (argv [i], aa.constData ());
|
||||
}
|
||||
QByteArray aa = a.toUtf8 ();
|
||||
argv [i] = new char [aa.size () + 1];
|
||||
strcpy (argv [i], aa.constData ());
|
||||
}
|
||||
|
||||
int ret = klayout_main (argCount, argv);
|
||||
|
||||
for (int i = 0; i < argCount; i++) {
|
||||
delete[] argv [i];
|
||||
delete[] argv [i];
|
||||
}
|
||||
delete[] argv;
|
||||
|
||||
|
|
@ -100,15 +100,15 @@ main(int a_argc, const char **a_argv)
|
|||
{
|
||||
char **argv = new char *[a_argc];
|
||||
for (int i = 0; i < a_argc; i++) {
|
||||
tl::string aa = tl::system_to_string (a_argv[i]);
|
||||
tl::string aa = tl::system_to_string (a_argv[i]);
|
||||
argv [i] = new char [aa.size () + 1];
|
||||
strcpy (argv [i], aa.c_str ());
|
||||
strcpy (argv [i], aa.c_str ());
|
||||
}
|
||||
|
||||
int ret = klayout_main (a_argc, argv);
|
||||
|
||||
for (int i = 0; i < a_argc; i++) {
|
||||
delete[] argv [i];
|
||||
delete[] argv [i];
|
||||
}
|
||||
delete[] argv;
|
||||
|
||||
|
|
@ -158,14 +158,14 @@ void myMessageOutput(QtMsgType type, const char *msg)
|
|||
}
|
||||
#endif
|
||||
|
||||
static int klayout_main_cont (int argc, char **argv);
|
||||
static int klayout_main_cont (int &argc, char **argv);
|
||||
|
||||
/**
|
||||
* @brief The basic entry point
|
||||
* Note that by definition, klayout_main receives arguments in UTF-8
|
||||
*/
|
||||
int
|
||||
klayout_main (int argc, char **argv)
|
||||
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);
|
||||
|
|
@ -179,7 +179,7 @@ klayout_main (int argc, char **argv)
|
|||
}
|
||||
|
||||
int
|
||||
klayout_main_cont (int argc, char **argv)
|
||||
klayout_main_cont (int &argc, char **argv)
|
||||
{
|
||||
// install the version strings
|
||||
lay::Version::set_exe_name (prg_exe_name);
|
||||
|
|
|
|||
|
|
@ -1751,16 +1751,16 @@ RubyInterpreter::version () const
|
|||
}
|
||||
}
|
||||
|
||||
static int s_argc = 0;
|
||||
static int *s_argc = 0;
|
||||
static char **s_argv = 0;
|
||||
static int (*s_main_func) (int, char **) = 0;
|
||||
static int (*s_main_func) (int &, char **) = 0;
|
||||
|
||||
static VALUE run_app_func (VALUE)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
if (s_main_func && s_argv && s_argc > 0) {
|
||||
res = (*s_main_func) (s_argc, s_argv);
|
||||
if (s_main_func && s_argv && s_argc && *s_argc > 0) {
|
||||
res = (*s_main_func) (*s_argc, s_argv);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
|
|
@ -1771,7 +1771,7 @@ static VALUE run_app_func (VALUE)
|
|||
}
|
||||
|
||||
int
|
||||
RubyInterpreter::initialize (int main_argc, char **main_argv, int (*main_func) (int, char **))
|
||||
RubyInterpreter::initialize (int &main_argc, char **main_argv, int (*main_func) (int &, char **))
|
||||
{
|
||||
int argc = 3;
|
||||
char *argv[3];
|
||||
|
|
@ -1861,7 +1861,7 @@ RubyInterpreter::initialize (int main_argc, char **main_argv, int (*main_func) (
|
|||
|
||||
rb_define_global_function("__run_app__", (VALUE (*)(...)) run_app_func, 0);
|
||||
|
||||
s_argc = main_argc;
|
||||
s_argc = &main_argc;
|
||||
s_argv = main_argv;
|
||||
s_main_func = main_func;
|
||||
|
||||
|
|
@ -1879,6 +1879,7 @@ RubyInterpreter::initialize (int main_argc, char **main_argv, int (*main_func) (
|
|||
int res = ruby_run_node (ruby_options (argc, argv));
|
||||
#endif
|
||||
|
||||
s_argc = 0;
|
||||
return res;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ public:
|
|||
* }
|
||||
* @endcode
|
||||
*/
|
||||
static int initialize (int argc, char **argv, int (*main_func) (int, char **));
|
||||
static int initialize (int &argc, char **argv, int (*main_func) (int &, char **));
|
||||
|
||||
/**
|
||||
* @brief The instance of the Ruby interpreter of 0 if there is none.
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ RubyInterpreter::available () const
|
|||
}
|
||||
|
||||
int
|
||||
RubyInterpreter::initialize (int argc, char **argv, int (*main_cont)(int, char **))
|
||||
RubyInterpreter::initialize (int &argc, char **argv, int (*main_cont)(int &, char **))
|
||||
{
|
||||
return (*main_cont) (argc, argv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ public:
|
|||
/**
|
||||
* @brief Provide a first (basic) initialization and continue with the "main_cont" function internally
|
||||
*/
|
||||
static int initialize (int argc, char **argv, int (*main_cont)(int, char **));
|
||||
static int initialize (int &argc, char **argv, int (*main_cont)(int &, char **));
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
#include "drcForceLink.h"
|
||||
#endif
|
||||
|
||||
static int main_cont (int argc, char **argv);
|
||||
static int main_cont (int &argc, char **argv);
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
|
@ -318,7 +318,7 @@ run_tests (const std::vector<tl::TestBase *> &selected_tests, bool editable, boo
|
|||
}
|
||||
|
||||
static int
|
||||
main_cont (int argc, char **argv)
|
||||
main_cont (int &argc, char **argv)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue