From 40e7f607f5d3dd73fcd714acc3cd7d73e06d9188 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 22 Nov 2021 11:38:40 -0500 Subject: [PATCH] If no protocol defined, fall back to the name of the Control --- scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm index da3a56373..5646fb897 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Monitor.pm @@ -326,17 +326,23 @@ sub resumeMotionDetection { sub Control { my $self = shift; - if ( ! exists $$self{Control}) { + if (!exists $$self{Control}) { if ($$self{ControlId}) { require ZoneMinder::Control; my $Control = ZoneMinder::Control->find_one(Id=>$$self{ControlId}); if ($Control) { + my $Protocol = $$Control{Protocol}; + + if (!$Protocol) { + Error("No protocol set in control $$Control{Id}, trying Name $$Control{Name}"); + $Protocol = $$Control{Name}; + } require Module::Load::Conditional; - if (!Module::Load::Conditional::can_load(modules => {'ZoneMinder::Control::'.$$Control{Protocol} => undef})) { - Error("Can't load ZoneMinder::Control::$$Control{Protocol}\n$Module::Load::Conditional::ERROR"); + if (!Module::Load::Conditional::can_load(modules => {'ZoneMinder::Control::'.$Protocol => undef})) { + Error("Can't load ZoneMinder::Control::$Protocol\n$Module::Load::Conditional::ERROR"); return undef; } - bless $Control, 'ZoneMinder::Control::'.$$Control{Protocol}; + bless $Control, 'ZoneMinder::Control::'.$Protocol; $$Control{MonitorId} = $$self{Id}; $$self{Control} = $Control; } else {