From 6e88ab611af31732314103393ae7c37475cf395b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 25 Nov 2015 17:42:25 -0500 Subject: [PATCH] Fixed most of the various bugs preventing this libui from working. Woo! It even works from Go! --- wpf/init.c | 1 + wpf/text.cpp | 5 ++++- wpf/window.cpp | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wpf/init.c b/wpf/init.c index 5834e5d8..994dbdc6 100644 --- a/wpf/init.c +++ b/wpf/init.c @@ -92,6 +92,7 @@ void uiUninit(void) { uninitWPF(); CoUninitialize(); + uninitTypes(); uninitAlloc(); } diff --git a/wpf/text.cpp b/wpf/text.cpp index 9b956eff..313a1cda 100644 --- a/wpf/text.cpp +++ b/wpf/text.cpp @@ -9,9 +9,12 @@ using namespace System::Runtime::InteropServices; String ^fromUTF8(const char *str) { array ^bytes; + size_t len; + len = strlen(str); + bytes = gcnew array(len); // TODO avoid the cast - Marshal::Copy(IntPtr((char *) str), bytes, 0, strlen(str)); + Marshal::Copy(IntPtr((char *) str), bytes, 0, len); return Encoding::UTF8->GetString(bytes); } diff --git a/wpf/window.cpp b/wpf/window.cpp index 74cb961e..a8fea67e 100644 --- a/wpf/window.cpp +++ b/wpf/window.cpp @@ -28,7 +28,11 @@ uiWindowsDefineControlWithOnDestroy( void libuiWindow::onClosing(Object ^sender, CancelEventArgs ^e) { - e->Cancel = (*(this->w->onClosing))(this->w, this->w->onClosingData) == 0; + // TODO copy comments + if ((*(this->w->onClosing))(this->w, this->w->onClosingData)) + // TODO this triggers another onClosing() when it's too late + uiControlDestroy(uiControl(this->w)); + e->Cancel = true; } static int defaultOnClosing(uiWindow *w, void *data)