From patchwork Mon Jan 20 00:24:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2695 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D8E31607F4 for ; Mon, 20 Jan 2020 01:24:45 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 420BE529 for ; Mon, 20 Jan 2020 01:24:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1579479885; bh=381ksBZRWm51n+Ev4Slj5OQOiaQATFkU/Qfy81qRFG4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=i9r5lGEdnX62A3aV/AuF31JeMoxmONaFwqdNJUFTjYkMC+fXSgflMFLgDn2Ptbe+S 4gLJiGC7VOrI/K2mhw+7XI6ECuIw+81S8Jnf5vuUk1qJ3G9aVHJtBr266UOHoM49XN EFaZLDR5ipFxZ8rDpupCgOXv6x4ZNaYGNSedLxs8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 20 Jan 2020 02:24:26 +0200 Message-Id: <20200120002437.6633-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200120002437.6633-1-laurent.pinchart@ideasonboard.com> References: <20200120002437.6633-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 08/19] test: signal: Add additional disconnection tests for Object X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jan 2020 00:24:47 -0000 Add two tests that exercise the Signal::disconnect(Object *) and Signal::disconnect() methods, to verify that they correctly remove the signal from the connected object's list of signals. This triggers an issue that was detected through manual code inspection, and is expected to crash or at least generate valgrind warnings. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- test/signal.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/signal.cpp b/test/signal.cpp index 0054ed5a380d..f83ceb05f091 100644 --- a/test/signal.cpp +++ b/test/signal.cpp @@ -220,6 +220,30 @@ protected: delete dynamicSignal; delete slotObject; + /* + * Test that signal manual disconnection from Object removes + * the signal for the object. This shall not generate any + * valgrind warning. + */ + dynamicSignal = new Signal<>(); + slotObject = new SlotObject(); + dynamicSignal->connect(slotObject, &SlotObject::slot); + dynamicSignal->disconnect(slotObject); + delete dynamicSignal; + delete slotObject; + + /* + * Test that signal manual disconnection from all slots removes + * the signal for the object. This shall not generate any + * valgrind warning. + */ + dynamicSignal = new Signal<>(); + slotObject = new SlotObject(); + dynamicSignal->connect(slotObject, &SlotObject::slot); + dynamicSignal->disconnect(); + delete dynamicSignal; + delete slotObject; + /* Exercise the Object slot code paths. */ slotObject = new SlotObject(); signalVoid_.connect(slotObject, &SlotObject::slot);