From 0d1fc35b202e2267301a15d6f43cc98efd2733e1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 4 Jan 2015 13:26:34 +0100 Subject: [PATCH] + add try/catch block to notify() method --- src/Gui/Application.cpp | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index e5529b615..600d1a6fa 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1554,24 +1554,29 @@ public: // Print some more information to the log file (if active) to ease bug fixing if (receiver && event) { - 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(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"; + 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(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()); } - 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"); } }