Skip to content

Commit 1d821a6

Browse files
#533 Block update during repaint
1 parent 6f0a08b commit 1d821a6

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

qtgui/exe/src/DmsExport.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "DmsExport.h"
66
#include "DmsMainWindow.h"
7+
#include "DmsTreeView.h"
78
#include "ExportInfo.h"
89
#include "utl/Environment.h"
910
#include "Parallel.h"
@@ -727,7 +728,14 @@ void DmsExportWindow::exportActiveTabInfoOrCloseAfterExport()
727728
m_export_button->setText("Exporting...");
728729
//m_export_button->setDisabled(true);
729730
m_cancel_button->setDisabled(true);
730-
m_export_button->repaint();
731+
732+
733+
{
734+
MainWindow::TheOne()->m_treeview->setUpdatesEnabled(false);
735+
MainThreadBlocker blockThis;
736+
m_export_button->repaint();
737+
MainWindow::TheOne()->m_treeview->setUpdatesEnabled(true);
738+
}
731739

732740
try {
733741
exportImpl();

rtc/dll/src/act/MainThread.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ RTC_CALL bool IsProcessingMainThreadOpers()
129129
return s_ProcessMainThreadOperLevel != 0;
130130
}
131131

132+
MainThreadBlocker::MainThreadBlocker()
133+
{
134+
++s_ProcessMainThreadOperLevel;
135+
}
136+
137+
MainThreadBlocker::~MainThreadBlocker()
138+
{
139+
--s_ProcessMainThreadOperLevel;
140+
}
141+
132142
void ProcessMainThreadOpers()
133143
{
134144
assert(IsMainThread());

rtc/dll/src/act/MainThread.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,12 @@ RTC_CALL UInt32 GetCallCount();
4545
RTC_CALL UInt32 GetThreadID();
4646
RTC_CALL void AddMainThreadOper(std::function<void()>&& func, bool postAlways = false);
4747
RTC_CALL void ProcessMainThreadOpers();
48+
RTC_CALL bool IsProcessingMainThreadOpers();
49+
50+
struct MainThreadBlocker
51+
{
52+
RTC_CALL MainThreadBlocker();
53+
RTC_CALL ~MainThreadBlocker();
54+
};
4855

4956
#endif // __RTC_ACT_MAINTHREAD_H

0 commit comments

Comments
 (0)