mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Add console output on windows
This commit is contained in:
33
src/main.cpp
33
src/main.cpp
@@ -36,10 +36,38 @@
|
|||||||
#include "breakpad/BreakPad.h"
|
#include "breakpad/BreakPad.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <io.h>
|
||||||
|
#define argc __argc
|
||||||
|
#define argv __argv
|
||||||
|
// code taken from AbiWord, (c) AbiSource Inc.
|
||||||
|
|
||||||
|
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||||
|
PSTR szCmdLine, int iCmdShow)
|
||||||
|
{
|
||||||
|
if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1)
|
||||||
|
{
|
||||||
|
/* stdout is fine, presumably redirected to a file or pipe */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
typedef BOOL (WINAPI * AttachConsole_t) (DWORD);
|
||||||
|
|
||||||
|
AttachConsole_t p_AttachConsole = (AttachConsole_t) GetProcAddress (GetModuleHandleW(L"kernel32.dll"), "AttachConsole");
|
||||||
|
|
||||||
|
if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS))
|
||||||
|
{
|
||||||
|
_wfreopen (L"CONOUT$", L"w", stdout);
|
||||||
|
dup2 (fileno (stdout), 1);
|
||||||
|
_wfreopen (L"CONOUT$", L"w", stderr);
|
||||||
|
dup2 (fileno (stderr), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else // Q_OS_WIN
|
||||||
int
|
int
|
||||||
main( int argc, char *argv[] )
|
main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
// Do Mac specific startup to get media keys working.
|
// Do Mac specific startup to get media keys working.
|
||||||
// This must go before QApplication initialisation.
|
// This must go before QApplication initialisation.
|
||||||
Tomahawk::macMain();
|
Tomahawk::macMain();
|
||||||
@@ -47,7 +75,8 @@ main( int argc, char *argv[] )
|
|||||||
// used for url handler
|
// used for url handler
|
||||||
AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler );
|
AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler );
|
||||||
AEInstallEventHandler( 'GURL', 'GURL', h, 0, false );
|
AEInstallEventHandler( 'GURL', 'GURL', h, 0, false );
|
||||||
#endif
|
#endif // Q_WS_MAC
|
||||||
|
#endif //Q_OS_WIN
|
||||||
|
|
||||||
/* // Unity hack taken from Clementine's main.cpp
|
/* // Unity hack taken from Clementine's main.cpp
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
|
Reference in New Issue
Block a user