Don't crash if overridden wxDataViewModel::GetValue() throws

Don't let any exceptions propagate to GTK+ code as this results in an
immediate crash there, at least with GTK+ 3.14.5.
This commit is contained in:
Vadim Zeitlin
2016-03-22 19:32:06 +01:00
parent 1bbc44daff
commit d324bd2469

View File

@@ -26,6 +26,7 @@
#endif
#include "wx/datectrl.h"
#include "wx/except.h"
#include "wx/spinctrl.h"
#include "wx/choice.h"
#include "wx/imaglist.h"
@@ -818,6 +819,11 @@ wxDataViewRendererBase::PrepareForItem(const wxDataViewModel *model,
const wxDataViewItem& item,
unsigned column)
{
// This method is called by the native control, so we shouldn't allow
// exceptions to escape from it.
wxTRY
{
// Now check if we have a value and remember it for rendering it later.
// Notice that we do it even if it's null, as the cell should be empty then
// and not show the last used value.
@@ -849,6 +855,15 @@ wxDataViewRendererBase::PrepareForItem(const wxDataViewModel *model,
SetEnabled(enabled);
}
wxCATCH_ALL
(
// There is not much we can do about it here, just log it and don't
// show anything in this cell.
wxLogDebug("Retrieving the value from the model threw an exception");
SetValue(wxVariant());
)
return true;
}