diff --git a/pgadmin/dlg/dlgProperty.cpp b/pgadmin/dlg/dlgProperty.cpp index dead2d3..e348c82 100644 --- a/pgadmin/dlg/dlgProperty.cpp +++ b/pgadmin/dlg/dlgProperty.cpp @@ -793,6 +793,9 @@ void dlgProperty::ShowObject() // inherently get refreshed as well. Yay :-) if (owneritem) { + // Get the object node in case we need it later + wxTreeItemId objectnode = mainForm->GetBrowser()->GetItemParent(owneritem); + // Stash the selected items path wxString currentPath = mainForm->GetCurrentNodePath(); @@ -803,6 +806,35 @@ void dlgProperty::ShowObject() // Restore the previous selection... mainForm->SetCurrentNode(mainForm->GetBrowser()->GetRootItem(), currentPath); + + // If we couldn't restore the previous selection, it means that + // the object doesn't exist any more. Either it was dropped, or + // moved to another schema. + // If it is the latter, we need to refresh the Schemas node. + if (currentPath != mainForm->GetCurrentNodePath()) + { + if (objectnode.IsOk()) + { + // first parent is the objects' node + wxTreeItemId objectsnode = mainForm->GetBrowser()->GetItemParent(objectnode); + if (objectsnode.IsOk()) + { + // second parent is the schema's node + wxTreeItemId schemanode = mainForm->GetBrowser()->GetItemParent(objectsnode); + if (objectsnode.IsOk()) + { + // third parent is the schemas' node + wxTreeItemId schemasnode = mainForm->GetBrowser()->GetItemParent(schemanode); + if (objectsnode.IsOk()) + { + // we finally have the schemas' node, so we refresh it + pgObject *schemasnodeobj = mainForm->GetBrowser()->GetObject(schemasnode); + mainForm->Refresh(schemasnodeobj); + } + } + } + } + } } else if (data) {