From b9563def246940c744e40b76ed37d556506bf25f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 15 Jun 2022 16:00:18 +0000 Subject: [PATCH] Add IP/port info to "connection failed" dialog --- src/vconnect.cc | 4 +++- src/vinfo.cc | 22 ++++++++++------------ src/vinfo.h | 3 ++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/vconnect.cc b/src/vconnect.cc index fc07c93..0755ccd 100644 --- a/src/vconnect.cc +++ b/src/vconnect.cc @@ -254,7 +254,9 @@ bool VConnect::attemptConnect(const VDRServer* vdrServer) if (!connectSuccess) { - setOneLiner(tr("Connection failed")); + std::stringstream connFailedString; + connFailedString << tr("Connection failed") << " to " << vdrServer->ip << " port " << vdrServer->port; + setOneLiner(connFailedString.str()); draw(); boxstack->update(this); { diff --git a/src/vinfo.cc b/src/vinfo.cc index 262b023..d1dae30 100644 --- a/src/vinfo.cc +++ b/src/vinfo.cc @@ -27,7 +27,6 @@ VInfo::VInfo() { - mainText = NULL; exitable = 0; dropThrough = 0; @@ -40,7 +39,6 @@ VInfo::VInfo() VInfo::~VInfo() { MessageQueue::getInstance()->removeReceiver(this); - if (mainText) delete[] mainText; } void VInfo::setExitable() @@ -55,19 +53,19 @@ void VInfo::setDropThrough() void VInfo::setMainText(const char* takeText) { - if (mainText) delete[] mainText; - int length = strlen(takeText); - mainText = new char[length + 1]; - strcpy(mainText, takeText); + mainText = takeText; mainTextType = NORMAL; } void VInfo::setOneLiner(const char* takeText) { - if (mainText) delete[] mainText; - int length = strlen(takeText); - mainText = new char[length + 1]; - strcpy(mainText, takeText); + mainText = takeText; + mainTextType = ONELINER; +} + +void VInfo::setOneLiner(const std::string& takeText) +{ + mainText = takeText; mainTextType = ONELINER; } @@ -75,11 +73,11 @@ void VInfo::draw() { TBBoxx::draw(); - if (mainText) + if (mainText.size()) { if (mainTextType == NORMAL) { - drawPara(mainText, 10, 45, DrawStyle::LIGHTTEXT); + drawPara(mainText.c_str() /* FIXME */, 10, 45, DrawStyle::LIGHTTEXT); } if (mainTextType == ONELINER) diff --git a/src/vinfo.h b/src/vinfo.h index a13e7c7..1f051ea 100644 --- a/src/vinfo.h +++ b/src/vinfo.h @@ -37,6 +37,7 @@ class VInfo : public TBBoxx, public MessageReceiver void setMainText(const char* title); void setOneLiner(const char* text); + void setOneLiner(const std::string& text); void setExitable(); void setDropThrough(); void okButton(); @@ -46,7 +47,7 @@ class VInfo : public TBBoxx, public MessageReceiver void draw(); protected: - char* mainText; + std::string mainText; UCHAR exitable; UCHAR dropThrough; UCHAR mainTextType; -- 2.39.5