From 8bf4408731339d0d56ee51dd86c44a67e1984a03 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Tue, 26 Oct 2021 14:03:58 +0200 Subject: [PATCH] Fix of #7170. Delayed notification is not moved until push will succeed. --- src/slic3r/GUI/NotificationManager.cpp | 8 ++++++-- src/slic3r/GUI/NotificationManager.hpp | 1 + src/slic3r/GUI/Plater.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index a984b6ba7..0af8e32f5 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -2068,9 +2068,11 @@ bool NotificationManager::update_notifications(GLCanvas3D& canvas) if ((*it).remaining_time > 0) (*it).remaining_time -= time_since_render; if ((*it).remaining_time <= 0) { - if ((*it).condition_callback()) { // push notification, erase it from waiting list (frame is scheduled by push) + if ((*it).notification && (*it).condition_callback()) { // push notification, erase it from waiting list (frame is scheduled by push) (*it).notification->reset_timer(); - if (push_notification_data(std::move((*it).notification), 0)) { + // if activate_existing returns false, we expect push to return true. + if(!this->activate_existing((*it).notification.get()) || (*it).delay_interval == 0) { + push_notification_data(std::move((*it).notification), 0); it = m_waiting_notifications.erase(it); continue; } @@ -2107,11 +2109,13 @@ bool NotificationManager::activate_existing(const NotificationManager::PopNotifi const std::string &new_text = notification->get_data().text1; for (auto it = m_pop_notifications.begin(); it != m_pop_notifications.end(); ++it) { if ((*it)->get_type() == new_type && !(*it)->is_finished()) { + // multiple of one type allowed, but must have different text if (std::find(m_multiple_types.begin(), m_multiple_types.end(), new_type) != m_multiple_types.end()) { // If found same type and same text, return true - update will be performed on the old notif if ((*it)->compare_text(new_text) == false) { continue; } + // multiple of one type allowed, but must have different text nad ObjectID } else if (new_type == NotificationType::SlicingWarning) { auto w1 = dynamic_cast(notification); auto w2 = dynamic_cast(it->get()); diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index 655b17e63..6c50f6407 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -706,6 +706,7 @@ private: // Otherwise another delay interval waiting. Timestamp is 0. // Note that notification object is constructed when being added to the waiting list, but there are no updates called on it and its timer is reset at regular push. // Also note that no control of same notification is done during push_delayed_notification_data but if waiting notif fails to push, it continues waiting. + // If delay_interval is 0, notification is pushed only after initial_delay no matter the result. void push_delayed_notification_data(std::unique_ptr notification, std::function condition_callback, int64_t initial_delay, int64_t delay_interval); //finds older notification of same type and moves it to the end of queue. returns true if found bool activate_existing(const NotificationManager::PopNotification* notification); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index ec09ac1ad..57c8a2328 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4030,7 +4030,7 @@ void Plater::priv::on_export_began(wxCommandEvent& evt) { if (show_warning_dialog) warnings_dialog(); - notification_manager->push_delayed_notification(NotificationType::ExportOngoing, [](){return true;}, 1000, 1000); + notification_manager->push_delayed_notification(NotificationType::ExportOngoing, [](){return true;}, 1000, 0); } void Plater::priv::on_slicing_began() {