Windows users report GIMP's RT plugin cannot find the RT executable. They also report dt works correctly, so maybe our plugin code needs to be synced with dt's.
https://bugzilla.gnome.org/show_bug.cgi?id=790740#c8
Ping @agriggio
Sorry I have no windows experience. This however seems pretty bad behaviour:
Against its promise in rawtherapee -help (" -v Print RawTherapee version number and exit"), RawTherapee does NOT exit and displays "Press any key to exit RawTherapee" in a console window when called like "rawtherapee -v". This blocks the GIMP startup process until a key is pressed.
Hopefully some regular windows user can help?
Without showing the "Press any key to exit..." stuff, the console window would be automatically closed after writing the version information or the help when rt is not started from console. Just add -w parameter.
ingo, thanks for the clarification! :+1:
this is some windows console madness I suppose, right? :-)
Without showing the "Press any key to exit..." stuff, the console window would be automatically closed after writing the version information or the help when rt is not started from console.
Isn't this exactly how it works for the linux version?
putting rawtherapee -v in a bash script and then executing it via the file manager (e.g. Nautilus) causes the terminal window to pop up and then close itself immediately after that. I would have expected to see the exact same behavior on Windows. This is also how it looks for dt on Windows.
Edit: I just tried the following: rawtherapee.exe -v -w > C:\Users\Simon\Desktop\rt.txt
This does not open an extra console window (as expected) and gives me a text file with the following content:
Using lensfun 0.3.2.0
Whereas rawtherapee.exe -v > C:\Users\Simon\Desktop\rt.txt causes the console to stay open and gives me
Using lensfun 0.3.2.0
RawTherapee, version 5.4
WARNING: closing this window will close RawTherapee!
Press any key to exit RawTherapee
So somehow the RT version information is missing when starting with -w. This will cause the detection code that is used in gimp to fail because it specifically looks for the string "RawTherapee, version %d.%d".
ON W10
Rawtherapee.exe-debug : no console opens. OK
The -mwindows flag should permit to suppress console window on Windows. It does not change the behaviour.
I take this.
So somehow the RT version information is missing when starting with -w
That's a bug. I will fix it.
When the bug is fixed, you can even skip -w parameter and use
rawtherapee.exe -v &> C:\Users\Simon\Desktop\rt.txt
which redirects stdout and stderr. In this case the console window won't be opened.
@gaaned92
execution from bash console or dos console
rawtherapee. exe : no RT console opens: OK
rawtherapee.exe -v : RT console opens: KO must add -w to suppress console
rawtherapee.exe -h: console opens: KO
rawtherapee.exe -h -w: console opens:KO
Here we have to distinguish between dos console (cmd.exe) and bash console.
I agree that when started from bash console no new console window should be opened (I'm currently fixing that) if RT is bound to the bash console.
But when started from cmd.exe RT is decoupled from the cmd.exe console and needs to open a new one to write (well at least if the output should be visible).
Here's a patch
diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc
index 43948bae9..f130d1dbc 100644
--- a/rtgui/main-cli.cc
+++ b/rtgui/main-cli.cc
@@ -221,11 +221,10 @@ int main (int argc, char **argv)
#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)) {
+ bool stdoutRedirectedtoConsole = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0000);
+ bool stderrRedirectedtoConsole = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0000);
+ // open console, if stdout or stderr are invalid
+ if (stdoutRedirectedtoConsole || stderrRedirectedtoConsole) {
// 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;
@@ -255,11 +254,11 @@ int main (int argc, char **argv)
cursorInfo.bVisible = false;
SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo );
- if (!stdoutRedirectedtoFile) {
+ if (stdoutRedirectedtoConsole) {
freopen ( "CON", "w", stdout ) ;
}
- if (!stderrRedirectedtoFile) {
+ if (stderrRedirectedtoConsole) {
freopen ( "CON", "w", stderr ) ;
}
diff --git a/rtgui/main.cc b/rtgui/main.cc
index 80f055bbf..097493c88 100644
--- a/rtgui/main.cc
+++ b/rtgui/main.cc
@@ -528,11 +528,10 @@ int main (int argc, char **argv)
int ret = processLineParams ( argc, argv);
if (options.rtSettings.verbose || (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, 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)) {
+ bool stdoutRedirectedtoConsole = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0000);
+ bool stderrRedirectedtoConsole = (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) == 0x0000);
+ // open console, if stdout or stderr are invalid
+ if (stdoutRedirectedtoConsole || stderrRedirectedtoConsole) {
// 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;
@@ -562,30 +561,31 @@ int main (int argc, char **argv)
cursorInfo.bVisible = false;
SetConsoleCursorInfo ( GetStdHandle ( STD_OUTPUT_HANDLE ), &cursorInfo );
- if (!stdoutRedirectedtoFile) {
+ if (stdoutRedirectedtoConsole) {
freopen ( "CON", "w", stdout ) ;
}
- if (!stderrRedirectedtoFile) {
+ if (stderrRedirectedtoConsole) {
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 << std::endl;
- std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
}
}
}
if ( ret <= 0 ) {
if (consoleOpened) {
+ // printing RT's version in every case, particularly useful for the 'verbose' mode, but also for the batch processing
+ printf("RawTherapee, version %s\n", RTVERSION);
+ printf ("WARNING: closing this window will close RawTherapee!\n");
printf ("Press any key to exit RawTherapee\n");
FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE));
getch();
+ } else {
+ std::cout << "RawTherapee, version " << RTVERSION << std::endl;
}
return ret;
@@ -597,9 +597,6 @@ int main (int argc, char **argv)
if (argc > 1 || options.rtSettings.verbose) {
// printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing
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) {
int ret = processLineParams ( argc, argv);
When started from msys2 (bash) console no additional console should open now.
When started from cmd.exe and redirecting output to a file, you also have to redirect stderr to a file or NULL or use the -w switch.
rawtherapee.exe -v > test.txt 2>NULL
or
rawtherapee.exe -v -w > test.txt
@heckflosse isn't it possible to have "-v" activate also "-w" by default? If not, why?
When I call rawtherapee -v from cmd.exe I want to see the version information.
As soon as I start rawtherapee.exe it is decoupled from the cmd.exe console and can't write the version info there.
For that reason RT opens a console in that case to show the version information. Same for -h
Calling rawtherapee -v -w without redirecting stdout and/or stderr makes no sense. It's just a nop.
@heckflosse what I meant is that RT should not detatch itself from the console if -v is given... are you saying that this is technically not possible?
@agriggio at least I don't know how to do that.
@agriggio from here
GUI applications are initialized without a console.
why can't you just enforce an implicit -w when -v is given?
@agriggio because then the console window would not be opened and the output would not be visible.
What do I expect if I call rawtherapee -v from the console (cmd.exe)?
I expect to see the version information.
Because RT is detached from console it opens its own console and shows the version information.
To let me read the version information, it waits for a key press before the console closes.
An implicit -w when -v is given would mean, the console window would not be opened (-w means, no console window) and I would not be able to see the version information.
@agriggio another possibility is to build rt for windows as console application (without the -mwindows flag). But then, when starting rt from windows explorer or desktop or start menu, always a console is opened. We can close this console immediately but it is still visible for a short time, which is annoying.
Let my try to explain more detailed the current situation (if the patch from above is applied) for windows builds.
1.) when starting from bash, no new console window is opened (has been opened before patch)
else {
2) when starting from cmd.exe or windows explorer or..., a new console window is opened when needed. For example, if you call rawtherapee -v a console window is opened to show the version information
3) when redirecting stdout and stderr, no new console window is opened. That's same behaviour as before, but before patch in this case the version information was not written to the redirected stdout. That's fixed now.
}
ok, thanks for the clarification. Windows is a funny os indeed... :-)
@gaaned92 please try the patch from above if your time permits. Though I'm usually building rt without -mwindows, in this case I build with using -mwindows (with the patch applied), and all worked as designed.
But I also may miss some things...
@heckflosse
With patch and -mwindows
MSYS2 console : all is ok,no RT console, text written in MSYS2 console or redirected to file as required
DOS console
rawtherapee.exe no console opens
rawtherapee.exe -v : no version text, RT Console opens
rawtherapee.exe -v >tt.txt: text written in tt.txt, Empty RT console opens(absolutely nothing in it)
rawtherapee -v -w nothing hapens
rawtherapee -v -w >tt.txt : text written in tt.txt, no console
rawtherapee -h: no help written, RT console opens without help text
rawtherapee -h -w nothing hapens
rawtherapee -h -w >tt.txt : no RT console, help written in tt.txt
rawtherapee -h >ts.txt : help written in tt.txt, empty RT console
There is also the powershell console
I am going to test without -mwindows
With patch without -mwindows
-DOS console : same as above
So the -mwindows flag could be useless?
@gaaned92
So the -mwindows flag could be useless?
No, I found no way to completely suppress the console window when build without -mwindows. It still shows up for a short time, which is annoying :(
@gaaned92
With patch and -mwindows
MSYS2 console : all is ok,no RT console, text written in MSYS2 console or redirected to file as required
DOS console
rawtherapee.exe no console opens
rawtherapee.exe -v : no version text, RT Console opens
rawtherapee.exe -v >tt.txt: text written in tt.txt, Empty RT console opens(absolutely nothing in it)
rawtherapee -v -w nothing hapens
rawtherapee -v -w >tt.txt : text written in tt.txt, no console
rawtherapee -h: no help written, RT console opens without help text
rawtherapee -h -w nothing hapens
rawtherapee -h -w >tt.txt : no RT console, help written in tt.txt
rawtherapee -h >ts.txt : help written in tt.txt, empty RT console
rawtherapee.exe -v : no version text, RT Console opens
Do you mean the RT console doesn't show version information in this case. That would be clearly a bug!
rawtherapee.exe -v >tt.txt: text written in tt.txt, Empty RT console opens(absolutely nothing in it)
That's expected behaviour because stderr is not redirected. Add 2>NULL to redirect stderr to NULL device
@gaaned92
rawtherapee -h: no help written, RT console opens without help text
Confirmed. Will fix that
@gaaned92
rawtherapee -h >ts.txt : help written in tt.txt, empty RT console
typo? > ts.txt should not write tt.txt
1-
No, I found no way to completely suppress the console window when build without -mwindows. It still shows up for a short time, which is annoying :(
I didn't succeed to view this transient console on my machine
2-
```
rawtherapee.exe -v : no version text, RT Console opens
Do you mean the RT console doesn't show version information in this case. That would be clearly a bug!
the version info is like this:
Using lensfun 0.3.2.0
RawTherapee, version 5.4-240-ge518e792
The RT console shows only
RawTherapee, version 5.4-240-ge518e792
WARNING: closing this window will close RawTherapee!
Press any key to exit RawTherapee
``
Which is the same thing displayed byrawtherapee.exe -h` , so I think it is not version information.
3-
yes, typo
@gaaned92
I didn't succeed to view this transient console on my machine
For builds without -mwindows I get the transient console always when starting rt from Start menu / Explorer / Desktop Shortcut on Windows 7
@Beep6581 @gaaned92 Just a silly thought: We have a manpage
Why don't we use them instead of hardcoding help information in rt ?
It would be easier to maintain, and less duplication.
About lensfun version
As all the versions old or recent have the same version nulmber, it is not at all informative.
Much interesting is the timestamp in the DB.
Ok for -mwindows, but I cannot observe here the same behaviour. The safer is thus to use -mwindows.
It turned out that it's more difficult as I thought...
When started from msys2 console, output is only visible when using std::cout. Output generated by using printf will be visible when a std::cout follows. I already tried this, but failed.
When started from cmd.exe and a console is opened (because for example verbose=true in preferences), output is only visible when using printf.
That makes using verbose=true on windows somehow useless atm, because we use std::cout and printf in the code.
@heckflosse try to set both stdout and std::cout to no buffering
@agriggio I just tried
std::cout.setf(std::ios::unitbuf);
setvbuf(stdout, NULL, _IONBF, 0);
Still the same :(
Here's a better patch.
Now most things work as expected.
The exception is the verbose mode on Windows which still has the same issues as before.
Please test thoroughly.
@gaaned92 I still have to check how to get the lensfun database timestamp. Maybe @agriggio knows.
diff --git a/rtgui/main-cli.cc b/rtgui/main-cli.cc
index 43948bae9..6643b0913 100644
--- a/rtgui/main-cli.cc
+++ b/rtgui/main-cli.cc
@@ -206,75 +206,6 @@ int main (int argc, char **argv)
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
int ret = 0;
@@ -288,16 +219,6 @@ int main (int argc, char **argv)
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;
}
@@ -575,11 +496,6 @@ int processLineParams ( int argc, char **argv )
}
break;
-#ifdef WIN32
-
- case 'w': // This case is handled outside this function
- break;
-#endif
case 'h':
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]) << " <other options> -c <dir>|<files> Convert files in batch with your own settings." << 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 << " " << 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;
diff --git a/rtgui/main.cc b/rtgui/main.cc
index 80f055bbf..e61e73338 100644
--- a/rtgui/main.cc
+++ b/rtgui/main.cc
@@ -121,6 +121,7 @@ static void myGdkLockLeave()
* -3 if at least one required procparam file was not found */
int processLineParams ( int argc, char **argv )
{
+ int ret = 1;
for ( int iArg = 1; iArg < argc; iArg++) {
Glib::ustring currParam (argv[iArg]);
if ( currParam.empty() ) {
@@ -139,8 +140,10 @@ int processLineParams ( int argc, char **argv )
#endif
case 'v':
- std::cout << "Using lensfun " << LF_VERSION_MAJOR << "." << LF_VERSION_MINOR << "." << LF_VERSION_MICRO << "." << LF_VERSION_BUGFIX << std::endl;
- return 0;
+ printf("RawTherapee, version %s\n", RTVERSION);
+ printf("Using lensfun %d.%d.%d.%d\n", LF_VERSION_MAJOR, LF_VERSION_MINOR, LF_VERSION_MICRO, LF_VERSION_BUGFIX);
+ 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
@@ -165,34 +168,29 @@ int processLineParams ( int argc, char **argv )
case 'h':
case '?':
default: {
- Glib::ustring pparamsExt = paramFileExtension.substr (1);
- std::cout << " An advanced, cross-platform program for developing raw photos." << std::endl;
- std::cout << std::endl;
- std::cout << " Website: http://www.rawtherapee.com/" << std::endl;
- 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;
+ printf(" An advanced, cross-platform program for developing raw photos.\n\n");
+ 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 << "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;
+ printf("Options:\n");
#ifdef WIN32
- std::cout << " -w Do not open the Windows console" << std::endl;
+ printf(" -w Do not open the Windows console\n");
#endif
- std::cout << " -v Print RawTherapee version number and exit" << std::endl;
+ printf(" -v Print RawTherapee version number and exit\n");
#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
- std::cout << " -h -? Display this help message" << std::endl;
- return -1;
+ printf(" -h -? Display this help message\n");
+
+ ret = -1;
+ break;
}
}
} else {
@@ -212,7 +210,7 @@ int processLineParams ( int argc, char **argv )
}
}
- return 1;
+ return ret;
}
@@ -517,6 +515,14 @@ int main (int argc, char **argv)
options.rtSettings.lensfunDbDirectory = LENSFUN_DB_PATH;
#endif
+ Glib::ustring fatalError;
+
+ try {
+ Options::load();
+ } catch (Options::Error &e) {
+ fatalError = e.get_msg();
+ }
+
#ifdef WIN32
bool consoleOpened = false;
@@ -524,15 +530,12 @@ int main (int argc, char **argv)
// suppression of annoying error boxes
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
- if (argc > 1) {
- int ret = processLineParams ( argc, argv);
+ if (argc > 1 || options.rtSettings.verbose) {
if (options.rtSettings.verbose || (!remote && !Glib::file_test (argv1, Glib::FILE_TEST_EXISTS ) && !Glib::file_test (argv1, 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)) {
+ bool stdoutRedirecttoConsole = (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0000);
+ // open console, if stdout is invalid
+ if (stdoutRedirecttoConsole) {
// 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;
@@ -562,26 +565,21 @@ int main (int argc, char **argv)
cursorInfo.bVisible = false;
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 ) ;
- }
-
- 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 << std::endl;
- std::cout << "WARNING: closing this window will close RawTherapee!" << std::endl << std::endl;
}
}
}
+ int ret = processLineParams ( argc, argv);
if ( ret <= 0 ) {
+ fflush(stdout);
if (consoleOpened) {
printf ("Press any key to exit RawTherapee\n");
FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE));
@@ -594,19 +592,11 @@ int main (int argc, char **argv)
#else
- if (argc > 1 || options.rtSettings.verbose) {
- // printing RT's version in all case, particularly useful for the 'verbose' mode, but also for the batch processing
- 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) {
- int ret = processLineParams ( argc, argv);
+ if (argc > 1) {
+ int ret = processLineParams ( argc, argv);
- if ( ret <= 0 ) {
- return ret;
- }
+ if ( ret <= 0 ) {
+ return ret;
}
}
@@ -628,14 +618,6 @@ int main (int argc, char **argv)
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_init();
gtk_init (&argc, &argv); // use the "--g-fatal-warnings" command line flag to make warnings fatal
@@ -681,6 +663,7 @@ int main (int argc, char **argv)
if (consoleOpened) {
printf ("Press any key to exit RawTherapee\n");
+ fflush(stdout);
FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE));
getch();
}
@heckflosse I would actually kill the info about lensfun from the output of -v -- I think it doesn't belong there
@agriggio ok, will do that later. Off to beer garden now.
@heckflosse
Until this thread, my builds were made without -mwindows.
I always run them in verbose mode.
When running from shortcut or double-clicking on explorer, RT starts without opening any Console.
Now, with your last patch and with -mwindows, When running in verbose mode, a RT console opens containing only what follows:
**************** FileCatalog::getFilter *** AFTER STEP 1
filter.showRanked[0] = 1
filter.showRanked[1] = 1
filter.showRanked[2] = 1
filter.showRanked[3] = 1
filter.showRanked[4] = 1
filter.showRanked[5] = 1
filter.showCLabeled[0] = 1
filter.showCLabeled[1] = 1
filter.showCLabeled[2] = 1
filter.showCLabeled[3] = 1
filter.showCLabeled[4] = 1
filter.showCLabeled[5] = 1
filter.showEdited[0] = 1
filter.showEdited[1] = 1
filter.showRecentlySaved[0] = 1
filter.showRecentlySaved[1] = 1
If I close the main window, the console stay open.
All my future builds will be made with -mwindows unless somebody disagree.
Have I to test as above with verbose=true or you want also tests for verbose=false?
@gaaned92 rawtherapee-cli should be build without -mwindows
Edit: our default CMakeLists.txt already adds -mwindows for the release builds of non cli rawtherapee target.
https://github.com/Beep6581/RawTherapee/blob/dev/rtgui/CMakeLists.txt#L239
@gaaned92
When running from shortcut or double-clicking on explorer, RT starts without opening any Console.
Now, with your last patch and with -mwindows, When running in verbose mode, a RT console
In past verbose mode on Windows only worked for debug builds. Now it also works for release builds.
I can revert to old behaviour because I'm not sure if the new behaviour is desired.
Edited because I quotet the wrong part.
@heckflosse
mwindows : OK, I forgot that.
In past,verbose mode worked also if RT started from console.
The new behaviour should not collide with requirement for GIMP plugin.
@heckflosse or @agriggio
when several RT versions are installed, is there an easy way to choose the version launched by the plugin?
@gaaned92
In past,verbose mode worked also if RT started from console.
The new behaviour should not collide with requirement for GIMP plugin
In past I never started RT from cmd.exe or double click in explorer or startmenu...
I always started from msys2 console.
Does the new behaviour collide with the requirement for the GIMP plugin?
If so, I have to fix that.
Test of dev branch, verbose mode, without mwindows
Direct opening by double clicking , "Open with rawtherapee" in context menu
RT console opens with verbose text, initialisation steps not described (pp3 reading, lensfun DB reading..), doesn't close when closing main window (seems to be a bug)
I suggest to come back to old behaviour. If we want the verbose text we have to start from a console
bash console
rawtherapee.exe : complete verbose text in the bash console OK
rawtherapee.exe -v: useless verbose text for initialisation and version at the end KO
rawtherapee -h: useless verbose text for initialisation and help at the end KO
-Dos console
rawtherapee.exe: opens RT and a RT console replacing bash console with same text OK
rawtherapee.exe -v : opens a RT console with version only OK
rawtherapee -h: opens a RT console with help only OK
@gaaned92
I suggest to come back to old behaviour. If we want the verbose text we have to start from a console
agreed, will change that :+1:
@gaaned92
rawtherapee.exe -v: useless verbose text for initialisation and version at the end KO
rawtherapee -h: useless verbose text for initialisation and help at the end KO
That's independent on my changes I guess. Nevertheless I can try to fix that
@heckflosse
W10
Nevertheless I can try to fix thatI tried to launch the RT plugin with no success. I put the path of dev rawtherapee.exe in %path% . launched GIMP2.10. RT is not registered as a plugin.
I would like to know what is inside the rawtherapee_stdout variable. how I can print it?
Do you know how to build fie-rawtherapee.exe?
To locate the RT exe, I would really prefer to setup a registry variable instead to modify the path.
The Darktable choice seems to be the recommended one. that should be feasible with windows installer.
@gaaned92
It is not fixed in last dev
Imho it was not related to this issue. I will try to fix that now.
launched GIMP2.10
I can't even launch GIMP2.10 without getting hundreds of messageboxes.
Do you know how to build fie-rawtherapee.exe?
What's that?
To locate the RT exe, I would really prefer to setup a registry variable instead to modify the path.
The Darktable choice seems to be the recommended one. that should be feasible with windows installer.
agreed
@gaaned92
Nevertheless I can try to fix that
Fix pushed, but only for rawtherapee, not for rawtherapee-cli
@gaaned92
About printing rawtherapee_stdout see line 305 of file-rawtherapee.c
I found this in file-rawtherapee.c
/* query() is run only the first time for efficiency. Yet this plugin
* is dependent on the presence of rawtherapee which may be installed
* or uninstalled between GIMP startups. Therefore we should move the
* usual gimp_install_procedure() to init() so that the check is done
* at every startup instead.
*/
Does that mean the presence of RT is only checked at gimp installation time?
@heckflosse not at installation time, but only once the first time you run a new version of GIMP, and therefore it re-creates the plug-in cache.
Putting the code in the init() function forces GIMP to check for the existence of the RT executable every time it is started, and not only the first time.
@aferrero2707 Then the current file_rawtherapee.c should be correct as it's already in the init() function.
Fix pushed, but only for rawtherapee, not for rawtherapee-cli
Thanks
I can't even launch GIMP2.10 without getting hundreds of messageboxes.
I installed Partha's build. I did'nt really yet use it but it launches ok (except for RT plugin!)
Then the current file_rawtherapee.c should be correct as it's already in the init() function.
Yes I assume that.
Do you know how to build file-rawtherapee.exe?
What's that?
there was a typo!
I would like to build this exe from file_rawtherapee.c . My previous trials were unsuccessfull.
Do you know how to build file-rawtherapee.exe?
What's that?
there was a typo!
would like to build this exe from file_rawtherapee.c . My previous trials were unsuccessfull.
Even though this issues is closed is the above still related to RT or is it now just a gimp problem ?
Edit: BTW, the new downstream ticket was moved to https://gitlab.gnome.org/GNOME/gimp/issues/1816
Most helpful comment
@agriggio ok, will do that later. Off to beer garden now.