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) { if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1); void *pointer = getPointer(L_p, 1);
if (pointer != NULL) { if (pointer != NULL) {
bool isWindow = false; void *window = windowForObject((QObject*)pointer);
QObject *object = ((QObject*)pointer); if (window != nullptr) {
while (!isWindow) { pushPointer(L_p, window);
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);
return 1; return 1;
} }
} }