From 5777ede3605d46620e789c6a9aa4cb511808d70a Mon Sep 17 00:00:00 2001
From: Yorik van Havre <yorik@uncreated.net>
Date: Sat, 20 Aug 2016 12:36:48 -0300
Subject: [PATCH] Workaround for isVisible error in macro

---
 PartsLibrary.FCMacro | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/PartsLibrary.FCMacro b/PartsLibrary.FCMacro
index c77f60a1..253f73bc 100644
--- a/PartsLibrary.FCMacro
+++ b/PartsLibrary.FCMacro
@@ -435,10 +435,15 @@ if QtCore.QDir(LIBRARYPATH).exists():
     m = FreeCADGui.getMainWindow()
     w = m.findChild(QtGui.QDockWidget,"PartsLibrary")
     if w:
-        if w.isVisible():
-            w.hide()
+        if hasattr(w,"isVisible"):
+            if w.isVisible():
+                w.hide()
+            else:
+                w.show()
         else:
-            w.show()
+            # something went wrong with our widget... Recreate it
+            del w
+            m.addDockWidget(QtCore.Qt.RightDockWidgetArea,ExpDockWidget(LIBRARYPATH))
     else:
         m.addDockWidget(QtCore.Qt.RightDockWidgetArea,ExpDockWidget(LIBRARYPATH))
 else: