From 807bcdd597e07e741b922eb2ab08f0cbd00edb8f Mon Sep 17 00:00:00 2001 From: Syping Date: Sat, 16 May 2020 17:05:00 +0200 Subject: [PATCH] remove repeating from getWindow --- src/luaenginegui/luaengine/LuaEngineGui.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/luaenginegui/luaengine/LuaEngineGui.cpp b/src/luaenginegui/luaengine/LuaEngineGui.cpp index 320de6c..8575371 100644 --- a/src/luaenginegui/luaengine/LuaEngineGui.cpp +++ b/src/luaenginegui/luaengine/LuaEngineGui.cpp @@ -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; } }