Convert some dynamic casts to static casts
There is no null check after these casts so if they fail they would generate a NullReferenceException. By changing them to static casts we would get a InvalidCastException which are much less misleading.
This commit is contained in:
parent
b2fb84d14b
commit
8b998861e1
3 changed files with 4 additions and 4 deletions
|
@ -81,7 +81,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
VMCodeType CodeType {
|
VMCodeType CodeType {
|
||||||
get {
|
get {
|
||||||
if (!(container_type as ObjectBase).CanGenerateClassStruct || force_glue_generation) {
|
if (!((ObjectBase)container_type).CanGenerateClassStruct || force_glue_generation) {
|
||||||
if (BlockGlue)
|
if (BlockGlue)
|
||||||
return VMCodeType.None;
|
return VMCodeType.None;
|
||||||
else
|
else
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace GLib {
|
||||||
else if (reference is GLib.Object)
|
else if (reference is GLib.Object)
|
||||||
return reference as GLib.Object;
|
return reference as GLib.Object;
|
||||||
|
|
||||||
WeakReference weak = reference as WeakReference;
|
WeakReference weak = (WeakReference)reference;
|
||||||
return weak.Target as GLib.Object;
|
return weak.Target as GLib.Object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ namespace GLib {
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
GCHandle gch = (GCHandle) data;
|
GCHandle gch = (GCHandle) data;
|
||||||
ToggleRef tref = gch.Target as ToggleRef;
|
ToggleRef tref = (ToggleRef)gch.Target;
|
||||||
tref.Toggle (is_last_ref);
|
tref.Toggle (is_last_ref);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ExceptionManager.RaiseUnhandledException (e, false);
|
ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
|
|
@ -534,7 +534,7 @@ namespace GLib {
|
||||||
if(value is GLib.Object)
|
if(value is GLib.Object)
|
||||||
g_value_set_object (ref this, (value as GLib.Object).Handle);
|
g_value_set_object (ref this, (value as GLib.Object).Handle);
|
||||||
else
|
else
|
||||||
g_value_set_object (ref this, (value as GLib.GInterfaceAdapter).Handle);
|
g_value_set_object (ref this, ((GInterfaceAdapter)value).Handle);
|
||||||
else if (GType.Is (type, GType.Boxed)) {
|
else if (GType.Is (type, GType.Boxed)) {
|
||||||
if (value is IWrapper) {
|
if (value is IWrapper) {
|
||||||
g_value_set_boxed (ref this, ((IWrapper)value).Handle);
|
g_value_set_boxed (ref this, ((IWrapper)value).Handle);
|
||||||
|
|
Loading…
Add table
Reference in a new issue