Engauge Digitizer  2
LoggerUpload.cpp
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include <iostream>
8 #include "LoggerUpload.h"
9 #include "MainWindow.h"
10 
11 const MainWindow *LoggerUpload::m_mainWindow = (const MainWindow*) 0;
12 
14 {
15 }
16 
18 {
19  m_mainWindow = mainWindow;
20 }
21 
22 void LoggerUpload::loggerAssert(const char *condition,
23  const char* file,
24  int line)
25 {
26  loggerOutput (condition,
27  file,
28  line,
29  "assert");
30 }
31 
32 void LoggerUpload::loggerCheckPtr(const char *ptr,
33  const char *file,
34  int line)
35 {
36  loggerOutput (ptr,
37  file,
38  line,
39  "null pointer");
40 }
41 
42 void LoggerUpload::loggerOutput(const char *comment,
43  const char *file,
44  int line,
45  const char *context)
46 {
47  if (m_mainWindow != 0) {
48  m_mainWindow->saveErrorReportFileAndExit(comment,
49  file,
50  line,
51  context);
52  }
53 
54  std::cerr << "Error '" << context << "' at file " << file << " line " << line << ": " << comment << std::endl;
55  exit (-1); // Stop execution since it is no longer safe to continue
56 }
LoggerUpload()
Single constructor.
static void loggerAssert(const char *condition, const char *file, int line) NO_RETURN_VALUE
Smart equivalent to standard assert method and Q_ASSERT (in qglobal.h).
static void bindToMainWindow(const MainWindow *mainWindow)
Bind to MainWindow so this class can access the command stack.
static void loggerCheckPtr(const char *pointer, const char *file, int line) NO_RETURN_VALUE
Smart equivalent to Q_CHECK_PTR (in qglobal.h). Similar to loggerAssert but for checking newly-alloca...
void saveErrorReportFileAndExit(const char *comment, const char *file, int line, const char *context) const
Save error report and exit.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:89