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
|
// ****************************************************************************
// Project: GUYMAGER
// ****************************************************************************
// Programmer: Guy Voncken
// Police Grand-Ducale
// Service de Police Judiciaire
// Section Nouvelles Technologies
// ****************************************************************************
// Module: Error handling utilities
// ****************************************************************************
// Copyright 2008, 2009, 2010, 2011 Guy Voncken
//
// This file is part of guymager.
//
// guymager 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.
//
// guymager is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with guymager. If not, see <http://www.gnu.org/licenses/>.
#include <stdarg.h>
#include <stdlib.h>
#include <QtGui>
#include "common.h"
#include "qtutil.h"
// -----------------------
// Constants
// -----------------------
static const int EXIT_SLEEP_BEFORE_EXIT = 3000; // ms
// -----------------------
// Local variables
// -----------------------
static int ErrorPopupCounter = 0;
// -----------------------
// Functions
// -----------------------
void ErrorExit (int ExitCode)
{
LOG_ERROR ("Exiting GUYMAGER with code %d", ExitCode)
printf ("\n\n");
(void) QtUtilSleep (EXIT_SLEEP_BEFORE_EXIT); // Quite often, the last messages of the slave cannot be
exit (ExitCode);
}
void ErrorPopupExit (const char *pFileName, const char *pFunctionName, int LineNr, APIRET ec, const char *pMsg)
{
const char *pErr;
QString MsgTxt;
if (ErrorPopupCounter < 3) // If there are already several windows, then they are most probably generated by a timer and we risk
{ // to fill up the screen without being able to click them all away. So, we simply exit here.
ErrorPopupCounter++;
(void) ToolErrorCheck (pFileName, pFunctionName, LineNr, ec);
pErr = ToolErrorMessage(ec);
if (pMsg)
MsgTxt = QString(pMsg) + QString("\n") + QString(pErr);
else MsgTxt = pErr;
(void) QMessageBox::critical (0, "Internal error", MsgTxt);
}
ErrorExit ();
}
APIRET ErrorInit (void)
{
CHK (TOOL_ERROR_REGISTER_CODE (ERROR_QT_UNSUCCESSFUL))
return NO_ERROR;
}
APIRET ErrorDeInit (void)
{
return NO_ERROR;
}
|