summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Bosveld <Joel.Bosveld@gmail.com>2009-02-26 20:36:51 +0900
committerDennis Kasprzyk <onestone@compiz-fusion.org>2009-02-27 14:53:39 +0100
commit5f066e015766bbc227944ccf491873b92ea16c36 (patch)
treeaab1079abe5e16a2a9f826b884f72c48d01e3cd7
parentaefdd9eca8fe275bad5fa24f231b5acbe5fdfb60 (diff)
Warn if attempting to get wrong type from CompOption::Valuecompiz++
-rw-r--r--src/option.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/option.cpp b/src/option.cpp
index 7f8d9a59..cc32bf82 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -190,7 +190,10 @@ bool
CompOption::Value::b ()
{
if (priv->type != CompOption::TypeBool)
+ {
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a bool");
return false;
+ }
return priv->value.b;
}
@@ -198,7 +201,10 @@ int
CompOption::Value::i ()
{
if (priv->type != CompOption::TypeInt)
+ {
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not an int");
return 0;
+ }
return priv->value.i;
}
@@ -206,7 +212,10 @@ float
CompOption::Value::f ()
{
if (priv->type != CompOption::TypeFloat)
+ {
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a float");
return 0.0;
+ }
return priv->value.f;
}
@@ -216,37 +225,54 @@ unsigned short*
CompOption::Value::c ()
{
if (priv->type != CompOption::TypeColor)
+ {
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a color");
return reinterpret_cast<unsigned short *> (&defaultColor);
+ }
return priv->value.c;
}
CompString
CompOption::Value::s ()
{
+ if (priv->type != CompOption::TypeString)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a string");
return priv->string;
}
CompMatch &
CompOption::Value::match ()
{
+ if (priv->type != CompOption::TypeMatch)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a match");
return priv->match;
}
CompAction &
CompOption::Value::action ()
{
+ if (priv->type != CompOption::TypeAction &&
+ priv->type != CompOption::TypeKey &&
+ priv->type != CompOption::TypeButton &&
+ priv->type != CompOption::TypeEdge &&
+ priv->type != CompOption::TypeBell)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not an action");
return priv->action;
}
CompOption::Type
CompOption::Value::listType ()
{
+ if (priv->type != CompOption::TypeList)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a list");
return priv->listType;
}
CompOption::Value::Vector &
CompOption::Value::list ()
{
+ if (priv->type != CompOption::TypeList)
+ compLogMessage("core", CompLogLevelWarn, "CompOption::Value not a list");
return priv->list;
}