Avoid crashes when some EditorState in Editor::onProcessMessage() cannot lock the document

This commit is contained in:
David Capello 2015-04-15 09:58:41 -03:00
parent b4d97a4d35
commit 66c5f76146
2 changed files with 18 additions and 2 deletions

View File

@ -155,7 +155,7 @@ void Console::printf(const char* format, ...)
void Console::showException(const std::exception& e)
{
Console console;
console.printf("A problem has occurred.\n\nDetails:\n%s", e.what());
console.printf("A problem has occurred.\n\nDetails:\n%s\n", e.what());
}
} // namespace app

View File

@ -14,6 +14,7 @@
#include "app/app.h"
#include "app/app_menus.h"
#include "app/commands/commands.h"
#include "app/console.h"
#include "app/document_access.h"
#include "app/modules/editors.h"
#include "app/modules/palettes.h"
@ -37,6 +38,8 @@
#include "ui/system.h"
#include "ui/view.h"
#include <typeinfo>
namespace app {
using namespace ui;
@ -132,7 +135,20 @@ protected:
}
break;
}
return Editor::onProcessMessage(msg);
try {
return Editor::onProcessMessage(msg);
}
catch (const LockedDocumentException& ex) {
Console console;
Console::showException(ex);
console.printf("\nInternal details:\n"
"- Message type: %d\n"
"- Editor state: %s\n",
msg->type(),
getState() ? typeid(*getState().get()).name(): "None");
return false;
}
}
private: