Fixed stale config view pointer in E-mail.
* When removing an account (all accounts would be removed when the app was quit), AccountItem::ConfigPanel() was used to remove views. * However, this member was only set when a new view was created, never when it was removed. This could cause a crash on quit. * Removed that member completely, as it was unnecessary, anyway. * Fixed naming of AccountItem getters to lose their Get* prefix.
This commit is contained in:
@@ -84,8 +84,7 @@ AccountItem::AccountItem(const char* label, BMailAccountSettings* account,
|
|||||||
:
|
:
|
||||||
BStringItem(label),
|
BStringItem(label),
|
||||||
fAccount(account),
|
fAccount(account),
|
||||||
fType(type),
|
fType(type)
|
||||||
fConfigPanel(NULL)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +95,7 @@ AccountItem::Update(BView* owner, const BFont* font)
|
|||||||
if (fType == ACCOUNT_ITEM)
|
if (fType == ACCOUNT_ITEM)
|
||||||
font = be_bold_font;
|
font = be_bold_font;
|
||||||
|
|
||||||
BStringItem::Update(owner,font);
|
BStringItem::Update(owner, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -112,20 +111,6 @@ AccountItem::DrawItem(BView* owner, BRect rect, bool complete)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AccountItem::SetConfigPanel(BView* panel)
|
|
||||||
{
|
|
||||||
fConfigPanel = panel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BView*
|
|
||||||
AccountItem::ConfigPanel()
|
|
||||||
{
|
|
||||||
return fConfigPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -523,7 +508,7 @@ ConfigWindow::MessageReceived(BMessage *msg)
|
|||||||
int32 index = msg->FindInt32("index");
|
int32 index = msg->FindInt32("index");
|
||||||
AccountItem* clickedItem = dynamic_cast<AccountItem*>(
|
AccountItem* clickedItem = dynamic_cast<AccountItem*>(
|
||||||
fAccountsListView->ItemAt(index));
|
fAccountsListView->ItemAt(index));
|
||||||
if (clickedItem == NULL || clickedItem->GetType() != ACCOUNT_ITEM)
|
if (clickedItem == NULL || clickedItem->Type() != ACCOUNT_ITEM)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BPopUpMenu rightClickMenu("accounts", false, false);
|
BPopUpMenu rightClickMenu("accounts", false, false);
|
||||||
@@ -535,7 +520,7 @@ ConfigWindow::MessageReceived(BMessage *msg)
|
|||||||
rightClickMenu.AddItem(inMenuItem);
|
rightClickMenu.AddItem(inMenuItem);
|
||||||
rightClickMenu.AddItem(outMenuItem);
|
rightClickMenu.AddItem(outMenuItem);
|
||||||
|
|
||||||
BMailAccountSettings* settings = clickedItem->GetAccount();
|
BMailAccountSettings* settings = clickedItem->Account();
|
||||||
if (settings->IsInboundEnabled())
|
if (settings->IsInboundEnabled())
|
||||||
inMenuItem->SetMarked(true);
|
inMenuItem->SetMarked(true);
|
||||||
if (settings->IsOutboundEnabled())
|
if (settings->IsOutboundEnabled())
|
||||||
@@ -603,7 +588,7 @@ ConfigWindow::MessageReceived(BMessage *msg)
|
|||||||
AccountItem *item = (AccountItem *)fAccountsListView->ItemAt(
|
AccountItem *item = (AccountItem *)fAccountsListView->ItemAt(
|
||||||
index);
|
index);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
_RemoveAccount(item->GetAccount());
|
_RemoveAccount(item->Account());
|
||||||
_ReplaceConfigView(_BuildHowToView());
|
_ReplaceConfigView(_BuildHowToView());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -666,8 +651,8 @@ ConfigWindow::AccountUpdated(BMailAccountSettings* account)
|
|||||||
|
|
||||||
for (int i = 0; i < fAccountsListView->CountItems(); i++) {
|
for (int i = 0; i < fAccountsListView->CountItems(); i++) {
|
||||||
AccountItem* item = (AccountItem*)fAccountsListView->ItemAt(i);
|
AccountItem* item = (AccountItem*)fAccountsListView->ItemAt(i);
|
||||||
if (item->GetAccount() == account) {
|
if (item->Account() == account) {
|
||||||
if (item->GetType() == ACCOUNT_ITEM) {
|
if (item->Type() == ACCOUNT_ITEM) {
|
||||||
item->SetText(account->Name());
|
item->SetText(account->Name());
|
||||||
fAccountsListView->Invalidate();
|
fAccountsListView->Invalidate();
|
||||||
}
|
}
|
||||||
@@ -785,13 +770,16 @@ ConfigWindow::_RemoveAccount(BMailAccountSettings* account)
|
|||||||
void
|
void
|
||||||
ConfigWindow::_RemoveAccountFromListView(BMailAccountSettings* account)
|
ConfigWindow::_RemoveAccountFromListView(BMailAccountSettings* account)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < fAccountsListView->CountItems(); i++) {
|
if (fLastSelectedAccount == account) {
|
||||||
|
_ReplaceConfigView(_BuildHowToView());
|
||||||
|
fLastSelectedAccount = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = fAccountsListView->CountItems(); i-- > 0;) {
|
||||||
AccountItem* item = (AccountItem*)fAccountsListView->ItemAt(i);
|
AccountItem* item = (AccountItem*)fAccountsListView->ItemAt(i);
|
||||||
if (item->GetAccount() == account) {
|
if (item->Account() == account) {
|
||||||
fAccountsListView->RemoveItem(i);
|
fAccountsListView->RemoveItem(i);
|
||||||
fConfigView->RemoveChild(item->ConfigPanel());
|
|
||||||
delete item;
|
delete item;
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -802,11 +790,11 @@ ConfigWindow::_AccountSelected(AccountItem* item)
|
|||||||
{
|
{
|
||||||
AccountUpdated(fLastSelectedAccount);
|
AccountUpdated(fLastSelectedAccount);
|
||||||
|
|
||||||
BMailAccountSettings* account = item->GetAccount();
|
BMailAccountSettings* account = item->Account();
|
||||||
fLastSelectedAccount = account;
|
fLastSelectedAccount = account;
|
||||||
|
|
||||||
BView* view = NULL;
|
BView* view = NULL;
|
||||||
switch (item->GetType()) {
|
switch (item->Type()) {
|
||||||
case ACCOUNT_ITEM:
|
case ACCOUNT_ITEM:
|
||||||
view = new AccountConfigView(account);
|
view = new AccountConfigView(account);
|
||||||
break;
|
break;
|
||||||
@@ -825,8 +813,6 @@ ConfigWindow::_AccountSelected(AccountItem* item)
|
|||||||
view = new FiltersConfigView(*account);
|
view = new FiltersConfigView(*account);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (view != NULL)
|
|
||||||
item->SetConfigPanel(view);
|
|
||||||
|
|
||||||
_ReplaceConfigView(view);
|
_ReplaceConfigView(view);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,15 +43,12 @@ public:
|
|||||||
void Update(BView* owner, const BFont* font);
|
void Update(BView* owner, const BFont* font);
|
||||||
void DrawItem(BView* owner, BRect rect,
|
void DrawItem(BView* owner, BRect rect,
|
||||||
bool complete);
|
bool complete);
|
||||||
BMailAccountSettings* GetAccount() { return fAccount; }
|
BMailAccountSettings* Account() { return fAccount; }
|
||||||
item_types GetType() { return fType; }
|
item_types Type() { return fType; }
|
||||||
|
|
||||||
void SetConfigPanel(BView* panel);
|
|
||||||
BView* ConfigPanel();
|
|
||||||
private:
|
private:
|
||||||
BMailAccountSettings* fAccount;
|
BMailAccountSettings* fAccount;
|
||||||
item_types fType;
|
item_types fType;
|
||||||
BView* fConfigPanel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user