[GB.GTK]
* BUG: The Window.Controls property does not return invalid controls anymore. [GB.QT4] * BUG: The Window.Controls property does not return invalid controls anymore. git-svn-id: svn://localhost/gambas/trunk@5578 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
71d052a379
commit
82f9ea714e
@ -1120,7 +1120,7 @@ int gMainWindow::controlCount()
|
||||
while (list)
|
||||
{
|
||||
ctrl = (gControl *)list->data;
|
||||
if (ctrl->window() == this)
|
||||
if (ctrl->window() == this && !ctrl->isDestroyed())
|
||||
n++;
|
||||
list = g_list_next(list);
|
||||
}
|
||||
@ -1136,7 +1136,7 @@ gControl *gMainWindow::getControl(char *name)
|
||||
while (list)
|
||||
{
|
||||
ctrl = (gControl *)list->data;
|
||||
if (ctrl->window() == this && !strcasecmp(ctrl->name(), name))
|
||||
if (ctrl->window() == this && !strcasecmp(ctrl->name(), name) && !ctrl->isDestroyed())
|
||||
return ctrl;
|
||||
list = g_list_next(list);
|
||||
}
|
||||
@ -1153,7 +1153,7 @@ gControl *gMainWindow::getControl(int index)
|
||||
while (list)
|
||||
{
|
||||
ctrl = (gControl *)list->data;
|
||||
if (ctrl->window() == this)
|
||||
if (ctrl->window() == this && !ctrl->isDestroyed())
|
||||
{
|
||||
if (i == index)
|
||||
return ctrl;
|
||||
|
@ -296,11 +296,17 @@ void CWIDGET_update_design(CWIDGET *_object)
|
||||
|
||||
void CWIDGET_init_name(CWIDGET *_object)
|
||||
{
|
||||
static int n = 0;
|
||||
char *name = GB.GetLastEventName();
|
||||
|
||||
if (!name)
|
||||
name = GB.GetClassName(THIS);
|
||||
//qDebug("name: %p: %s", THIS, name);
|
||||
set_name(THIS, name);
|
||||
{
|
||||
char buffer[16];
|
||||
sprintf(buffer, "#%d", n);
|
||||
set_name(THIS, buffer);
|
||||
}
|
||||
else
|
||||
set_name(THIS, name);
|
||||
}
|
||||
|
||||
bool CWIDGET_container_for(void *_object, void *container_for)
|
||||
|
@ -1169,15 +1169,17 @@ BEGIN_PROPERTY(CWINDOW_visible)
|
||||
END_PROPERTY
|
||||
|
||||
|
||||
BEGIN_PROPERTY(CWINDOW_control_count)
|
||||
BEGIN_PROPERTY(Window_Controls_Count)
|
||||
|
||||
QList<QWidget *> list = WINDOW->findChildren<QWidget *>();
|
||||
int i;
|
||||
int n = 0;
|
||||
CWIDGET *control;
|
||||
|
||||
for (i = 0; i < list.count(); i++)
|
||||
{
|
||||
if (CWidget::getReal(list.at(i)))
|
||||
control = CWidget::getReal(list.at(i));
|
||||
if (control && !CWIDGET_check(control))
|
||||
n++;
|
||||
}
|
||||
|
||||
@ -1186,7 +1188,7 @@ BEGIN_PROPERTY(CWINDOW_control_count)
|
||||
END_PROPERTY
|
||||
|
||||
|
||||
BEGIN_METHOD_VOID(CWINDOW_control_next)
|
||||
BEGIN_METHOD_VOID(Window_Controls_next)
|
||||
|
||||
QList<QWidget *> children = WINDOW->findChildren<QWidget *>();
|
||||
CWIDGET *control;
|
||||
@ -1207,7 +1209,7 @@ BEGIN_METHOD_VOID(CWINDOW_control_next)
|
||||
control = CWidget::getReal(children.at(index));
|
||||
index++;
|
||||
}
|
||||
while (!control);
|
||||
while (!control || CWIDGET_check(control));
|
||||
|
||||
ENUM(int) = index;
|
||||
GB.ReturnObject(control);
|
||||
@ -1223,9 +1225,14 @@ BEGIN_METHOD(CWINDOW_reparent, GB_OBJECT container; GB_INTEGER x; GB_INTEGER y)
|
||||
END_METHOD
|
||||
|
||||
|
||||
BEGIN_METHOD(CWINDOW_get, GB_STRING name)
|
||||
BEGIN_METHOD(Window_Controls_get, GB_STRING name)
|
||||
|
||||
GB.ReturnObject(WINDOW->names[GB.ToZeroString(ARG(name))]);
|
||||
CWIDGET *control = WINDOW->names[GB.ToZeroString(ARG(name))];
|
||||
|
||||
if (CWIDGET_check(control))
|
||||
GB.ReturnNull();
|
||||
else
|
||||
GB.ReturnObject(control);
|
||||
|
||||
END_METHOD
|
||||
|
||||
@ -1366,9 +1373,9 @@ GB_DESC CWindowControlsDesc[] =
|
||||
{
|
||||
GB_DECLARE(".Window.Controls", 0), GB_VIRTUAL_CLASS(),
|
||||
|
||||
GB_METHOD("_next", "Control", CWINDOW_control_next, NULL),
|
||||
GB_METHOD("_get", "Control", CWINDOW_get, "(Name)s"),
|
||||
GB_PROPERTY_READ("Count", "i", CWINDOW_control_count),
|
||||
GB_METHOD("_next", "Control", Window_Controls_next, NULL),
|
||||
GB_METHOD("_get", "Control", Window_Controls_get, "(Name)s"),
|
||||
GB_PROPERTY_READ("Count", "i", Window_Controls_Count),
|
||||
|
||||
GB_END_DECLARE
|
||||
};
|
||||
@ -1407,7 +1414,7 @@ GB_DESC CWindowDesc[] =
|
||||
|
||||
GB_METHOD("_new", NULL, CWINDOW_new, "[(Parent)Control;]"),
|
||||
GB_METHOD("_free", NULL, CWINDOW_free, NULL),
|
||||
GB_METHOD("_get", "Control", CWINDOW_get, "(Name)s"),
|
||||
GB_METHOD("_get", "Control", Window_Controls_get, "(Name)s"),
|
||||
|
||||
GB_METHOD("Close", "b", CWINDOW_close, "[(Return)i]"),
|
||||
GB_METHOD("Raise", NULL, CWINDOW_raise, NULL),
|
||||
|
Loading…
x
Reference in New Issue
Block a user