GIMP RawTherapee plugin cannot find executable in Windows, fixes #4514

This commit is contained in:
heckflosse 2018-04-30 14:16:00 +02:00
parent 5a9137777b
commit 483c0ae3e5
2 changed files with 43 additions and 150 deletions

View File

@ -206,75 +206,6 @@ int main (int argc, char **argv)
g_rename (Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ()); g_rename (Glib::build_filename (options.rtdir, "cache").c_str (), options.cacheBaseDir.c_str ());
} }
#endif
#ifdef WIN32
bool consoleOpened = false;
// suppression of annoying error boxes
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
if (argc > 1 || options.rtSettings.verbose) {
Glib::ustring fname (fname_to_utf8 (argv[1]));
#if ECLIPSE_ARGS
fname = fname.substr (1, fname.length() - 2);
#endif
if (options.rtSettings.verbose || ( !Glib::file_test (fname, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (fname, Glib::FILE_TEST_IS_DIR))) {
bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001);
bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001);
// no console, if stdout and stderr both are redirected to file
if ( ! (stdoutRedirectedtoFile && stderrRedirectedtoFile)) {
// check if parameter -w was passed.
// We have to do that in this step, because it controls whether to open a console to show the output of following steps
bool Console = true;
for (int i = 1; i < argc; i++)
if (!strcmp (argv[i], "-w")) {
Console = false;
break;
}
if (Console && AllocConsole()) {
AttachConsole ( GetCurrentProcessId() ) ;
// Don't allow CTRL-C in console to terminate RT
SetConsoleCtrlHandler ( NULL, true );
// Set title of console
char consoletitle[128];
sprintf (consoletitle, "RawTherapee %s Console", RTVERSION);
SetConsoleTitle (consoletitle);
// increase size of screen buffer
COORD c;
c.X = 200;
c.Y = 1000;
SetConsoleScreenBufferSize ( GetStdHandle ( STD_OUTPUT_HANDLE ), c );
// Disable console-Cursor
CONSOLE_CURSOR_INFO cursorInfo;
cursorInfo.dwSize = 100;
cursorInfo.bVisible = false;
SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo );
if (!stdoutRedirectedtoFile) {
freopen ( "CON", "w", stdout ) ;
}
if (!stderrRedirectedtoFile) {
freopen ( "CON", "w", stderr ) ;
}
freopen ( "CON", "r", stdin ) ;
consoleOpened = true;
// printing RT's version in every case, particularly useful for the 'verbose' mode, but also for the batch processing
std::cout << "RawTherapee, version " << RTVERSION << ", command line" << std::endl;
std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
}
}
}
}
#endif #endif
int ret = 0; int ret = 0;
@ -288,16 +219,6 @@ int main (int argc, char **argv)
std::cout << "Terminating without anything to do." << std::endl; std::cout << "Terminating without anything to do." << std::endl;
} }
#ifdef WIN32
if (consoleOpened) {
printf ("Press any key to exit RawTherapee\n");
FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE));
getch();
}
#endif
return ret; return ret;
} }
@ -575,11 +496,6 @@ int processLineParams ( int argc, char **argv )
} }
break; break;
#ifdef WIN32
case 'w': // This case is handled outside this function
break;
#endif
case 'h': case 'h':
case '?': case '?':
@ -602,10 +518,6 @@ int processLineParams ( int argc, char **argv )
std::cout << " " << Glib::path_get_basename (argv[0]) << " -c <dir>|<files> Convert files in batch with default parameters." << std::endl; std::cout << " " << Glib::path_get_basename (argv[0]) << " -c <dir>|<files> Convert files in batch with default parameters." << std::endl;
std::cout << " " << Glib::path_get_basename (argv[0]) << " <other options> -c <dir>|<files> Convert files in batch with your own settings." << std::endl; std::cout << " " << Glib::path_get_basename (argv[0]) << " <other options> -c <dir>|<files> Convert files in batch with your own settings." << std::endl;
std::cout << std::endl; std::cout << std::endl;
#ifdef WIN32
std::cout << " -w Do not open the Windows console" << std::endl;
std::cout << std::endl;
#endif
std::cout << "Options:" << std::endl; std::cout << "Options:" << std::endl;
std::cout << " " << Glib::path_get_basename (argv[0]) << "[-o <output>|-O <output>] [-q] [-a] [-s|-S] [-p <one.pp3> [-p <two.pp3> ...] ] [-d] [ -j[1-100] [-js<1-3>] | [-b<8|16>] [-t[z] | [-n]] ] [-Y] [-f] -c <input>" << std::endl; std::cout << " " << Glib::path_get_basename (argv[0]) << "[-o <output>|-O <output>] [-q] [-a] [-s|-S] [-p <one.pp3> [-p <two.pp3> ...] ] [-d] [ -j[1-100] [-js<1-3>] | [-b<8|16>] [-t[z] | [-n]] ] [-Y] [-f] -c <input>" << std::endl;
std::cout << std::endl; std::cout << std::endl;

