remove repeating from getWindow

This commit is contained in:
Syping 2020-05-16 17:05:00 +02:00
parent 8aac85e99b
commit 807bcdd597

View file

@ -1175,24 +1175,9 @@ int LuaEngineGui::getWindow(lua_State *L_p)
if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
bool isWindow = false;
QObject *object = ((QObject*)pointer);
while (!isWindow) {
if (object->inherits("QDialog") || object->inherits("QMainWindow")) {
isWindow = true;
}
else {
QObject *parent = object->parent();
if (parent != NULL) {
object = parent;
}
else {
break;
}
}
}
if (isWindow) {
pushPointer(L_p, object);
void *window = windowForObject((QObject*)pointer);
if (window != nullptr) {
pushPointer(L_p, window);
return 1;
}
}