+ move GuiApplication class into its own source files
This commit is contained in:
@@ -63,7 +63,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
#include "AutoSaver.h"
|
||||
#include "GuiApplicationNativeEventAware.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Document.h"
|
||||
#include "View.h"
|
||||
@@ -1536,102 +1536,6 @@ void Application::initTypes(void)
|
||||
Gui::PythonWorkbench ::init();
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
/** Override QCoreApplication::notify() to fetch exceptions in Qt widgets
|
||||
* properly that are not handled in the event handler or slot.
|
||||
*/
|
||||
class GUIApplication : public GUIApplicationNativeEventAware
|
||||
{
|
||||
int systemExit;
|
||||
public:
|
||||
GUIApplication(int & argc, char ** argv, int exitcode)
|
||||
: GUIApplicationNativeEventAware(argc, argv), systemExit(exitcode)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Make forwarding events exception-safe and get more detailed information
|
||||
* where an unhandled exception comes from.
|
||||
*/
|
||||
bool notify (QObject * receiver, QEvent * event)
|
||||
{
|
||||
if (!receiver && event) {
|
||||
Base::Console().Log("GUIApplication::notify: Unexpected null receiver, event type: %d\n",
|
||||
(int)event->type());
|
||||
}
|
||||
try {
|
||||
if (event->type() == Spaceball::ButtonEvent::ButtonEventType ||
|
||||
event->type() == Spaceball::MotionEvent::MotionEventType)
|
||||
return processSpaceballEvent(receiver, event);
|
||||
else
|
||||
return QApplication::notify(receiver, event);
|
||||
}
|
||||
catch (const Base::SystemExitException&) {
|
||||
qApp->exit(systemExit);
|
||||
return true;
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("Unhandled Base::Exception caught in GUIApplication::notify.\n"
|
||||
"The error message is: %s\n", e.what());
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
Base::Console().Error("Unhandled std::exception caught in GUIApplication::notify.\n"
|
||||
"The error message is: %s\n", e.what());
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().Error("Unhandled unknown exception caught in GUIApplication::notify.\n");
|
||||
}
|
||||
|
||||
// Print some more information to the log file (if active) to ease bug fixing
|
||||
if (receiver && event) {
|
||||
try {
|
||||
std::stringstream dump;
|
||||
dump << "The event type " << (int)event->type() << " was sent to "
|
||||
<< receiver->metaObject()->className() << "\n";
|
||||
dump << "Object tree:\n";
|
||||
if (receiver->isWidgetType()) {
|
||||
QWidget* w = qobject_cast<QWidget*>(receiver);
|
||||
while (w) {
|
||||
dump << "\t";
|
||||
dump << w->metaObject()->className();
|
||||
QString name = w->objectName();
|
||||
if (!name.isEmpty())
|
||||
dump << " (" << (const char*)name.toUtf8() << ")";
|
||||
w = w->parentWidget();
|
||||
if (w)
|
||||
dump << " is child of\n";
|
||||
}
|
||||
std::string str = dump.str();
|
||||
Base::Console().Log("%s",str.c_str());
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().Log("Invalid recipient and/or event in GUIApplication::notify\n");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
void commitData(QSessionManager &manager)
|
||||
{
|
||||
if (manager.allowsInteraction()) {
|
||||
if (!Gui::getMainWindow()->close()) {
|
||||
// cancel the shutdown
|
||||
manager.release();
|
||||
manager.cancel();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// no user interaction allowed, thus close all documents and
|
||||
// the main window
|
||||
App::GetApplication().closeAllDocuments();
|
||||
Gui::getMainWindow()->close();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void Application::runApplication(void)
|
||||
{
|
||||
// A new QApplication
|
||||
|
||||
Reference in New Issue
Block a user