Chris@222: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@222: Chris@222: /* Chris@222: Sonic Visualiser Chris@222: An audio file viewer and annotation editor. Chris@222: Centre for Digital Music, Queen Mary, University of London. Chris@222: This file copyright 2006 Chris Cannam. Chris@222: Chris@222: This program is free software; you can redistribute it and/or Chris@222: modify it under the terms of the GNU General Public License as Chris@222: published by the Free Software Foundation; either version 2 of the Chris@222: License, or (at your option) any later version. See the file Chris@222: COPYING included with this distribution for more information. Chris@222: */ Chris@222: Chris@222: #include Chris@222: #include Chris@222: Chris@222: #include Chris@222: Chris@222: #ifdef Q_WS_X11 Chris@222: #include Chris@222: #include Chris@222: #include Chris@222: #include Chris@222: Chris@222: static int handle_x11_error(Display *dpy, XErrorEvent *err) Chris@222: { Chris@222: char errstr[256]; Chris@222: XGetErrorText(dpy, err->error_code, errstr, 256); Chris@222: if (err->error_code != BadWindow) { Chris@222: std::cerr << "Sonic Visualiser: X Error: " Chris@222: << errstr << " " << int(err->error_code) Chris@222: << "\nin major opcode: " Chris@222: << int(err->request_code) << std::endl; Chris@222: } Chris@222: return 0; Chris@222: } Chris@222: #endif Chris@222: Chris@222: #ifdef Q_WS_WIN32 Chris@222: Chris@222: #include Chris@222: #include Chris@222: Chris@222: // Set default file open mode to binary Chris@222: //#undef _fmode Chris@222: //int _fmode = _O_BINARY; Chris@222: Chris@222: void redirectStderr() Chris@222: { Chris@222: HANDLE stderrHandle = GetStdHandle(STD_ERROR_HANDLE); Chris@222: if (!stderrHandle) return; Chris@222: Chris@222: AllocConsole(); Chris@222: Chris@222: CONSOLE_SCREEN_BUFFER_INFO info; Chris@222: GetConsoleScreenBufferInfo(stderrHandle, &info); Chris@222: info.dwSize.Y = 1000; Chris@222: SetConsoleScreenBufferSize(stderrHandle, info.dwSize); Chris@222: Chris@222: int h = _open_osfhandle((long)stderrHandle, _O_TEXT); Chris@222: if (h) { Chris@222: FILE *fd = _fdopen(h, "w"); Chris@222: if (fd) { Chris@222: *stderr = *fd; Chris@222: setvbuf(stderr, NULL, _IONBF, 0); Chris@222: } Chris@222: } Chris@222: } Chris@222: Chris@222: #endif Chris@222: Chris@222: extern void svSystemSpecificInitialisation() Chris@222: { Chris@222: #ifdef Q_WS_X11 Chris@222: XSetErrorHandler(handle_x11_error); Chris@222: #endif Chris@222: Chris@222: #ifdef Q_WS_WIN32 Chris@222: redirectStderr(); Chris@384: // QFont fn = qApp->font(); Chris@384: // fn.setFamily("Tahoma"); Chris@384: // qApp->setFont(fn); Chris@222: #else Chris@222: #ifdef Q_WS_X11 Chris@263: // QFont fn = qApp->font(); Chris@263: // fn.setPointSize(fn.pointSize() + 2); Chris@263: // qApp->setFont(fn); Chris@222: #endif Chris@222: #endif Chris@222: } Chris@222: Chris@259: Chris@259: