mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 08:01:51 +08:00
#66 [GUI] fixed disconnection problem when hitting cancel-button while receiving data and there is no need to restart GUI after unexpected disconnect
This commit is contained in:
parent
5e2d8e3be6
commit
a32d3576c6
@ -1411,6 +1411,7 @@ void EasyMainWindow::onFrameTimeRequestTimeout()
|
||||
}
|
||||
else if (!m_listener.connected())
|
||||
{
|
||||
m_listener.closeSocket();
|
||||
setDisconnected();
|
||||
}
|
||||
}
|
||||
@ -1518,10 +1519,11 @@ void EasyMainWindow::onListenerDialogClose(int _result)
|
||||
if (m_listener.connected())
|
||||
{
|
||||
// make reconnect to clear socket buffers
|
||||
std::string address = m_listener.address();
|
||||
const std::string address = m_listener.address();
|
||||
const auto port = m_listener.port();
|
||||
|
||||
profiler::net::EasyProfilerStatus reply(false, false, false);
|
||||
if (m_listener.connect(address.c_str(), m_listener.port(), reply))
|
||||
if (m_listener.reconnect(address.c_str(), port, reply))
|
||||
{
|
||||
disconnect(m_eventTracingEnableAction, &QAction::triggered, this, &This::onEventTracingEnableChange);
|
||||
disconnect(m_eventTracingPriorityAction, &QAction::triggered, this, &This::onEventTracingPriorityChange);
|
||||
@ -1570,6 +1572,7 @@ void EasyMainWindow::onListenerDialogClose(int _result)
|
||||
|
||||
if (!m_listener.connected())
|
||||
{
|
||||
m_listener.closeSocket();
|
||||
setDisconnected();
|
||||
}
|
||||
}
|
||||
@ -1925,7 +1928,10 @@ void EasyMainWindow::onConnectClicked(bool)
|
||||
{
|
||||
QMessageBox::warning(this, "Warning", QString("Cannot connect to %1").arg(address), QMessageBox::Close);
|
||||
if (EASY_GLOBALS.connected)
|
||||
{
|
||||
m_listener.closeSocket();
|
||||
setDisconnected(false);
|
||||
}
|
||||
|
||||
if (!isSameAddress)
|
||||
{
|
||||
@ -2001,12 +2007,14 @@ void EasyMainWindow::onCaptureClicked(bool)
|
||||
profiler::net::EasyProfilerStatus reply(false, false, false);
|
||||
if (!m_listener.connect(m_lastAddress.toStdString().c_str(), m_lastPort, reply))
|
||||
{
|
||||
m_listener.closeSocket();
|
||||
setDisconnected();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_listener.startCapture())
|
||||
{
|
||||
m_listener.closeSocket();
|
||||
setDisconnected();
|
||||
return;
|
||||
}
|
||||
@ -2164,6 +2172,7 @@ void EasyMainWindow::onGetBlockDescriptionsClicked(bool)
|
||||
|
||||
if (!m_listener.connected())
|
||||
{
|
||||
m_listener.closeSocket();
|
||||
setDisconnected();
|
||||
}
|
||||
}
|
||||
@ -2254,11 +2263,16 @@ void EasySocketListener::disconnect()
|
||||
m_address.clear();
|
||||
m_port = 0;
|
||||
|
||||
closeSocket();
|
||||
}
|
||||
|
||||
void EasySocketListener::closeSocket()
|
||||
{
|
||||
m_easySocket.flush();
|
||||
m_easySocket.init();
|
||||
}
|
||||
|
||||
bool EasySocketListener::connect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply)
|
||||
bool EasySocketListener::connect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply, bool _disconnectFirst)
|
||||
{
|
||||
if (connected())
|
||||
{
|
||||
@ -2275,8 +2289,9 @@ bool EasySocketListener::connect(const char* _ipaddress, uint16_t _port, profile
|
||||
m_address.clear();
|
||||
m_port = 0;
|
||||
|
||||
//m_easySocket.flush();
|
||||
//m_easySocket.init();
|
||||
if (_disconnectFirst)
|
||||
closeSocket();
|
||||
|
||||
int res = m_easySocket.setAddress(_ipaddress, _port);
|
||||
res = m_easySocket.connect();
|
||||
|
||||
@ -2337,6 +2352,11 @@ bool EasySocketListener::connect(const char* _ipaddress, uint16_t _port, profile
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
bool EasySocketListener::reconnect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply)
|
||||
{
|
||||
return connect(_ipaddress, _port, _reply, true);
|
||||
}
|
||||
|
||||
bool EasySocketListener::startCapture()
|
||||
{
|
||||
//if (m_thread.joinable())
|
||||
|
@ -167,7 +167,9 @@ public:
|
||||
void clearData();
|
||||
|
||||
void disconnect();
|
||||
bool connect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply);
|
||||
void closeSocket();
|
||||
bool connect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply, bool _disconnectFirst = false);
|
||||
bool reconnect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply);
|
||||
|
||||
bool startCapture();
|
||||
void stopCapture();
|
||||
@ -178,7 +180,8 @@ public:
|
||||
bool requestFrameTime();
|
||||
|
||||
template <class T>
|
||||
inline void send(const T& _message) {
|
||||
inline void send(const T& _message)
|
||||
{
|
||||
m_easySocket.send(&_message, sizeof(T));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user