mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
improve error proofness
This commit is contained in:
parent
53e8d9abe5
commit
115d384f88
1 changed files with 33 additions and 27 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue