Fix of #7170. Delayed notification is not moved until push will succeed.

This commit is contained in:
David Kocik 2021-10-26 14:03:58 +02:00
parent 79d9fd154e
commit 8bf4408731
3 changed files with 8 additions and 3 deletions

View File

@ -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<const ObjectIDNotification*>(notification);
auto w2 = dynamic_cast<const ObjectIDNotification*>(it->get());

View File

@ -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<NotificationManager::PopNotification> notification, std::function<bool(void)> 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);

View File

@ -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()
{