Bug http://www.lyx.org/trac/ticket/10440
in at least on Windows a major issue.

5 months ago the user "backbone" presented a patch that fixes the bug for me (see attached). I don't understand what is wrong wit this patch and all further patches do not work.

Therefore the patch should go in if it doesn't have effects for other OSes. The aim of this discussion to fix the bug soon (if possible even for LyX 2.2.3).

regards Uwe
diff --git 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\LyX-d568846.000.cpp" 
"b/D:\\LyXGit\\Master\\src\\LyX.cpp"
index 12bdbe6666..4075db6b55 100644
--- "a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\LyX-d568846.000.cpp"
+++ "b/D:\\LyXGit\\Master\\src\\LyX.cpp"
@@ -315,9 +315,13 @@ int LyX::exec(int & argc, char * argv[])
                LYXERR(Debug::LOCALE, message.title_ + ", " + message.details_);
        }
 
+       // Bug #10440: argv modification leads to runtime error with msvc 2015, 
so copy them
+       char ** argv_local = new char * [argc + 1];
+       memcpy (argv_local, argv, (argc + 1) * sizeof (char *));
+
        // Here we need to parse the command line. At least
        // we need to parse for "-dbg" and "-help"
-       easyParse(argc, argv);
+       easyParse(argc, argv_local);
 
 #if QT_VERSION >= 0x050600
        // Check whether Qt will scale all GUI elements and accordingly
@@ -346,7 +350,7 @@ int LyX::exec(int & argc, char * argv[])
        setLocale();
 
        if (!use_gui) {
-               LyXConsoleApp app(this, argc, argv);
+               LyXConsoleApp app(this, argc, argv_local);
 
                // Reestablish our defaults, as Qt overwrites them
                // after creating app
@@ -356,7 +360,7 @@ int LyX::exec(int & argc, char * argv[])
        }
 
        // Let the frontend parse and remove all arguments that it knows
-       pimpl_->application_.reset(createApplication(argc, argv));
+       pimpl_->application_.reset(createApplication(argc, argv_local));
 
        // Reestablish our defaults, as Qt overwrites them
        // after createApplication()
@@ -364,7 +368,8 @@ int LyX::exec(int & argc, char * argv[])
 
        // Parse and remove all known arguments in the LyX singleton
        // Give an error for all remaining ones.
-       int exit_status = init(argc, argv);
+       int exit_status = init(argc, argv_local);
+       delete [] argv_local;
        if (exit_status) {
                // Kill the application object before exiting.
                pimpl_->application_.reset();

Reply via email to