diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/basiccontainer.cpp | 7 | ||||
-rw-r--r-- | src/gui/widgets/basiccontainer.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/basiccontainer2.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/icon.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/layoutarray.h | 7 | ||||
-rw-r--r-- | src/gui/widgets/layouthelper.cpp | 14 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/radiobutton.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/shortcutcontainer.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_input.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setuptabscroll.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/textfield.h | 6 | ||||
-rw-r--r-- | src/gui/widgets/widget.cpp | 3 |
17 files changed, 50 insertions, 24 deletions
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp index 1be1d4bc0..ea0a28bd8 100644 --- a/src/gui/widgets/basiccontainer.cpp +++ b/src/gui/widgets/basiccontainer.cpp @@ -240,6 +240,8 @@ void BasicContainer::setFocusHandler(FocusHandler *const focusHandler) void BasicContainer::add(Widget *const widget) { + if (!widget) + return; mWidgets.push_back(widget); if (widget->isAllowLogic()) mLogicWidgets.push_back(widget); @@ -255,6 +257,8 @@ void BasicContainer::add(Widget *const widget) void BasicContainer::remove(Widget* widget) { + if (!widget) + return; FOR_EACH (WidgetListIterator, iter, mWidgets) { if (*iter == widget) @@ -382,6 +386,9 @@ void BasicContainer::logicChildren() void BasicContainer::showWidgetPart(Widget *const widget, const Rect &area) { + if (!widget) + return; + const Rect widgetArea = getChildrenArea(); const int x = widget->mDimension.x; diff --git a/src/gui/widgets/basiccontainer.h b/src/gui/widgets/basiccontainer.h index eb115777c..c18e3ba63 100644 --- a/src/gui/widgets/basiccontainer.h +++ b/src/gui/widgets/basiccontainer.h @@ -163,9 +163,9 @@ class BasicContainer notfinal : public Widget, * * @param graphics A graphics object to draw with. */ - virtual void drawChildren(Graphics* graphics); + virtual void drawChildren(Graphics* graphics) A_NONNULL(2); - virtual void safeDrawChildren(Graphics* graphics); + virtual void safeDrawChildren(Graphics* graphics) A_NONNULL(2); /** * Calls logic for the children widgets of the basic diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp index cc0158d9a..11e36c09b 100644 --- a/src/gui/widgets/basiccontainer2.cpp +++ b/src/gui/widgets/basiccontainer2.cpp @@ -116,8 +116,11 @@ void BasicContainer2::add(Widget* widget) } void BasicContainer2::addXY(Widget* widget, - const int x, const int y) + const int x, + const int y) { + if (!widget) + return; widget->setPosition(x, y); BasicContainer::add(widget); } diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index df8e93d49..e07e783c7 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -143,7 +143,7 @@ class DropDown final : public ActionListener, * * @param graphics a Graphics object to draw with. */ - void drawButton(Graphics *graphics); + void drawButton(Graphics *graphics) A_NONNULL(2); PopupList *mPopup; Color mShadowColor; diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index bb2101b01..e48f71b24 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -67,9 +67,9 @@ class Icon final : public Widget /** * Draws the Icon. */ - void draw(Graphics *g) override final; + void draw(Graphics *g) override final A_NONNULL(2); - void safeDraw(Graphics *g) override final; + void safeDraw(Graphics *g) override final A_NONNULL(2); private: Image *mImage; diff --git a/src/gui/widgets/layoutarray.h b/src/gui/widgets/layoutarray.h index 4658e8c75..63d0912d1 100644 --- a/src/gui/widgets/layoutarray.h +++ b/src/gui/widgets/layoutarray.h @@ -93,9 +93,12 @@ class LayoutArray final /** * Gets the position and size of a widget along a given axis */ - void align(int &restrict pos, int &restrict size, const int dim, + void align(int &restrict pos, + int &restrict size, + const int dim, LayoutCell const &restrict cell, - const int *restrict const sizes, const int sizeCount) const; + const int *restrict const sizes, + const int sizeCount) const A_NONNULL(6); /** * Ensures the private vectors are large enough. diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index caf7df58e..5296c69bc 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -32,12 +32,14 @@ LayoutHelper::LayoutHelper(BasicContainer2 *const container) : mLayout(), mContainer(container) { - mContainer->addWidgetListener(this); + if (mContainer) + mContainer->addWidgetListener(this); } LayoutHelper::~LayoutHelper() { - mContainer->removeWidgetListener(this); + if (mContainer) + mContainer->removeWidgetListener(this); } const Layout &LayoutHelper::getLayout() const @@ -49,7 +51,8 @@ LayoutCell &LayoutHelper::place(const int x, const int y, Widget *const wg, const int w, const int h) { - mContainer->add(wg); + if (mContainer) + mContainer->add(wg); return mLayout.place(wg, x, y, w, h); } @@ -61,11 +64,14 @@ ContainerPlacer LayoutHelper::getPlacer(const int x, const int y) void LayoutHelper::reflowLayout(int w, int h) { mLayout.reflow(w, h); - mContainer->setSize(w, h); + if (mContainer) + mContainer->setSize(w, h); } void LayoutHelper::widgetResized(const Event &event A_UNUSED) { + if (!mContainer) + return; const Rect area = mContainer->getChildrenArea(); int w = area.width; int h = area.height; diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index ee15f32ba..f21a88f8b 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -83,9 +83,9 @@ class PlayerBox final : public Widget, /** * Draws the background and border of the scroll area. */ - void drawFrame(Graphics *graphics) override final; + void drawFrame(Graphics *graphics) override final A_NONNULL(2); - void safeDrawFrame(Graphics *graphics) override final; + void safeDrawFrame(Graphics *graphics) override final A_NONNULL(2); Being *getBeing() A_WARN_UNUSED { return mBeing; } diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index 50b000f31..939601e07 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -106,7 +106,7 @@ class RadioButton final : public Widget, /** * Draws the radiobutton, not the caption. */ - void drawBox(Graphics* graphics); + void drawBox(Graphics* graphics) A_NONNULL(2); /** * Implementation of the draw methods. diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 5d9b2e70b..1d341e46b 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -144,9 +144,9 @@ class ScrollArea final : public BasicContainer, /** * Draws the background and border of the scroll area. */ - void drawFrame(Graphics *graphics) override final; + void drawFrame(Graphics *graphics) override final A_NONNULL(2); - void safeDrawFrame(Graphics *graphics) override final; + void safeDrawFrame(Graphics *graphics) override final A_NONNULL(2); /** * Sets whether the widget should draw its background or not. diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 18196a739..6bc0ef655 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -194,6 +194,8 @@ void SetupItem::externalUnloaded(const std::string &eventName A_UNUSED) void SetupItem::fixFirstItemSize(Widget *const widget) { + if (!widget) + return; const int maxSize = mParent->getPreferredFirstItemSize(); if (widget->getWidth() < maxSize) widget->setWidth(maxSize); diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index a8dad30c9..770609175 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -86,9 +86,9 @@ class ShortcutContainer notfinal : public Widget, int getBoxHeight() const A_WARN_UNUSED { return mBoxHeight; } - void drawBackground(Graphics *g); + void drawBackground(Graphics *g) A_NONNULL(2); - void safeDrawBackground(Graphics *g); + void safeDrawBackground(Graphics *g) A_NONNULL(2); protected: /** diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index f96201e42..b6b0eceb4 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -253,6 +253,8 @@ void TabbedArea::addTab(Tab *const tab, void TabbedArea::adjustWidget(Widget *const widget) const { + if (!widget) + return; const int frameSize = 2 * mFrameSize; widget->setSize(getWidth() - frameSize, getHeight() - frameSize - mTabContainer->getHeight()); diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h index eb97dd644..ac8a06609 100644 --- a/src/gui/widgets/tabs/setup_input.h +++ b/src/gui/widgets/tabs/setup_input.h @@ -87,7 +87,7 @@ class Setup_Input final : public SetupTab static void fixTranslation(SetupActionData *const actionDatas, const InputActionT actionStart, const InputActionT actionEnd, - const std::string &text); + const std::string &text) A_NONNULL(1); KeyListModel *mKeyListModel; ListBox *mKeyList; diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp index 0a0294357..11c7afd61 100644 --- a/src/gui/widgets/tabs/setuptabscroll.cpp +++ b/src/gui/widgets/tabs/setuptabscroll.cpp @@ -70,6 +70,8 @@ void SetupTabScroll::clear() void SetupTabScroll::addControl(SetupItem *const widget) { + if (!widget) + return; const std::string actionId = widget->getActionEventId(); if (!actionId.empty()) { diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 75c3d9253..6e77b5e1a 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -119,9 +119,9 @@ class TextField notfinal : public Widget, /** * Draws the background and border. */ - void drawFrame(Graphics *graphics) override final; + void drawFrame(Graphics *graphics) override final A_NONNULL(2); - void safeDrawFrame(Graphics *graphics) override final; + void safeDrawFrame(Graphics *graphics) override final A_NONNULL(2); /** * Determine whether the field should be numeric or not @@ -234,7 +234,7 @@ class TextField notfinal : public Widget, void setWindow(Widget *const widget) override final; protected: - void drawCaret(Graphics* graphics, int x); + void drawCaret(Graphics* graphics, int x) A_NONNULL(2); void fixScroll(); diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index 7fdab305e..023f4a035 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -516,6 +516,7 @@ void Widget::windowResized() Widget *Widget::callPostInit(Widget *const widget) { - widget->postInit(); + if (widget) + widget->postInit(); return widget; } |