Commit 3efd419d authored by Nicholas Little's avatar Nicholas Little Committed by Andrés G. Aragoneses

Gio: protect call to event delegates in HardwareManager

Make Gio's HardwareManager class respect this concurrency rule
that is already a good practice held in other parts of the
codebase. (For a good explanation, you can check [1])

This commit also makes the event handling more consistent to
how it is done in other parts of this class (having two overloads
of the same method, with different parameter types).

[1] http://www.mono-project.com/Gendarme.Rules.Concurrency#ProtectCallToEventDelegatesRuleSigned-off-by: Andrés G. Aragoneses's avatarAndrés G. Aragoneses <knocte@gmail.com>
parent 21d90407
......@@ -56,15 +56,30 @@ namespace Banshee.Hardware.Gio
void HandleManagerDeviceRemoved (object o, MountArgs args)
{
if (DeviceRemoved != null) {
DeviceRemoved (this, new DeviceRemovedArgs (args.Device.Uuid));
}
HandleManagerDeviceRemoved (args.Device);
}
void HandleManagerDeviceAdded (IDevice device)
{
if (device != null && DeviceAdded != null) {
DeviceAdded (this, new DeviceAddedArgs (device));
if (device == null) {
return;
}
var handler = DeviceAdded;
if (handler != null) {
handler (this, new DeviceAddedArgs (device));
}
}
private void HandleManagerDeviceRemoved (IDevice device)
{
if (device == null) {
return;
}
var handler = DeviceRemoved;
if (handler != null) {
handler (this, new DeviceRemovedArgs (device.Uuid));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment