1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
main.cpp - description
-------------------
begin : Fre Apr 6 21:47:55 CEST 2001
copyright : (C) 2001 by Franz Schmid
email : Franz.Schmid@altmuehlnet.de
copyright : (C) 2004 by Alessandro Rimoldi
email : http://ideale.ch/contact
copyright : (C) 2005 by Craig Bradney
email : cbradney@zip.com.au
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <iostream>
#include <signal.h>
#include <QApplication>
#define BASE_QM "scribus"
#include "scribusapp.h"
#include "scribuscore.h"
#include "scribus.h"
#include "scconfig.h"
int mainApp(int argc, char **argv);
void initCrashHandler();
static void defaultCrashHandler(int sig);
ScribusCore SCRIBUS_API *ScCore;
ScribusMainWindow SCRIBUS_API *ScMW;
ScribusQApp SCRIBUS_API *ScQApp;
bool emergencyActivated;
int main(int argc, char *argv[])
{
return mainApp(argc, argv);
}
/*!
\author Franz Schmid
\author Alessandro Rimoldi
\author Craig Bradney
\date Mon Feb 9 14:07:46 CET 2004
\brief Launches the Gui
\param argc Number of arguments passed to Scribus
\param argv *argv list of the arguments passed to Scribus
\retval int Error code from the execution of Scribus
*/
int mainApp(int argc, char **argv)
{
emergencyActivated=false;
ScribusQApp app(argc, argv);
initCrashHandler();
/* possible fix for the Qt-4.4.0 locale problem */
#ifdef Q_OS_UNIX
// setlocale(LC_ALL, "C"); // use correct char set mapping
#if (QT_VERSION == 0x040400) || (QT_VERSION == 0x040500)
setlocale(LC_NUMERIC, "C"); // make sprintf()/scanf() work
#endif // QT_VERSION == 0x040400
#endif // Q_OS_UNIX
app.parseCommandLine();
if (app.useGUI)
{
int appRetVal=app.init();
if (appRetVal==EXIT_FAILURE)
return(EXIT_FAILURE);
return app.exec();
}
return EXIT_SUCCESS;
}
void initCrashHandler()
{
typedef void (*HandlerType)(int);
HandlerType handler = 0;
handler = defaultCrashHandler;
if (!handler)
handler = SIG_DFL;
sigset_t mask;
sigemptyset(&mask);
#ifdef SIGSEGV
signal (SIGSEGV, handler);
sigaddset(&mask, SIGSEGV);
#endif
#ifdef SIGFPE
signal (SIGFPE, handler);
sigaddset(&mask, SIGFPE);
#endif
#ifdef SIGILL
signal (SIGILL, handler);
sigaddset(&mask, SIGILL);
#endif
#ifdef SIGABRT
signal (SIGABRT, handler);
sigaddset(&mask, SIGABRT);
#endif
sigprocmask(SIG_UNBLOCK, &mask, 0);
}
void defaultCrashHandler(int sig)
{
static int crashRecursionCounter = 0;
crashRecursionCounter++;
signal(SIGALRM, SIG_DFL);
if (crashRecursionCounter < 2)
{
emergencyActivated=true;
crashRecursionCounter++;
QString sigHdr=QObject::tr("Scribus Crash");
QString sigLine="-------------";
QString sigMsg=QObject::tr("Scribus crashes due to Signal #%1").arg(sig);
std::cout << sigHdr.toStdString() << std::endl;
std::cout << sigLine.toStdString() << std::endl;
std::cout << sigMsg.toStdString() << std::endl;
if (ScribusQApp::useGUI)
{
ScCore->closeSplash();
QMessageBox::critical(ScMW, sigHdr, sigMsg, QObject::tr("&OK"));
ScMW->emergencySave();
ScMW->close();
}
alarm(300);
}
exit(255);
}
|