handle string form of number passed as hwnd
authorTony Cook <tony@develop-help.com>
Mon, 18 Oct 2010 10:02:30 +0000 (10:02 +0000)
committerTony Cook <tony@develop-help.com>
Mon, 18 Oct 2010 10:02:30 +0000 (10:02 +0000)
svwin32.c

index f992793784ed7532811121ca29da6a16f88a1c21..8581ece48e519431c7e77b25b41b5b5e041da5fd 100644 (file)
--- a/svwin32.c
+++ b/svwin32.c
@@ -4,6 +4,9 @@ SSHWND
 hwnd_from_sv(pTHX_ SV *sv) {
   SvGETMAGIC(sv);
 
+  if (!SvOK(sv)) {
+    return 0;
+  }
   if (SvPOK(sv)) {
     STRLEN len;
     char const *p = SvPV_nomg(sv, len);
@@ -11,9 +14,6 @@ hwnd_from_sv(pTHX_ SV *sv) {
     if (len == 6 && strEQ(p, "active")) {
       return (SSHWND)GetForegroundWindow();
     }
-    else {
-      return (SSHWND)NULL;
-    }
   }
 
   return SvUV_nomg(sv);