Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Prevent a crash when refreshing a node which has a child with an open…
Browse files Browse the repository at this point in the history
… dialogue
  • Loading branch information
dhirajchawla authored and dpage committed Nov 8, 2012
1 parent 027aec1 commit 90b4578
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -37,6 +37,8 @@ Changes

Date Dev Ver Change details
---------- --- ------ --------------
2012-11-08 DP 1.16.1 Prevent a crash when refreshing a node which has a
child with an open dialogue [Dhiraj Chawla]
2012-11-08 DP 1.16.1 Fix dropping/renaming of indexes [Akshay Joshi]
2012-11-08 DP 1.16.1 Avoid updating the GQB model on every key press in
the query tool [Dhiraj Chawla]
Expand Down
17 changes: 16 additions & 1 deletion pgadmin/frm/events.cpp
Expand Up @@ -429,11 +429,26 @@ void frmMain::execSelChange(wxTreeItemId item, bool currentNode)

if (settingRefreshOnClick == REFRESH_OBJECT_ONLY )
{
//We can not update the schema, because it would cause an update to the entire tree.
// We can not update the schema, because it would cause an update to the entire tree.
if (currentObject->GetTypeName() != wxT("Schema"))
{
wxTreeItemId currentItem = currentObject->GetId();

// Do not refresh and instead bail out if dialog of the currently selected
// node or it's child node is open, as refresh would delete this node's object
// and could cause a 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);

Expand Down
10 changes: 10 additions & 0 deletions pgadmin/schema/pgObject.cpp
Expand Up @@ -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 collapsed the node again. This case is handled in the
// check below
else if (subChildItem && browser->GetItemData(subChildItem))
{
if (CheckOpenDialogs(browser, child))
return true;
}

child = browser->GetNextChild(node, cookie);
}
Expand Down

0 comments on commit 90b4578

Please sign in to comment.