View File

@ -121,6 +121,7 @@ static void myGdkLockLeave()
* -3 if at least one required procparam file was not found */ * -3 if at least one required procparam file was not found */
int processLineParams ( int argc, char **argv ) int processLineParams ( int argc, char **argv )
{ {
int ret = 1;
for ( int iArg = 1; iArg < argc; iArg++) { for ( int iArg = 1; iArg < argc; iArg++) {
Glib::ustring currParam (argv[iArg]); Glib::ustring currParam (argv[iArg]);
if ( currParam.empty() ) { if ( currParam.empty() ) {
@ -139,8 +140,9 @@ int processLineParams ( int argc, char **argv )
#endif #endif
case 'v': case 'v':
std::cout << "Using lensfun " << LF_VERSION_MAJOR << "." << LF_VERSION_MINOR << "." << LF_VERSION_MICRO << "." << LF_VERSION_BUGFIX << std::endl; printf("RawTherapee, version %s\n", RTVERSION);
return 0; ret = 0;
break;
#ifndef __APPLE__ // TODO agriggio - there seems to be already some "single instance app" support for OSX in rtwindow. Disabling it here until I understand how to merge the two #ifndef __APPLE__ // TODO agriggio - there seems to be already some "single instance app" support for OSX in rtwindow. Disabling it here until I understand how to merge the two
@ -165,34 +167,29 @@ int processLineParams ( int argc, char **argv )
case 'h': case 'h':
case '?': case '?':
default: { default: {
Glib::ustring pparamsExt = paramFileExtension.substr (1); printf(" An advanced, cross-platform program for developing raw photos.\n\n");
std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl; printf(" Website: http://www.rawtherapee.com/\n");
printf(" Documentation: http://rawpedia.rawtherapee.com/\n");
printf(" Forum: https://discuss.pixls.us/c/software/rawtherapee\n");
printf(" Code and bug reports: https://github.com/Beep6581/RawTherapee\n\n");
printf("Symbols:\n");
printf(" <Chevrons> indicate parameters you can change.\n\n");
printf("Usage:\n");
printf(" %s <folder> Start File Browser inside folder.\n",Glib::path_get_basename (argv[0]).c_str());
printf(" %s <file> Start Image Editor with file.\n\n",Glib::path_get_basename (argv[0]).c_str());
std::cout << std::endl; std::cout << std::endl;
std::cout << " Website: http://www.rawtherapee.com/" << std::endl; printf("Options:\n");
std::cout << " Documentation: http://rawpedia.rawtherapee.com/" << std::endl;
std::cout << " Forum: https://discuss.pixls.us/c/software/rawtherapee" << std::endl;
std::cout << " Code and bug reports: https://github.com/Beep6581/RawTherapee" << std::endl;
std::cout << std::endl;
std::cout << "Symbols:" << std::endl;
std::cout << " <Chevrons> indicate parameters you can change." << std::endl;
//std::cout << " [Square brackets] mean the parameter is optional." << std::endl;
//std::cout << " The pipe symbol | indicates a choice of one or the other." << std::endl;
//std::cout << " The dash symbol - denotes a range of possible values from one to the other." << std::endl;
std::cout << std::endl;
std::cout << "Usage:" << std::endl;
std::cout << " " << Glib::path_get_basename (argv[0]) << " <folder> Start File Browser inside folder." << std::endl;
std::cout << " " << Glib::path_get_basename (argv[0]) << " <file> Start Image Editor with file." << std::endl;
std::cout << std::endl;
std::cout << "Options:" << std::endl;
#ifdef WIN32 #ifdef WIN32
std::cout << " -w Do not open the Windows console" << std::endl; printf(" -w Do not open the Windows console\n");
#endif #endif
std::cout << " -v Print RawTherapee version number and exit" << std::endl; printf(" -v Print RawTherapee version number and exit\n");
#ifndef __APPLE__ #ifndef __APPLE__
std::cout << " -R Raise an already running RawTherapee instance (if available)" << std::endl; printf(" -R Raise an already running RawTherapee instance (if available)\n");
#endif #endif
std::cout << " -h -? Display this help message" << std::endl; printf(" -h -? Display this help message\n");
return -1;
ret = -1;
break;
} }
} }
} else { } else {
@ -212,7 +209,7 @@ int processLineParams ( int argc, char **argv )
} }
} }
return 1; return ret;
} }
@ -517,6 +514,14 @@ int main (int argc, char **argv)
options.rtSettings.lensfunDbDirectory = LENSFUN_DB_PATH; options.rtSettings.lensfunDbDirectory = LENSFUN_DB_PATH;
#endif #endif
Glib::ustring fatalError;
try {
Options::load();
} catch (Options::Error &e) {
fatalError = e.get_msg();
}
#ifdef WIN32 #ifdef WIN32
bool consoleOpened = false; bool consoleOpened = false;
@ -525,14 +530,10 @@ int main (int argc, char **argv)
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
if (argc > 1) { if (argc > 1) {
int ret = processLineParams ( argc, argv); if (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR)) {
bool stdoutRedirecttoConsole = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0000);
if (options.rtSettings.verbose || (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, Glib::FILE_TEST_IS_DIR))) { // open console, if stdout is invalid
bool stdoutRedirectedtoFile = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0001); if (stdoutRedirecttoConsole) {
bool stderrRedirectedtoFile = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0001);
// no console, if stdout and stderr both are redirected to file
if ( ! (stdoutRedirectedtoFile && stderrRedirectedtoFile)) {
// check if parameter -w was passed. // check if parameter -w was passed.
// We have to do that in this step, because it controls whether to open a console to show the output of following steps // We have to do that in this step, because it controls whether to open a console to show the output of following steps
bool Console = true; bool Console = true;
@ -562,26 +563,21 @@ int main (int argc, char **argv)
cursorInfo.bVisible = false; cursorInfo.bVisible = false;
SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo ); SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo );
if (!stdoutRedirectedtoFile) { if (stdoutRedirecttoConsole) { // if stdout is Redirect to console, we also redirect stderr to console
freopen ( "CON", "w", stdout ) ; freopen ( "CON", "w", stdout ) ;
}
if (!stderrRedirectedtoFile) {
freopen ( "CON", "w", stderr ) ; freopen ( "CON", "w", stderr ) ;
} }
freopen ( "CON", "r", stdin ) ; freopen ( "CON", "r", stdin ) ;
consoleOpened = true; consoleOpened = true;
// printing RT's version in every case, particularly useful for the 'verbose' mode, but also for the batch processing
std::cout << "RawTherapee, version " << RTVERSION << std::endl;
std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
} }
} }
} }
int ret = processLineParams ( argc, argv);
if ( ret <= 0 ) { if ( ret <= 0 ) {
fflush(stdout);
if (consoleOpened) { if (consoleOpened) {
printf ("Press any key to exit RawTherapee\n"); printf ("Press any key to exit RawTherapee\n");
FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE));
@ -594,19 +590,11 @@ int main (int argc, char **argv)
#else #else
if (argc > 1 || options.rtSettings.verbose) { if (argc > 1) {
// printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing int ret = processLineParams ( argc, argv);
std::cout << "RawTherapee, version " << RTVERSION << std::endl;
#ifdef WIN32
std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
#endif
if (argc > 1) { if ( ret <= 0 ) {
int ret = processLineParams ( argc, argv); return ret;
if ( ret <= 0 ) {
return ret;
}
} }
} }
@ -628,14 +616,6 @@ int main (int argc, char **argv)
int ret = 0; int ret = 0;
Glib::ustring fatalError;
try {
Options::load();
} catch (Options::Error &e) {
fatalError = e.get_msg();
}
gdk_threads_set_lock_functions (G_CALLBACK (myGdkLockEnter), (G_CALLBACK (myGdkLockLeave))); gdk_threads_set_lock_functions (G_CALLBACK (myGdkLockEnter), (G_CALLBACK (myGdkLockLeave)));
gdk_threads_init(); gdk_threads_init();
gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal
@ -681,6 +661,7 @@ int main (int argc, char **argv)
if (consoleOpened) { if (consoleOpened) {
printf ("Press any key to exit RawTherapee\n"); printf ("Press any key to exit RawTherapee\n");
fflush(stdout);
FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE)); FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE));
getch(); getch();
} }