Ejemplo n.º 1
0
static bool crashCallback(wchar_t const* dump_path,
                          wchar_t const* id,
                          void* context, EXCEPTION_POINTERS* exinfo,
                          MDRawAssertionInfo* assertion,
                          bool succeeded)
{
    if (!succeeded) {
        return false;
    }

    static wchar_t command_line[1024] = L"CrashReporter.exe ";
    wchar_t* p = command_line;
    p = lstrcatW(p, L"\"");
    p = lstrcatW(p, dump_path);
    p = lstrcatW(p, L"\" ");
    p = lstrcatW(p, L"\"");
    p = lstrcatW(p, id);
    p = lstrcatW(p, L"\"");

    static PROCESS_INFORMATION pinfo;
    static STARTUPINFOW startupinfo = {
        sizeof(STARTUPINFOW), 0, 0, 0,
        CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    };

    if (CreateProcessW(crash_reporter_path, command_line, 0, 0, FALSE,
                       CREATE_UNICODE_ENVIRONMENT|CREATE_NEW_CONSOLE, 0, 0,
                       &startupinfo, &pinfo)) {
        return true;
    }

    // CraeateProcessW() failed.  Maybe crash_reporter_path got corrupted?
    // Let's try to re-create it.
    getCrashReporterPath(
        crash_reporter_path,
        sizeof(crash_reporter_path)/sizeof(crash_reporter_path[0])
    );

    if (CreateProcessW(crash_reporter_path, command_line, 0, 0, FALSE,
                       CREATE_UNICODE_ENVIRONMENT|CREATE_NEW_CONSOLE, 0, 0,
                       &startupinfo, &pinfo)) {
        return true;
    }

    return false;
}
Ejemplo n.º 2
0
int main(int argc, char** argv)
{
#ifdef ENABLE_CRASH_REPORTER
    getCrashReporterPath(
        crash_reporter_path,
        sizeof(crash_reporter_path)/sizeof(crash_reporter_path[0])
    );

    google_breakpad::ExceptionHandler eh(
        QDir::tempPath().toStdWString().c_str(), 0, &crashCallback,
        0, google_breakpad::ExceptionHandler::HANDLER_ALL
    );
#endif

    Application app(argc, argv);

#ifdef _WIN32
    // Get rid of all references to Qt's installation directory.
    app.setLibraryPaths(QStringList(app.applicationDirPath()));
#endif

    // parse command line arguments
    CommandLine cli(app.arguments());
    CommandLine::set(cli);

    if (cli.hasHelp()) {
        cli.printHelp();
        return 0;
    }

    QString const translation("scantailor_"+QLocale::system().name());
    QTranslator translator;

    // Try loading from the current directory.
    if (!translator.load(translation)) {
        // Now try loading from where it's supposed to be.
        QString path(QString::fromUtf8(TRANSLATIONS_DIR_ABS));
        path += QChar('/');
        path += translation;
        if (!translator.load(path)) {
            path = QString::fromUtf8(TRANSLATIONS_DIR_REL);
            path += QChar('/');
            path += translation;
            translator.load(path);
        }
    }

    app.installTranslator(&translator);

    // This information is used by QSettings.
    app.setApplicationName("Scan Tailor");
    app.setOrganizationName("Scan Tailor");
    app.setOrganizationDomain("scantailor.sourceforge.net");
    QSettings settings;

    PngMetadataLoader::registerMyself();
    TiffMetadataLoader::registerMyself();
    JpegMetadataLoader::registerMyself();

    MainWindow* main_wnd = new MainWindow();
    main_wnd->setAttribute(Qt::WA_DeleteOnClose);
    if (settings.value("mainWindow/maximized") == false) {
        main_wnd->show();
    } else {
        main_wnd->showMaximized();
    }

    if (!cli.projectFile().isEmpty()) {
        main_wnd->openProject(cli.projectFile());
    }

    return app.exec();
}
Ejemplo n.º 3
0
Archivo: main.cpp Proyecto: DikBSD/STE
int main(int argc, char** argv)
{
#ifdef ENABLE_CRASH_REPORTER
	getCrashReporterPath(
		crash_reporter_path,
		sizeof(crash_reporter_path)/sizeof(crash_reporter_path[0])
	);

	google_breakpad::ExceptionHandler eh(
		QDir::tempPath().toStdWString().c_str(), 0, &crashCallback,
		0, google_breakpad::ExceptionHandler::HANDLER_ALL
	);
#endif

	Application app(argc, argv);
	
	QString const translation("scantailor_"+QLocale::system().name());
	QTranslator translator;
	
	// Try loading from the current directory.
	if (!translator.load(translation)) {
		// Now try loading from where it's supposed to be.
		QString path(QString::fromUtf8(TRANSLATIONS_DIR_ABS));
		path += QChar('/');
		path += translation;
		if (!translator.load(path)) {
			path = QString::fromUtf8(TRANSLATIONS_DIR_REL);
			path += QChar('/');
			path += translation;
			translator.load(path);
		}
	}
	
	app.installTranslator(&translator);
	
	// This information is used by QSettings.
	app.setApplicationName("Scan Tailor Extended");		// +
	app.setOrganizationName("Scan Tailor Extended");	// +
	app.setOrganizationDomain("scantailor.sourceforge.net");
	QSettings settings;
	
	PngMetadataLoader::registerMyself();
	TiffMetadataLoader::registerMyself();
	JpegMetadataLoader::registerMyself();
	
	MainWindow* main_wnd = new MainWindow();
	main_wnd->setAttribute(Qt::WA_DeleteOnClose);
	if (settings.value("mainWindow/maximized") == false) {
		main_wnd->show();
	} else {
		main_wnd->showMaximized();
	}
	
	// Note that we use app.arguments() rather than argv,
	// because the former is Unicode-safe under Windows.
	QStringList const args(app.arguments());
	if (args.size() > 1) {
		main_wnd->openProject(args[1]);
	}
	
	return app.exec();
}