launch_daemon: Fixed NULL events.

* Also, events now can actually be NULL when there is an empty "on"
  field in the settings.
* This fixes a crash, too.
This commit is contained in:
Axel Dörfler
2015-07-22 20:45:15 +02:00
parent f2afa73344
commit f6647de349
2 changed files with 10 additions and 3 deletions
+4 -2
View File
@@ -20,7 +20,8 @@
BaseJob::BaseJob(const char* name)
:
BJob(name),
fCondition(NULL)
fCondition(NULL),
fEvent(NULL)
{
}
@@ -87,7 +88,8 @@ void
BaseJob::SetEvent(::Event* event)
{
fEvent = event;
event->SetOwner(this);
if (event != NULL)
event->SetOwner(this);
}
+6 -1
View File
@@ -92,8 +92,12 @@ static Event*
create_event(Event* parent, const char* name, const BMessenger* target,
const BMessage& args)
{
if (strcmp(name, "or") == 0)
if (strcmp(name, "or") == 0) {
if (args.IsEmpty())
return NULL;
return new OrEvent(parent, target, args);
}
if (strcmp(name, "demand") == 0)
return new DemandEvent(parent);
@@ -356,6 +360,7 @@ FileCreatedEvent::FileCreatedEvent(Event* parent, const BMessage& args)
status_t
FileCreatedEvent::Register(EventRegistrator& registrator) const
{
// TODO: implement!
return B_ERROR;
}