diff --git a/libs/image/KisSelectionUpdateCompressor.cpp b/libs/image/KisSelectionUpdateCompressor.cpp index d9fd32e272..129e6d471b 100644 --- a/libs/image/KisSelectionUpdateCompressor.cpp +++ b/libs/image/KisSelectionUpdateCompressor.cpp @@ -1,76 +1,75 @@ /* * Copyright (c) 2018 Dmitry Kazakov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "KisSelectionUpdateCompressor.h" #include "kis_image.h" #include "kis_selection.h" #include "kis_layer_utils.h" #include "kis_update_selection_job.h" KisSelectionUpdateCompressor::KisSelectionUpdateCompressor(KisSelection *selection) - : m_parentSelection(selection), - m_updateSignalCompressor(new KisThreadSafeSignalCompressor(100, KisSignalCompressor::POSTPONE)), - m_hasStalledUpdate(false) + : m_parentSelection(selection) + , m_updateSignalCompressor(new KisThreadSafeSignalCompressor(100, KisSignalCompressor::POSTPONE)) { connect(m_updateSignalCompressor, SIGNAL(timeout()), this, SLOT(startUpdateJob())); this->moveToThread(m_updateSignalCompressor->thread()); } KisSelectionUpdateCompressor::~KisSelectionUpdateCompressor() { m_updateSignalCompressor->deleteLater(); } void KisSelectionUpdateCompressor::requestUpdate(const QRect &updateRect) { m_fullUpdateRequested |= updateRect.isEmpty(); m_updateRect = !m_fullUpdateRequested ? m_updateRect | updateRect : QRect(); m_updateSignalCompressor->start(); } void KisSelectionUpdateCompressor::tryProcessStalledUpdate() { if (m_hasStalledUpdate) { m_updateSignalCompressor->start(); } } void KisSelectionUpdateCompressor::startUpdateJob() { KisNodeSP parentNode = m_parentSelection->parentNode(); if (!parentNode) { m_hasStalledUpdate = true; return; } KisImageSP image = KisLayerUtils::findImageByHierarchy(parentNode); if (!image) { m_hasStalledUpdate = true; return; } if (image) { image->addSpontaneousJob(new KisUpdateSelectionJob(m_parentSelection, m_updateRect)); } m_updateRect = QRect(); m_fullUpdateRequested = false; m_hasStalledUpdate = false; } diff --git a/libs/image/KisSelectionUpdateCompressor.h b/libs/image/KisSelectionUpdateCompressor.h index e003c3dd88..4ab98c5054 100644 --- a/libs/image/KisSelectionUpdateCompressor.h +++ b/libs/image/KisSelectionUpdateCompressor.h @@ -1,52 +1,52 @@ /* * Copyright (c) 2018 Dmitry Kazakov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KISSELECTIONUPDATECOMPRESSOR_H #define KISSELECTIONUPDATECOMPRESSOR_H #include "kritaimage_export.h" #include "kis_thread_safe_signal_compressor.h" #include "kis_types.h" #include class KisSelectionUpdateCompressor : public QObject { Q_OBJECT public: KisSelectionUpdateCompressor(KisSelection *selection); ~KisSelectionUpdateCompressor(); public Q_SLOTS: void requestUpdate(const QRect &updateRect); void tryProcessStalledUpdate(); private Q_SLOTS: void startUpdateJob(); private: - KisSelection *m_parentSelection; - KisThreadSafeSignalCompressor *m_updateSignalCompressor; + KisSelection *m_parentSelection {0}; + KisThreadSafeSignalCompressor *m_updateSignalCompressor {0}; QRect m_updateRect; - bool m_fullUpdateRequested; + bool m_fullUpdateRequested {false}; - bool m_hasStalledUpdate; + bool m_hasStalledUpdate {false}; }; #endif // KISSELECTIONUPDATECOMPRESSOR_H