mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
remove repeating from getWindow
This commit is contained in:
parent
8aac85e99b
commit
807bcdd597
1 changed files with 3 additions and 18 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue