annotate system/Init.cpp @ 345:700cd3350391

* Improvements to layer summary dialog (LayerTree, LayerTreeDialog), & rename. It's still rather unstable though.
author Chris Cannam
date Wed, 28 Nov 2007 17:45:37 +0000
parents 71dfc6ab3b54
children 7aa1de571880
rev   line source
Chris@222 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@222 2
Chris@222 3 /*
Chris@222 4 Sonic Visualiser
Chris@222 5 An audio file viewer and annotation editor.
Chris@222 6 Centre for Digital Music, Queen Mary, University of London.
Chris@222 7 This file copyright 2006 Chris Cannam.
Chris@222 8
Chris@222 9 This program is free software; you can redistribute it and/or
Chris@222 10 modify it under the terms of the GNU General Public License as
Chris@222 11 published by the Free Software Foundation; either version 2 of the
Chris@222 12 License, or (at your option) any later version. See the file
Chris@222 13 COPYING included with this distribution for more information.
Chris@222 14 */
Chris@222 15
Chris@222 16 #include <QApplication>
Chris@222 17 #include <QFont>
Chris@222 18
Chris@222 19 #include <iostream>
Chris@222 20
Chris@222 21 #ifdef Q_WS_X11
Chris@222 22 #include <X11/Xlib.h>
Chris@222 23 #include <X11/Xutil.h>
Chris@222 24 #include <X11/Xatom.h>
Chris@222 25 #include <X11/SM/SMlib.h>
Chris@222 26
Chris@222 27 static int handle_x11_error(Display *dpy, XErrorEvent *err)
Chris@222 28 {
Chris@222 29 char errstr[256];
Chris@222 30 XGetErrorText(dpy, err->error_code, errstr, 256);
Chris@222 31 if (err->error_code != BadWindow) {
Chris@222 32 std::cerr << "Sonic Visualiser: X Error: "
Chris@222 33 << errstr << " " << int(err->error_code)
Chris@222 34 << "\nin major opcode: "
Chris@222 35 << int(err->request_code) << std::endl;
Chris@222 36 }
Chris@222 37 return 0;
Chris@222 38 }
Chris@222 39 #endif
Chris@222 40
Chris@222 41 #ifdef Q_WS_WIN32
Chris@222 42
Chris@222 43 #include <fcntl.h>
Chris@222 44 #include <windows.h>
Chris@222 45
Chris@222 46 // Set default file open mode to binary
Chris@222 47 //#undef _fmode
Chris@222 48 //int _fmode = _O_BINARY;
Chris@222 49
Chris@222 50 void redirectStderr()
Chris@222 51 {
Chris@222 52 HANDLE stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
Chris@222 53 if (!stderrHandle) return;
Chris@222 54
Chris@222 55 AllocConsole();
Chris@222 56
Chris@222 57 CONSOLE_SCREEN_BUFFER_INFO info;
Chris@222 58 GetConsoleScreenBufferInfo(stderrHandle, &info);
Chris@222 59 info.dwSize.Y = 1000;
Chris@222 60 SetConsoleScreenBufferSize(stderrHandle, info.dwSize);
Chris@222 61
Chris@222 62 int h = _open_osfhandle((long)stderrHandle, _O_TEXT);
Chris@222 63 if (h) {
Chris@222 64 FILE *fd = _fdopen(h, "w");
Chris@222 65 if (fd) {
Chris@222 66 *stderr = *fd;
Chris@222 67 setvbuf(stderr, NULL, _IONBF, 0);
Chris@222 68 }
Chris@222 69 }
Chris@222 70 }
Chris@222 71
Chris@222 72 #endif
Chris@222 73
Chris@222 74 extern void svSystemSpecificInitialisation()
Chris@222 75 {
Chris@222 76 #ifdef Q_WS_X11
Chris@222 77 XSetErrorHandler(handle_x11_error);
Chris@222 78 #endif
Chris@222 79
Chris@222 80 #ifdef Q_WS_WIN32
Chris@222 81 redirectStderr();
Chris@345 82 // QFont fn = qApp->font();
Chris@345 83 // fn.setFamily("Tahoma");
Chris@345 84 // qApp->setFont(fn);
Chris@222 85 #else
Chris@222 86 #ifdef Q_WS_X11
Chris@263 87 // QFont fn = qApp->font();
Chris@263 88 // fn.setPointSize(fn.pointSize() + 2);
Chris@263 89 // qApp->setFont(fn);
Chris@222 90 #endif
Chris@222 91 #endif
Chris@222 92 }
Chris@222 93
Chris@259 94
Chris@259 95