[banshee] SourceView: log errors in SetCellDataFunc to avoid crashing (bgo#683359)
- From: AndrÃs Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] SourceView: log errors in SetCellDataFunc to avoid crashing (bgo#683359)
- Date: Wed, 12 Sep 2012 18:34:32 +0000 (UTC)
commit d835de9ebc75bf937aa66d45909cb5eb119249e0
Author: Andres G. Aragoneses <knocte gmail com>
Date: Wed Sep 12 19:34:00 2012 +0100
SourceView: log errors in SetCellDataFunc to avoid crashing (bgo#683359)
There must be a tricky problem about model.GetValue() not returning
proper values the first times it is queried. It is an issue hard
to reproduce so this is not a proper fix, but just rather a call
to Log.Error to prevent crashing.
(Banshee is able to run normally after a few times this error
condition happens and gets logged, as tested by Andy Goar.)
Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>
.../Banshee.Sources.Gui/SourceView.cs | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
index 1870794..8b86739 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
@@ -134,7 +134,24 @@ namespace Banshee.Sources.Gui
throw new ArgumentNullException ("model");
}
- var type = (SourceModel.EntryType) model.GetValue (iter, (int)SourceModel.Columns.Type);
+ // be paranoid about the values returned from model.GetValue(), they may be null or have unexpected types, see bgo#683359
+ var obj_type = model.GetValue (iter, (int)SourceModel.Columns.Type);
+ if (obj_type == null || !(obj_type is SourceModel.EntryType)) {
+
+ var source = model.GetValue (iter, (int)SourceModel.Columns.Source) as Source;
+ var source_name = source == null ? "some source" : String.Format ("source {0}", source.Name);
+
+ Log.ErrorFormat (
+ "SourceView of {0} could not render its source column because its type value returned {1} from the iter",
+ source_name, obj_type == null ? "null" : String.Format ("an instance of {0}", obj_type.GetType ().FullName));
+
+ header_renderer.Visible = false;
+ source_renderer.Visible = false;
+
+ return;
+ }
+
+ var type = (SourceModel.EntryType) obj_type;
header_renderer.Visible = type == SourceModel.EntryType.Group;
source_renderer.Visible = type == SourceModel.EntryType.Source;
if (type == SourceModel.EntryType.Group) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]