Skip to content

Commit 97f5b20

Browse files
committed
refactor: use std::string for thread names
1 parent 29d540b commit 97f5b20

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

src/qt/guiutil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ void PrintSlotException(
982982
std::string description = sender->metaObject()->className();
983983
description += "->";
984984
description += receiver->metaObject()->className();
985-
PrintExceptionContinue(exception, description.c_str());
985+
PrintExceptionContinue(exception, description);
986986
}
987987

988988
void ShowModalDialogAsynchronously(QDialog* dialog)

src/util/system.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message
831831
std::string("\n\n");
832832
}
833833

834-
static std::string FormatException(const std::exception* pex, const char* pszThread)
834+
static std::string FormatException(const std::exception* pex, std::string_view pszThread)
835835
{
836836
#ifdef WIN32
837837
char pszModule[MAX_PATH] = "";
@@ -847,7 +847,7 @@ static std::string FormatException(const std::exception* pex, const char* pszThr
847847
"UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread);
848848
}
849849

850-
void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
850+
void PrintExceptionContinue(const std::exception* pex, std::string_view pszThread)
851851
{
852852
std::string message = FormatException(pex, pszThread);
853853
LogPrintf("\n\n************************\n%s\n", message);

src/util/system.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ bool error(const char* fmt, const Args&... args)
5151
return false;
5252
}
5353

54-
void PrintExceptionContinue(const std::exception *pex, const char* pszThread);
54+
void PrintExceptionContinue(const std::exception* pex, std::string_view pszThread);
5555

5656
/**
5757
* Ensure file contents are fully committed to disk, using a platform-specific

src/util/thread.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010

1111
#include <exception>
1212
#include <functional>
13+
#include <string>
14+
#include <utility>
1315

14-
void util::TraceThread(const char* thread_name, std::function<void()> thread_func)
16+
void util::TraceThread(std::string_view thread_name, std::function<void()> thread_func)
1517
{
16-
util::ThreadRename(thread_name);
18+
util::ThreadRename(std::string{thread_name});
1719
try {
1820
LogPrintf("%s thread start\n", thread_name);
1921
thread_func();

src/util/thread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#define BITCOIN_UTIL_THREAD_H
77

88
#include <functional>
9+
#include <string>
910

1011
namespace util {
1112
/**
1213
* A wrapper for do-something-once thread functions.
1314
*/
14-
void TraceThread(const char* thread_name, std::function<void()> thread_func);
15+
void TraceThread(std::string_view thread_name, std::function<void()> thread_func);
1516

1617
} // namespace util
1718

0 commit comments

Comments
 (0)