Fixes for the Deselect() bug in BListView (at least I think this is a bug):
When the BListView is not attached to any window Deselect() does not work. So, if you remove an item that is selected the BListView's selection index is not updated and thus it results in a crash when it is attached again. This happens when you use a BTabView and change the information of the BListView while its tab is inactive. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7070 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
527eb29edb
commit
1e695afb41
@ -182,9 +182,14 @@ DialUpView::MessageReceived(BMessage *message)
|
||||
} break;
|
||||
|
||||
case MSG_DELETE_CURRENT: {
|
||||
// TODO: remove file from disk
|
||||
|
||||
fInterfaceMenu->RemoveItem(fCurrentItem);
|
||||
BDirectory settings, profile;
|
||||
GetPPPDirectories(&settings, &profile);
|
||||
BEntry entry;
|
||||
settings.FindEntry(fCurrentItem->Label(), &entry);
|
||||
entry.Remove();
|
||||
profile.FindEntry(fCurrentItem->Label(), &entry);
|
||||
entry.Remove();
|
||||
delete fCurrentItem;
|
||||
fCurrentItem = NULL;
|
||||
|
||||
|
@ -75,8 +75,7 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
fSettings = settings;
|
||||
fProfile = profile;
|
||||
if(!settings || !profile || isNew) {
|
||||
if(fIPCPWindow)
|
||||
fIPCPWindow->Reload();
|
||||
fIPCPWindow->Reload();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -148,6 +147,8 @@ IPCPAddon::LoadSettings(BMessage *settings, BMessage *profile, bool isNew)
|
||||
protocol.AddBool(MDSU_VALID, true);
|
||||
fProfile->ReplaceMessage(MDSU_PARAMETERS, protocolIndex, &protocol);
|
||||
|
||||
fIPCPWindow->Reload();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -295,9 +295,10 @@ ProtocolsView::Reload()
|
||||
DialUpAddon *protocol;
|
||||
for(int32 index = 0; Addon()->Settings()->FindPointer(PROTOCOLS_TAB_PROTOCOLS,
|
||||
index, reinterpret_cast<void**>(&protocol)) == B_OK; index++)
|
||||
RegisterProtocol(protocol);
|
||||
RegisterProtocol(protocol, false);
|
||||
|
||||
fListView->Select(0);
|
||||
// XXX: unfortunately, this does not work when the BListView is detached
|
||||
|
||||
UpdateButtons();
|
||||
}
|
||||
@ -311,6 +312,21 @@ ProtocolsView::AttachedToWindow()
|
||||
fAddButton->SetTarget(this);
|
||||
fRemoveButton->SetTarget(this);
|
||||
fPreferencesButton->SetTarget(this);
|
||||
|
||||
// XXX: a workaround for the bug in BListView that causes Select() only to work
|
||||
// when it is attached to a window
|
||||
if(fListView->CurrentSelection() < 0)
|
||||
fListView->Select(0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ProtocolsView::DetachedFromWindow()
|
||||
{
|
||||
// XXX: Is this a bug in BeOS? While BListView is detached the index for the
|
||||
// currently selected item does not get updated when it is removed.
|
||||
// Workaround: call DeselectAll() before it gets detached
|
||||
fListView->DeselectAll();
|
||||
}
|
||||
|
||||
|
||||
@ -383,7 +399,7 @@ ProtocolsView::HasProtocol(const BString& moduleName) const
|
||||
|
||||
|
||||
int32
|
||||
ProtocolsView::RegisterProtocol(const DialUpAddon *protocol)
|
||||
ProtocolsView::RegisterProtocol(const DialUpAddon *protocol, bool reload = true)
|
||||
{
|
||||
if(!protocol)
|
||||
return -1;
|
||||
@ -394,7 +410,7 @@ ProtocolsView::RegisterProtocol(const DialUpAddon *protocol)
|
||||
item = fProtocolsMenu->ItemAt(index);
|
||||
if(item && item->Message()->FindPointer("Addon",
|
||||
reinterpret_cast<void**>(&addon)) == B_OK && addon == protocol)
|
||||
return RegisterProtocol(index);
|
||||
return RegisterProtocol(index, reload);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -402,7 +418,7 @@ ProtocolsView::RegisterProtocol(const DialUpAddon *protocol)
|
||||
|
||||
|
||||
int32
|
||||
ProtocolsView::RegisterProtocol(int32 index)
|
||||
ProtocolsView::RegisterProtocol(int32 index, bool reload = true)
|
||||
{
|
||||
DialUpAddon *addon;
|
||||
BMenuItem *remove = fProtocolsMenu->ItemAt(index);
|
||||
@ -418,7 +434,8 @@ ProtocolsView::RegisterProtocol(int32 index)
|
||||
fProtocolsMenu->RemoveItem(remove);
|
||||
delete remove;
|
||||
|
||||
addon->LoadSettings(Addon()->Settings(), Addon()->Profile(), true);
|
||||
addon->LoadSettings(Addon()->Settings(), Addon()->Profile(), reload);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ class ProtocolsView : public BView {
|
||||
bool HasTemporaryProfile() const;
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
|
||||
int32 CountProtocols() const
|
||||
@ -80,8 +81,8 @@ class ProtocolsView : public BView {
|
||||
bool HasProtocol(const BString& moduleName) const;
|
||||
|
||||
private:
|
||||
int32 RegisterProtocol(const DialUpAddon *protocol);
|
||||
int32 RegisterProtocol(int32 index);
|
||||
int32 RegisterProtocol(const DialUpAddon *protocol, bool reload = true);
|
||||
int32 RegisterProtocol(int32 index, bool reload = true);
|
||||
// moves the protocol from the pop-up menu to the list view
|
||||
void UnregisterProtocol(int32 index);
|
||||
// moves the protocol from the list view to the pop-up menu
|
||||
|
@ -3,11 +3,11 @@ Short-term TODOs:
|
||||
- add "Extras" tab for changing dial-behaviour (auto-redial, dial-on-demand, etc.)
|
||||
- add "Revert Changes" button
|
||||
- load add-ons
|
||||
- write IP (IPCP) protocol add-on
|
||||
- move DEVNOTES into a doxygen file and document the rest of the API
|
||||
- use dynamic window positioning based on screen size instead of static coordinates
|
||||
- really delete interface description files when removing an interface
|
||||
- open dialog asking for interface name when creating a new interface
|
||||
- IPCP: check for incorrect settings (only IP addresses should be entered)
|
||||
|
||||
Long-term TODOs:
|
||||
- (maybe) allow selecting multiple authenticators (in expert-mode)
|
||||
|
Loading…
Reference in New Issue
Block a user