diff --git a/pgadmin/frm/events.cpp b/pgadmin/frm/events.cpp
index 150f3c1..66b7fa4 100644
--- a/pgadmin/frm/events.cpp
+++ b/pgadmin/frm/events.cpp
@@ -434,6 +434,21 @@ void frmMain::execSelChange(wxTreeItemId item, bool currentNode)
 				{
 					wxTreeItemId currentItem = currentObject->GetId();
 
+					// Do not refresh and bail out if dialog of the currently selected node or
+					// it's children node is open as refresh would delete this node's object
+					// and would cause crash
+					pgObject *obj = NULL;
+					if (currentItem)
+						obj = browser->GetObject(currentItem);
+
+					if (obj && obj->CheckOpenDialogs(browser, currentItem))
+					{
+						properties->Freeze();
+						setDisplay(currentObject, properties, sqlPane);
+						properties->Thaw();
+						refresh = true;
+						return;
+					}
 
 					pgObject *newData = currentObject->Refresh(browser, currentItem);
 
diff --git a/pgadmin/schema/pgObject.cpp b/pgadmin/schema/pgObject.cpp
index e222f50..433df80 100644
--- a/pgadmin/schema/pgObject.cpp
+++ b/pgadmin/schema/pgObject.cpp
@@ -1097,11 +1097,21 @@ bool pgObject::CheckOpenDialogs(ctlTree *browser, wxTreeItemId node)
 		if (obj && obj->GetWindowPtr())
 			return true;
 
+		wxTreeItemIdValue subCookie;
+		wxTreeItemId subChildItem = browser->GetFirstChild(child, subCookie);
 		if (browser->IsExpanded(child))
 		{
 			if (CheckOpenDialogs(browser, child))
 				return true;
 		}
+		// it may be the case the user might have expanded the node opened the
+		// dialog and then collapse the node again. This case handled in the
+		// below check
+		else if (subChildItem && browser->GetItemData(subChildItem))
+		{
+			if (CheckOpenDialogs(browser, child))
+				return true;
+		}
 
 		child = browser->GetNextChild(node, cookie);
 	}
