From d5df35c05dadad1575d1ea80b98412a057854d50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Wed, 4 Dec 2013 17:53:15 +0100 Subject: [PATCH] Safely cast FFBEffect& to FFBPeriodicEffect& in operator== --- ffbperiodiceffect.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ffbperiodiceffect.cpp b/ffbperiodiceffect.cpp index 2099deb..62898df 100644 --- a/ffbperiodiceffect.cpp +++ b/ffbperiodiceffect.cpp @@ -115,8 +115,14 @@ bool FFBPeriodicEffect::operator==(const FFBEffect& other) const { if (this->type() != other.type()) return false; - else - return this->m_params->waveform == dynamic_cast(other).m_params->waveform; + else { + try { + const FFBPeriodicEffect& eff = dynamic_cast(other); + return this->m_params->waveform == eff.m_params->waveform; + } catch(std::bad_cast&) { + return false; + } + } } bool FFBPeriodicEffect::operator!=(const FFBEffect& other) const -- 2.43.5