Shortcut catcher: crash fix, better monitoring of setting file
* Fix bad memory cleaning I introduced in earlier commit, causing crash in add-on * Upon detecting the deletion of setting file, shortcuts weren't properly removed * The node monitoring would not filter the right file on every case Thanks Diver.
This commit is contained in:
@@ -230,9 +230,9 @@ KeyCommandMap::MessageReceived(BMessage* msg)
|
|||||||
dev_t device;
|
dev_t device;
|
||||||
ino_t node;
|
ino_t node;
|
||||||
if (msg->FindInt32("device", &device) != B_OK
|
if (msg->FindInt32("device", &device) != B_OK
|
||||||
&& msg->FindInt64("node", &node) != B_OK
|
|| msg->FindInt64("node", &node) != B_OK
|
||||||
&& device != fNodeRef.device
|
|| device != fNodeRef.device
|
||||||
&& node != fNodeRef.node)
|
|| node != fNodeRef.node)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,12 +240,9 @@ KeyCommandMap::MessageReceived(BMessage* msg)
|
|||||||
{
|
{
|
||||||
BMessage fileMsg;
|
BMessage fileMsg;
|
||||||
BFile file(fFileName, B_READ_ONLY);
|
BFile file(fFileName, B_READ_ONLY);
|
||||||
|
BList* newList = new BList;
|
||||||
|
BList* oldList = NULL;
|
||||||
if (file.InitCheck() == B_OK && fileMsg.Unflatten(&file) == B_OK) {
|
if (file.InitCheck() == B_OK && fileMsg.Unflatten(&file) == B_OK) {
|
||||||
BList* newList = new BList;
|
|
||||||
|
|
||||||
// whatever this is set to will be deleted below.
|
|
||||||
// defaults to no deletion
|
|
||||||
BList* oldList = NULL;
|
|
||||||
|
|
||||||
file.GetNodeRef(&fNodeRef);
|
file.GetNodeRef(&fNodeRef);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -261,7 +258,7 @@ KeyCommandMap::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
// Leave handling of add-ons shortcuts to Tracker
|
// Leave handling of add-ons shortcuts to Tracker
|
||||||
BString command;
|
BString command;
|
||||||
if (actMsg.FindString("largv", &command) == B_OK) {
|
if (msg.FindString("command", &command) == B_OK) {
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_SYSTEM_ADDONS_DIRECTORY, &path) == B_OK) {
|
if (find_directory(B_SYSTEM_ADDONS_DIRECTORY, &path) == B_OK) {
|
||||||
path.Append("Tracker/");
|
path.Append("Tracker/");
|
||||||
@@ -295,18 +292,20 @@ KeyCommandMap::MessageReceived(BMessage* msg)
|
|||||||
delete archive;
|
delete archive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
if (fSyncSpecs.Lock()) {
|
fNodeRef.device = -1;
|
||||||
// swap in the new list
|
fNodeRef.node = -1;
|
||||||
oldList = fSpecs;
|
|
||||||
fSpecs = newList;
|
|
||||||
fSyncSpecs.Unlock();
|
|
||||||
} else {
|
|
||||||
// wtf? This shouldn't happen...
|
|
||||||
oldList = newList; // but clean up if it does
|
|
||||||
}
|
|
||||||
_DeleteHKSList(oldList);
|
|
||||||
}
|
}
|
||||||
|
if (fSyncSpecs.Lock()) {
|
||||||
|
// swap in the new list
|
||||||
|
oldList = fSpecs;
|
||||||
|
fSpecs = newList;
|
||||||
|
fSyncSpecs.Unlock();
|
||||||
|
} else {
|
||||||
|
// wtf? This shouldn't happen...
|
||||||
|
oldList = newList; // but clean up if it does
|
||||||
|
}
|
||||||
|
_DeleteHKSList(oldList);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -320,7 +319,7 @@ KeyCommandMap::_DeleteHKSList(BList* l)
|
|||||||
if (l != NULL) {
|
if (l != NULL) {
|
||||||
int num = l->CountItems();
|
int num = l->CountItems();
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
delete ((hks*) l->ItemAt(0));
|
delete ((hks*) l->ItemAt(i));
|
||||||
delete l;
|
delete l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user