dannyedel / dspdfviewer

Dual-Screen PDF Viewer for latex-beamer
http://dspdfviewer.danny-edel.de
GNU General Public License v2.0
218 stars 27 forks source link

Hiding console #52

Closed projekter closed 9 years ago

projekter commented 9 years ago

Changed application type to Windows GUI so that the console windows does not show up automatically. Note that this also means that there will never be a console or output to a console window in any case. If you used the console at some point to print a message without at the same time giving a window popup, this message will not be seen.

dannyedel commented 9 years ago

Ah okay, I didn't know that it will be completely gone. One more thing to add to the list where windows differs from linux:

On the linux system, if the application is started from GUI (for example, because you've assigned it to a rightclick on PDF "Open with dspdfviewer" or something like that) standard output will be hidden automatically.

Howver, if you spawn it from terminal, standard output goes to that terminal. So on linux it's not a compile-time definition, but more a run-time user choice to see terminal output.


For a normal user, there will never be any understandable output on the terminal, I can guarantee you that much : ) So its safe to completely disable it on builds for users.

We already include an exception catcher that renders a QMessageBox, so anything that throws an exception will be seen by a GUI user right before the application terminates.


The only thing I can imagine is that a developer working on windows may want to see console output while debugging, so you might want to enclose it in a "if on windows and not debugging" stance.

You can change Debug/Release with cmake. In the build directory, try the commands

cmake . -DCMAKE_BUILD_TYPE=Release && make

# or

cmake . -DCMAKE_BUILD_TYPE=Debug && make

And try the resulting executable. On my linux system, the "Debug" version generates a lot of console output, while "Release" is silent.


If debugging output works at all on windows, lets see if we can make use of it for developers.

Release mode will set a compiler define named NDEBUG (No-Debugging) (as well as a longer one named QT_NO_DEBUG_OUTPUT).

Please try if a stance like the following works on your system:

#if defined ( _WIN32 ) and defined ( NDEBUG )
// Hide console by using WinMain()
#else
//standard main()
#endif

Sorry for all the noise, but I think its amazing that dspdfviewer works even on windows - and if we can make it that using and developing there works similar to linux/unix I think it would be amazing.

Since this is also my first-ever cross platform project, it has a lot of educational value to me about different operating systems, so I'm sorry if my learning curve is a bit slow.

projekter commented 9 years ago

I included this check. The debug.h had to be adjusted, as func is called FUNCTION in VC++. I also uploaded another release containing the files with debug information. In order to work properly, I had to recompile poppler with debug information as well (or else an assertion failure would be presented right after the file choser). As far as I tested it, debugging works without any problems.

dannyedel commented 9 years ago

Thanks! I have included the pullrequest.