git://gitweb.devoid-pointer.net
/
FFBChecker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
99ef45a
)
Safely cast FFBEffect& to FFBPeriodicEffect& in operator==
author
Michal Malý
<madcatxster@prifuk.cz>
Wed, 4 Dec 2013 16:53:15 +0000
(17:53 +0100)
committer
Michal Malý
<madcatxster@prifuk.cz>
Wed, 4 Dec 2013 16:53:15 +0000
(17:53 +0100)
ffbperiodiceffect.cpp
patch
|
blob
|
blame
|
history
diff --git
a/ffbperiodiceffect.cpp
b/ffbperiodiceffect.cpp
index 2099debf83431ff4b4e53c3651035476a3deaa60..62898dfdbb9452e859cab9ff5452e4a64e7592bc 100644
(file)
--- 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<const FFBPeriodicEffect&>(other).m_params->waveform;
+ else {
+ try {
+ const FFBPeriodicEffect& eff = dynamic_cast<const FFBPeriodicEffect&>(other);
+ return this->m_params->waveform == eff.m_params->waveform;
+ } catch(std::bad_cast&) {
+ return false;
+ }
+ }
}
bool FFBPeriodicEffect::operator!=(const FFBEffect& other) const