~aleteoryx/muditaos

506f5615ce379088b6e80fb5fb4de32a679a2d1f — Piotr Tanski 5 years ago 87254a7
[EGD-4373] Fix for the unexpected call to onClose() method. (#1048)

4 files changed, 17 insertions(+), 15 deletions(-)

M changelog.md
M module-apps/Application.cpp
M module-apps/Application.hpp
M module-apps/WindowsStack.hpp
M changelog.md => changelog.md +1 -0
@@ 12,6 12,7 @@
* `[desktop]` Fixed ScreenlockCheckEvent handler 
* `[messages]` Fix for changing the content of option windows when forwarding a message.
* `[messages]` Fixed saving a draft message for a phone number.
* `[messages]` Fixed usage of special characters while writing new message.

### Changed


M module-apps/Application.cpp => module-apps/Application.cpp +14 -8
@@ 145,10 145,7 @@ namespace app
        if (suspendInProgress)
            suspendInProgress = false;
    }
    void Application::blockEvents(bool isBlocked)
    {
        acceptInput = isBlocked;
    }

    void Application::switchWindow(const std::string &windowName,
                                   gui::ShowMode cmd,
                                   std::unique_ptr<gui::SwitchData> data)


@@ 406,10 403,12 @@ namespace app
            if (switchData && switchData->ignoreCurrentWindowOnStack) {
                popToWindow(getPrevWindow());
            }
            if (not windowsStack.isEmpty()) {
                getCurrentWindow()->onClose();
            if (!isCurrentWindow(msg->getWindowName())) {
                if (!windowsStack.isEmpty()) {
                    getCurrentWindow()->onClose();
                }
                setActiveWindow(msg->getWindowName());
            }
            setActiveWindow(msg->getWindowName());
            LOG_DEBUG("Current window: %s vs %s", getCurrentWindow()->getName().c_str(), msg->getWindowName().c_str());
            getCurrentWindow()->handleSwitchData(switchData.get());



@@ 517,7 516,6 @@ namespace app
    void Application::setActiveWindow(const std::string &windowName)
    {
        pushWindow(windowName);
        acceptInput = true;
    }

    bool Application::setVolume(const audio::Volume &value,


@@ 682,6 680,14 @@ namespace app
        return windowsStack.get(windowsStack.stack.back());
    }

    bool Application::isCurrentWindow(const std::string &windowName) const noexcept
    {
        if (windowsStack.isEmpty()) {
            return false;
        }
        return windowsStack.stack.back() == windowName;
    }

    gui::AppWindow *Application::getWindow(const std::string &name)
    {
        return windowsStack.get(name);

M module-apps/Application.hpp => module-apps/Application.hpp +1 -6
@@ 194,9 194,6 @@ namespace app
        /// 2. loads rendering commands and send them to GUI renderer (sgui::ServiceGUI)
        void render(gui::RefreshModes mode);

        /// Method responsible for setting application to the state where incoming user input is blocked
        void blockEvents(bool isBlocked);

        /// Method sending switch command for another window. It will switch window within active application.
        /// To switch windows between applications use app::manager::Controller::switchApplication
        /// it will effectively trigger setActiveWindow and change on windows stack


@@ 337,6 334,7 @@ namespace app
        /// if there is none - returns default window
        /// @ingrup AppWindowStack
        gui::AppWindow *getCurrentWindow();
        bool isCurrentWindow(const std::string &windowName) const noexcept;

        gui::AppWindow *getWindow(const std::string &name);
        /// to avoid conflicts with connect below


@@ 345,9 343,6 @@ namespace app
        void connect(std::unique_ptr<GuiTimer> &&timer, gui::Item *item);

      protected:
        /// Flag defines whether keyboard input should be processed
        bool acceptInput = false;

        /// key translator to handle
        /// 1. long press transformation (right now we support long press only via top application keyTralator handling)
        /// 2. simple translation of keys 1 to 1 with keyboard

M module-apps/WindowsStack.hpp => module-apps/WindowsStack.hpp +1 -1
@@ 46,7 46,7 @@ namespace app
            stack.push_back(name);
        }

        gui::AppWindow *get(const std::string &name)
        gui::AppWindow *get(const std::string &name) const
        {
            auto ret = windows.find(name);
            return ret == std::end(windows) ? nullptr : ret->second.get();