diff --git a/examples/proto_debuger/base_form.cpp b/examples/proto_debuger/base_form.cpp index 8d3747e5..fce48815 100644 --- a/examples/proto_debuger/base_form.cpp +++ b/examples/proto_debuger/base_form.cpp @@ -127,13 +127,13 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) } } mMonitor->GetRootNode()->GetChildNode(1)->RemoveChildNode(p); - delete mRightShow; +// delete mRightShow; mRightShow = nullptr; } + if (uMsg == WM_USER_TCP_SERVER_CLOSE) { wprintf(L"close %s\r\n", ((wstring*)wParam)->c_str()); mRightShow->SetVisible(false); - mRightSide->SetAutoDestroy(true); mRightSide->RemoveAll(); mTcpServerForm.erase(*(wstring*)(wParam)); @@ -146,8 +146,9 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) break; } } - mMonitor->GetRootNode()->GetChildNode(2)->RemoveChildNode(p); - delete mRightShow; + if(nullptr != p) + mMonitor->GetRootNode()->GetChildNode(2)->RemoveChildNode(p); + //delete mRightShow; mRightShow = nullptr; } if (uMsg == WM_USER_POS_CHANGED) { @@ -393,7 +394,6 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) p->SetVisible(true); mRightShow = p; mRightSide->SelectItem(p->GetName()); - } else { p->SetVisible(true); diff --git a/examples/proto_debuger/serial_port.h b/examples/proto_debuger/serial_port.h index f7e0a0a9..d9d5b2f0 100644 --- a/examples/proto_debuger/serial_port.h +++ b/examples/proto_debuger/serial_port.h @@ -5,7 +5,6 @@ using namespace std; - typedef struct{ wstring name; UINT port_num; @@ -31,8 +30,6 @@ typedef struct { class SerialPort { - - public: SerialPort(); ~SerialPort(); @@ -65,16 +62,12 @@ public: //检查指定串口状态 static int PortState(UINT PortNo); - //清空指定串口缓冲区 static void ClearCom(UINT PortNo); - //指定端口RTS信号检测,用于脚踏开关信号触发, static int CheckRTS(UINT PortNo); public: //static UINT PortNum; //串口端口号 static map ComMap; - - }; diff --git a/examples/proto_debuger/tcp_client.cpp b/examples/proto_debuger/tcp_client.cpp index 170b7b0a..3535e1fb 100644 --- a/examples/proto_debuger/tcp_client.cpp +++ b/examples/proto_debuger/tcp_client.cpp @@ -40,10 +40,13 @@ int ThreadRun(TcpClientLibevent *p) { //todo linux鐗堟湰sleep #endif }else { + std::cout << "p->Dispatch()"; ret = p->Dispatch(); } } } + std::cout << "p->Dispatch() finished"; + return 0; } @@ -164,6 +167,8 @@ int TcpClientLibevent::ConnectServer() { bufferevent_free(mBev); mBev = nullptr; printf("Connect failed\n"); + mMux.unlock(); + return -1; } this->mStatus = TcpClientLibevent::CONNECTING; @@ -223,6 +228,7 @@ int TcpClientLibevent::SetObserver(TcpClientLibevent::TcpClientObserver *ob) { } int TcpClientLibevent::Dispatch() { + std::cout << "Dispatch\r\n"; return event_base_dispatch(mBase);; } diff --git a/examples/proto_debuger/tcp_client.h b/examples/proto_debuger/tcp_client.h index e4d8aa61..f6cb3181 100644 --- a/examples/proto_debuger/tcp_client.h +++ b/examples/proto_debuger/tcp_client.h @@ -60,12 +60,15 @@ public: TcpClientLibevent(std::string addrinfo, int port, TcpClientObserver* p); ~TcpClientLibevent() { mMux.lock(); - mStatus = STOP; + mStatus = TcpClientLibevent::STOP; mMux.unlock(); + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 10000; + event_base_loopexit(mBase,&tv); mThread->join(); - event_base_free(mBase); - + std::cout << "12345\r\n"; }; friend void conn_eventcb(struct bufferevent*, short, void*); int ConnectServer(); diff --git a/examples/proto_debuger/tcp_client_form.cpp b/examples/proto_debuger/tcp_client_form.cpp index c5c7d822..effc6989 100644 --- a/examples/proto_debuger/tcp_client_form.cpp +++ b/examples/proto_debuger/tcp_client_form.cpp @@ -6,7 +6,7 @@ #define TCP_CLIENT_SCRIPT "tcp_client.lua" TcpClientForm::~TcpClientForm() { delete mClient; - + std::cout << "45678\r\n"; } TcpClientForm::TcpClientForm(ui::Window* hwnd,std::string url, uint32_t port, TcpClientLibevent* p):