Просмотр исходного кода

修复正餐切换桌子容易崩溃的问题

zhangyang 3 лет назад
Родитель
Сommit
b527194479

+ 11 - 11
zhipuzi_pos_windows/page/CZhengcanPageUI.cpp

@@ -241,7 +241,7 @@ void CZhengcanPageUI::RefreshTableShow()
 
 void CZhengcanPageUI::DoRefreshTable()
 {
-	m_is_refresh_table = true;
+	m_table_mutex.lock();
 
 	m_tableLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("zhengcan_tablelist")));
 	m_tableLayout->RemoveAll();
@@ -263,7 +263,7 @@ void CZhengcanPageUI::DoRefreshTable()
 	bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), params, response);
 	if (ret == false)
 	{
-		m_is_refresh_table = false;
+		m_table_mutex.unlock();
 		return;
 	}
 
@@ -273,14 +273,14 @@ void CZhengcanPageUI::DoRefreshTable()
 	if (document.HasParseError())
 	{
 		LOG_INFO("parse response error!");
-		m_is_refresh_table = false;
+		m_table_mutex.unlock();
 		return;
 	}
 
 	if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
 	{
 		LOG_INFO("json error!");
-		m_is_refresh_table = false;
+		m_table_mutex.unlock();
 		return;
 	}
 
@@ -288,13 +288,13 @@ void CZhengcanPageUI::DoRefreshTable()
 	int errcode = v_errcode.GetInt();
 	if (errcode != 0)
 	{
-		m_is_refresh_table = false;
+		m_table_mutex.unlock();
 		return;
 	}
 
 	if (!document.HasMember("data"))
 	{
-		m_is_refresh_table = false;
+		m_table_mutex.unlock();
 		return;
 	}
 
@@ -326,17 +326,14 @@ void CZhengcanPageUI::DoRefreshTable()
 
 	this->FindSubControl(_T("loading"))->SetVisible(false);
 
-	m_is_refresh_table = false;
+	m_table_mutex.unlock();
 
 	UpdateTablePos();
 }
 
 void CZhengcanPageUI::UpdateTablePos()
 {
-	if (m_is_refresh_table == true)
-	{
-		return;
-	}
+	m_table_mutex.lock();
 
 	int nTableNum = m_table_num;
 
@@ -344,6 +341,7 @@ void CZhengcanPageUI::UpdateTablePos()
 	int nWidth = m_nPageWidth;
 	if (nWidth == 0)
 	{
+		m_table_mutex.unlock();
 		return;
 	}
 
@@ -386,6 +384,8 @@ void CZhengcanPageUI::UpdateTablePos()
 	size.cy = 0;
 	CVerticalLayoutUI* pFenleiLayoutScroll = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("zhengcan_tablelist_scrolllayout")));
 	pFenleiLayoutScroll->SetScrollPos(size);
+
+	m_table_mutex.unlock();
 }
 
 void CZhengcanPageUI::ClickTableAction()

+ 2 - 1
zhipuzi_pos_windows/page/CZhengcanPageUI.h

@@ -83,5 +83,6 @@ private:
 
 	CZhengcanTableItemUI* m_cur_click_table_item;
 
-	bool m_is_refresh_table = false;
+	//µ±Ë¢ÐÂ×À×Óʱ
+	std::mutex m_table_mutex;
 };