From fca1b5bd9a2ec1761b0d9f34e886347d0677fbff Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sun, 21 Aug 2011 20:59:03 +0200 Subject: Don't spam with the "Unable to convert ... from nil" messages --- src/FbTk/Resource.hh | 10 +++++++--- src/Slit.cc | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh index b729ad4..e3e8cc1 100644 --- a/src/FbTk/Resource.hh +++ b/src/FbTk/Resource.hh @@ -257,9 +257,13 @@ public: virtual void setFromLua(lua::state &l) { try { - m_value = Traits::fromLua(l); - m_rm->resourceChanged(*this); - m_modified_sig.emit(m_value); + if(l.isnil(-1)) + setDefaultValue(); + else { + m_value = Traits::fromLua(l); + m_rm->resourceChanged(*this); + m_modified_sig.emit(m_value); + } } catch(ConversionError &e) { std::cerr << name() << ": " << e.what() << std::endl; diff --git a/src/Slit.cc b/src/Slit.cc index efb8793..6461798 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -153,8 +153,10 @@ void Slit::SlitClientsRes::setFromLua(lua::state &l) { SlitClients t; if(l.type(-1) != lua::TTABLE) { - std::cerr << "Cannot convert to a client list from lua type " - << l.type_name(l.type(-1)) << std::endl; + if(! l.isnil(-1)) { + std::cerr << "Cannot convert to a client list from lua type " + << l.type_name(l.type(-1)) << std::endl; + } return; } for(size_t i = 1; l.rawgeti(-1, i), !l.isnil(-1); l.pop(), ++i) { -- cgit v0.11.2