From 2443f62e578283b20aaed1874fb356753774cf79 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 23 May 2015 18:41:27 +0300 Subject: Add check in popups for posInit() calls. If postInit() was not called show error in log. --- src/gui/widgets/popup.cpp | 9 ++++++++- src/gui/widgets/popup.h | 7 +++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index a2c441225..a69c7a654 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -44,11 +44,12 @@ Popup::Popup(const std::string &name, mPadding(3), mSkin(nullptr), mPopupName(name), + mVertexes(new ImageCollection), mMinWidth(100), mMinHeight(40), mMaxWidth(mainGraphics->mWidth), mMaxHeight(mainGraphics->mHeight), - mVertexes(new ImageCollection) + mInit(false) { logger->log("Popup::Popup(\"%s\")", name.c_str()); @@ -86,6 +87,12 @@ Popup::~Popup() theme->unload(mSkin); mSkin = nullptr; } + + if (!mInit) + { + logger->log("error: Popup created without calling postInit(): " + + mPopupName); + } } void Popup::setWindowContainer(WindowContainer *const wc) diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index a375a90c7..f39a92ec0 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -172,8 +172,7 @@ class Popup notfinal : public Container, { return mVisible; } virtual void postInit() - { - } + { mInit = true; } protected: int mPadding; /**< Holds the padding of the popup. */ @@ -181,12 +180,12 @@ class Popup notfinal : public Container, private: std::string mPopupName; /**< Name of the popup */ + ImageCollection *mVertexes; int mMinWidth; /**< Minimum popup width */ int mMinHeight; /**< Minimum popup height */ int mMaxWidth; /**< Maximum popup width */ int mMaxHeight; /**< Maximum popup height */ - - ImageCollection *mVertexes; + bool mInit; }; #endif // GUI_WIDGETS_POPUP_H -- cgit v1.2.3-70-g09d2