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