try and make error message a little more useful

Change-Id: I20070965dbf2632461fc74cc8a9795c7ddded269
This commit is contained in:
Caolán McNamara 2012-11-27 15:42:12 +00:00
parent 79c1b16a96
commit 6e1fba8a72

View file

@ -10,6 +10,7 @@
#ifndef _VCLBUILDER_HXX
#define _VCLBUILDER_HXX
#include <typeinfo>
#include <vcl/dllapi.h>
#include <vcl/window.hxx>
#include <xmlreader/xmlreader.hxx>
@ -150,6 +151,9 @@ public:
template <typename T> T* get(T*& ret, OString sID)
{
Window *w = get_by_name(sID);
SAL_WARN_IF(!w, "vcl.layout", "widget " << sID.getStr() << " not found in .ui");
SAL_WARN_IF(!dynamic_cast<T*>(w),
"vcl.layout", "widget " << sID.getStr() << " needs to have type " << typeid(T).name());
assert(w && dynamic_cast<T*>(w));
ret = static_cast<T*>(w);
return ret;
@ -158,6 +162,8 @@ public:
template <typename T /*=Window if we had c++11*/> T* get(OString sID)
{
Window *w = get_by_name(sID);
SAL_WARN_IF(w && !dynamic_cast<T*>(w),
"vcl.layout", "widget " << sID.getStr() << " needs to have type " << typeid(T).name());
assert(!w || dynamic_cast<T*>(w));
return static_cast<T*>(w);
}