mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 20:05:30 +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) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue