Skip to content

Commit 192e22d

Browse files
committed
Merge remote-tracking branch 'benma/libserver'
2 parents 0f7362d + d68b673 commit 192e22d

File tree

5 files changed

+12
-69
lines changed

5 files changed

+12
-69
lines changed

frontends/qt/BitBox.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ SOURCES += \
5656
main.cpp \
5757
filedialog.cpp
5858

59-
HEADERS += libserver.h webclass.h filedialog.h
59+
# server/libserver.h is generated by building server.go, see the Makefiles in server/.
60+
HEADERS += server/libserver.h webclass.h filedialog.h
6061

6162
unix:macx {
6263
# Those frameworks are needed for Go's http/net packages.

frontends/qt/libserver.h

Lines changed: 0 additions & 63 deletions
This file was deleted.

frontends/qt/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include <string.h>
4444

4545
#include "filedialog.h"
46-
#include "libserver.h"
46+
#include "server/libserver.h"
4747
#include "webclass.h"
4848

4949
#define APPNAME "BitBoxApp"

frontends/qt/server/server.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ static char* getSaveFilename(getSaveFilenameCallback f, const char* suggestedfil
4444
return f(suggestedfilename);
4545
}
4646
47-
// see frontends/qt/libserver.h for doc comments
47+
// equivalent to C.free but suitable for releasing a memory malloc'ed
48+
// in a non-posix portable environment, incompatible with cgo.
49+
// this is especially important on windows where the standard C runtime
50+
// memory management used by cgo and mingw is different from win32 API used
51+
// when compiling C++ code with MSVC. hence, the memory allocated with malloc
52+
// in C++ must always be freed by this function in Go instead of C.free.
4853
typedef void (*cppHeapFree) (void* ptr);
4954
static void customHeapFree(cppHeapFree f, void* ptr) {
5055
f(ptr);
@@ -85,7 +90,7 @@ func (communication *nativeCommunication) PushNotify(msg string) {
8590
}
8691

8792
//export backendCall
88-
func backendCall(queryID C.int, s *C.char) {
93+
func backendCall(queryID C.int, s *C.cchar_t) {
8994
bridgecommon.BackendCall(int(queryID), C.GoString(s))
9095
}
9196

@@ -104,7 +109,7 @@ func serve(
104109
pushNotificationsFn C.pushNotificationsCallback,
105110
responseFn C.responseCallback,
106111
notifyUserFn C.notifyUserCallback,
107-
preferredLocale *C.char,
112+
preferredLocale *C.cchar_t,
108113
getSaveFilenameFn C.getSaveFilenameCallback,
109114
) {
110115
log := logging.Get().WithGroup("server")

frontends/qt/webclass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <QApplication>
1616

17-
#include "libserver.h"
17+
#include "server/libserver.h"
1818

1919
class WebClass : public QObject
2020
{

0 commit comments

Comments
 (0)