improve error proofness

This commit is contained in:
Syping 2018-08-23 17:02:12 +02:00
parent 53e8d9abe5
commit 115d384f88

View file

@ -293,7 +293,7 @@ int LuaEngine::luaDeletePointer_p(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL && ((QObject*)pointer)->inherits("QObject")) {
if (pointer != NULL) {
switch (getVariant(L_p, 2).toInt())
{
case 1:
@ -310,7 +310,9 @@ int LuaEngine::luaDeletePointer_p(lua_State *L_p)
int LuaEngine::luaTriggerConnect_p(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 3) {
QObject *object = (QObject*)getPointer(L_p, 1);
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
QObject *object = (QObject*)pointer;
QString signalString = getVariant(L_p, 2).toString();
int signalIndex = object->metaObject()->indexOfSignal(signalString.toUtf8().data());
if (signalIndex != -1) {
@ -326,13 +328,16 @@ int LuaEngine::luaTriggerConnect_p(lua_State *L_p)
}
}
}
}
return 0;
}
int LuaEngine::luaTriggerDisconnect_p(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 2) {
QObject *object = (QObject*)getPointer(L_p, 1);
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
QObject *object = (QObject*)pointer;
QString signalString = getVariant(L_p, 2).toString();
int signalIndex = object->metaObject()->indexOfSignal(signalString.toUtf8().data());
if (signalIndex != -1) {
@ -348,6 +353,7 @@ int LuaEngine::luaTriggerDisconnect_p(lua_State *L_p)
}
}
}
}
return 0;
}