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:
@@ -26,6 +26,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/datectrl.h"
|
#include "wx/datectrl.h"
|
||||||
|
#include "wx/except.h"
|
||||||
#include "wx/spinctrl.h"
|
#include "wx/spinctrl.h"
|
||||||
#include "wx/choice.h"
|
#include "wx/choice.h"
|
||||||
#include "wx/imaglist.h"
|
#include "wx/imaglist.h"
|
||||||
@@ -818,6 +819,11 @@ wxDataViewRendererBase::PrepareForItem(const wxDataViewModel *model,
|
|||||||
const wxDataViewItem& item,
|
const wxDataViewItem& item,
|
||||||
unsigned column)
|
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.
|
// 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
|
// Notice that we do it even if it's null, as the cell should be empty then
|
||||||
// and not show the last used value.
|
// and not show the last used value.
|
||||||
@@ -849,6 +855,15 @@ wxDataViewRendererBase::PrepareForItem(const wxDataViewModel *model,
|
|||||||
|
|
||||||
SetEnabled(enabled);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user