Author: abock
Date: 2006-07-18 11:12:54 -0400 (Tue, 18 Jul 2006)
New Revision: 62707

Modified:
   trunk/hal-sharp/ChangeLog
   trunk/hal-sharp/src/HalDevice.cs
Log:
2006-07-18  Aaron Bockover  <[EMAIL PROTECTED]>

    * src/HalDevice.cs: Added null checks for Hal.Context to prevent
    crashing in places



Modified: trunk/hal-sharp/ChangeLog
===================================================================
--- trunk/hal-sharp/ChangeLog   2006-07-18 15:06:12 UTC (rev 62706)
+++ trunk/hal-sharp/ChangeLog   2006-07-18 15:12:54 UTC (rev 62707)
@@ -1,3 +1,8 @@
+2006-07-18  Aaron Bockover  <[EMAIL PROTECTED]>
+
+       * src/HalDevice.cs: Added null checks for Hal.Context to prevent
+       crashing in places
+
 2006-01-13  Eric Butler  <[EMAIL PROTECTED]>
 
        * configure.ac: Generate makefile in doc directory, check for monodoc

Modified: trunk/hal-sharp/src/HalDevice.cs
===================================================================
--- trunk/hal-sharp/src/HalDevice.cs    2006-07-18 15:06:12 UTC (rev 62706)
+++ trunk/hal-sharp/src/HalDevice.cs    2006-07-18 15:12:54 UTC (rev 62707)
@@ -45,6 +45,10 @@
         
         public Device(Context ctx, string udi)
         {
+                       if(ctx == null) {
+                               throw new ApplicationException("Cannot create 
HAL device; context is null");
+                       }
+
             this.ctx = ctx;
             this.udi = udi;
         }
@@ -258,7 +262,7 @@
         
         public static bool DeviceExists(Context ctx, string udi)
         {
-            return Unmanaged.libhal_device_exists(ctx.Raw, udi, IntPtr.Zero);
+            return ctx == null ? false : 
Unmanaged.libhal_device_exists(ctx.Raw, udi, IntPtr.Zero);
         }
         
         public static string [] FindUdis(Context ctx, FindBy findMethod, 
string key, string query)
@@ -266,7 +270,11 @@
             IntPtr ptr;
             string [] deviceUdis;
             int device_count;
-            
+
+                       if(ctx == null) {
+                               return null;
+                       }
+
             switch(findMethod) {
                 case FindBy.StringMatch:
                     ptr = Unmanaged.libhal_manager_find_device_string_match(
@@ -291,6 +299,10 @@
         
         public static Device [] UdisToDevices(Context ctx, string [] udis)
         {
+                       if(ctx == null) {
+                               return null;
+                       }
+               
             Device [] devices = new Device[udis.Length];
             
             for(int i = 0; i < udis.Length; i++) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to