comparison view/View.cpp @ 1448:4b7fc925a5ce single-point

Some debug bits
author Chris Cannam
date Wed, 01 May 2019 11:46:09 +0100
parents b22a4df37095
children 160e6d010141
comparison
equal deleted inserted replaced
1447:8afea53332f3 1448:4b7fc925a5ce
48 #include <cassert> 48 #include <cassert>
49 #include <cmath> 49 #include <cmath>
50 50
51 //#define DEBUG_VIEW 1 51 //#define DEBUG_VIEW 1
52 //#define DEBUG_VIEW_WIDGET_PAINT 1 52 //#define DEBUG_VIEW_WIDGET_PAINT 1
53 //#define DEBUG_PROGRESS_STUFF 1
53 54
54 View::View(QWidget *w, bool showProgress) : 55 View::View(QWidget *w, bool showProgress) :
55 QFrame(w), 56 QFrame(w),
56 m_id(getNextId()), 57 m_id(getNextId()),
57 m_centreFrame(0), 58 m_centreFrame(0),
1734 } 1735 }
1735 1736
1736 void 1737 void
1737 View::checkProgress(void *object) 1738 View::checkProgress(void *object)
1738 { 1739 {
1739 if (!m_showProgress) return; 1740 if (!m_showProgress) {
1741 #ifdef DEBUG_PROGRESS_STUFF
1742 SVCERR << "View[" << this << "]::checkProgress(" << object << "): "
1743 << "m_showProgress is off" << endl;
1744 #endif
1745 return;
1746 }
1740 1747
1741 int ph = height(); 1748 int ph = height();
1749 bool found = false;
1742 1750
1743 for (ProgressMap::iterator i = m_progressBars.begin(); 1751 for (ProgressMap::iterator i = m_progressBars.begin();
1744 i != m_progressBars.end(); ++i) { 1752 i != m_progressBars.end(); ++i) {
1745 1753
1746 QProgressBar *pb = i->second.bar; 1754 QProgressBar *pb = i->second.bar;
1747 QPushButton *cancel = i->second.cancel; 1755 QPushButton *cancel = i->second.cancel;
1748 1756
1749 if (i->first == object) { 1757 if (i->first == object) {
1750 1758
1759 found = true;
1760
1751 // The timer is used to test for stalls. If the progress 1761 // The timer is used to test for stalls. If the progress
1752 // bar does not get updated for some length of time, the 1762 // bar does not get updated for some length of time, the
1753 // timer prompts it to go back into "indeterminate" mode 1763 // timer prompts it to go back into "indeterminate" mode
1754 QTimer *timer = i->second.checkTimer; 1764 QTimer *timer = i->second.checkTimer;
1755 1765
1756 int completion = i->first->getCompletion(this); 1766 int completion = i->first->getCompletion(this);
1757 QString text = i->first->getPropertyContainerName(); 1767 QString text = i->first->getPropertyContainerName();
1758 QString error = i->first->getError(this); 1768 QString error = i->first->getError(this);
1769
1770 #ifdef DEBUG_PROGRESS_STUFF
1771 SVCERR << "View[" << this << "]::checkProgress(" << object << "): "
1772 << "found progress bar " << pb << " for layer at height " << ph
1773 << ": completion = " << completion << endl;
1774 #endif
1759 1775
1760 if (error != "" && error != m_lastError) { 1776 if (error != "" && error != m_lastError) {
1761 QMessageBox::critical(this, tr("Layer rendering error"), error); 1777 QMessageBox::critical(this, tr("Layer rendering error"), error);
1762 m_lastError = error; 1778 m_lastError = error;
1763 } 1779 }
1776 if (wfm || 1792 if (wfm ||
1777 (model && 1793 (model &&
1778 (wfm = dynamic_cast<RangeSummarisableTimeValueModel *> 1794 (wfm = dynamic_cast<RangeSummarisableTimeValueModel *>
1779 (model->getSourceModel())))) { 1795 (model->getSourceModel())))) {
1780 completion = wfm->getAlignmentCompletion(); 1796 completion = wfm->getAlignmentCompletion();
1781 // SVDEBUG << "View::checkProgress: Alignment completion = " << completion << endl; 1797
1798 #ifdef DEBUG_PROGRESS_STUFF
1799 SVCERR << "View[" << this << "]::checkProgress(" << object << "): "
1800 << "alignment completion = " << completion << endl;
1801 #endif
1802
1782 if (completion < 100) { 1803 if (completion < 100) {
1783 text = tr("Alignment"); 1804 text = tr("Alignment");
1784 } 1805 }
1785 } 1806 }
1786 1807
1819 if (pb->isVisible()) { 1840 if (pb->isVisible()) {
1820 ph -= pb->height(); 1841 ph -= pb->height();
1821 } 1842 }
1822 } 1843 }
1823 } 1844 }
1845
1846 if (!found) {
1847 #ifdef DEBUG_PROGRESS_STUFF
1848 SVCERR << "View[" << this << "]::checkProgress(" << object << "): "
1849 << "failed to find layer " << object << " in progress map"
1850 << endl;
1851 #endif
1852 }
1824 } 1853 }
1825 1854
1826 void 1855 void
1827 View::progressCheckStalledTimerElapsed() 1856 View::progressCheckStalledTimerElapsed()
1828 { 1857 {
1829 QObject *s = sender(); 1858 QObject *s = sender();
1830 QTimer *t = qobject_cast<QTimer *>(s); 1859 QTimer *t = qobject_cast<QTimer *>(s);
1831 if (!t) return; 1860 if (!t) return;
1861
1832 for (ProgressMap::iterator i = m_progressBars.begin(); 1862 for (ProgressMap::iterator i = m_progressBars.begin();
1833 i != m_progressBars.end(); ++i) { 1863 i != m_progressBars.end(); ++i) {
1864
1834 if (i->second.checkTimer == t) { 1865 if (i->second.checkTimer == t) {
1866
1867 #ifdef DEBUG_PROGRESS_STUFF
1868 SVCERR << "View[" << this << "]::progressCheckStalledTimerElapsed for layer " << i->first << endl;
1869 #endif
1870
1835 int value = i->second.bar->value(); 1871 int value = i->second.bar->value();
1836 if (value > 0 && value == i->second.lastCheck) { 1872 if (value > 0 && value == i->second.lastCheck) {
1837 i->second.bar->setMaximum(0); // indeterminate 1873 i->second.bar->setMaximum(0); // indeterminate
1838 } 1874 }
1839 i->second.lastCheck = value; 1875 i->second.lastCheck = value;