Merge pull request #11 from EdgeTX/virtual-keyboard-fieldcontainer
[keyboard] Fix nullptr access while searching for full screen window
This commit is contained in:
+10
-13
@@ -53,11 +53,15 @@ class Keyboard: public FormWindow
|
|||||||
activeKeyboard = this;
|
activeKeyboard = this;
|
||||||
attach(MainWindow::instance());
|
attach(MainWindow::instance());
|
||||||
fieldContainer = getFieldContainer(newField);
|
fieldContainer = getFieldContainer(newField);
|
||||||
fieldContainer->setHeight(LCD_H - height() - fieldContainer->top());
|
if (fieldContainer) {
|
||||||
fieldContainer->scrollTo(newField);
|
fieldContainer->setHeight(LCD_H - height() - fieldContainer->top());
|
||||||
invalidate();
|
fieldContainer->scrollTo(newField);
|
||||||
newField->setEditMode(true);
|
invalidate();
|
||||||
field = newField;
|
newField->setEditMode(true);
|
||||||
|
field = newField;
|
||||||
|
} else {
|
||||||
|
clearField();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearField()
|
void clearField()
|
||||||
@@ -75,14 +79,7 @@ class Keyboard: public FormWindow
|
|||||||
|
|
||||||
Window * getFieldContainer(FormField * field)
|
Window * getFieldContainer(FormField * field)
|
||||||
{
|
{
|
||||||
Window * parent = field;
|
return field->getFullScreenWindow();
|
||||||
while (true) {
|
|
||||||
Window * tmp = parent->getParent();
|
|
||||||
if ((tmp->getWindowFlags() & OPAQUE) && tmp->width() == LCD_W && tmp->height() == LCD_H) {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
parent = tmp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -107,9 +107,11 @@ class Window
|
|||||||
return window == this || (parent && parent->isChild(window));
|
return window == this || (parent && parent->isChild(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
Window * getFullScreenWindow()
|
Window *getFullScreenWindow()
|
||||||
{
|
{
|
||||||
return (width() == LCD_W && height() == LCD_H) ? this : parent->getFullScreenWindow();
|
if (width() == LCD_W && height() == LCD_H) return this;
|
||||||
|
if (parent) return parent->getFullScreenWindow();
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowFlags getWindowFlags() const
|
WindowFlags getWindowFlags() const
|
||||||
|
|||||||
Reference in New Issue
Block a user