diff --git a/redo/modalqueue.c b/redo/modalqueue.c index 7474c95..a41787f 100644 --- a/redo/modalqueue.c +++ b/redo/modalqueue.c @@ -1,6 +1,8 @@ // 19 august 2014 #include +#include +#include #include "modalqueue.h" static struct { @@ -17,7 +19,7 @@ void beginModal(void) mq.cap = 128; mq.queue = (void **) malloc(mq.cap * sizeof (void *)); if (mq.queue == NULL) - abort();//TODO + modalPanic("error allocating modal queue", strerror(errno)); mq.len = 0; } } @@ -42,7 +44,7 @@ int queueIfModal(void *what) mq.cap *= 2; mq.queue = (void **) realloc(mq.queue, mq.cap * sizeof (void *)); if (mq.queue == NULL) - abort();//TODO + modalPanic("error growing modal queue", strerror(errno)); } return 1; } diff --git a/redo/modalqueue.h b/redo/modalqueue.h index 912ba32..e05db36 100644 --- a/redo/modalqueue.h +++ b/redo/modalqueue.h @@ -6,3 +6,4 @@ extern int queueIfModal(void *); /* needed by the above */ extern void doissue(void *); +extern void modalPanic(char *, char *); diff --git a/redo/uitask_darwin.go b/redo/uitask_darwin.go index 13de8e0..2e0380a 100644 --- a/redo/uitask_darwin.go +++ b/redo/uitask_darwin.go @@ -39,3 +39,8 @@ func issue(f *func()) { func doissue(fp unsafe.Pointer) { perform(fp) } + +//export modalPanic +func modalPanic(reason *C.char, strerror *C.char) { + panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror))) +} diff --git a/redo/uitask_unix.go b/redo/uitask_unix.go index 86628dd..7786d95 100644 --- a/redo/uitask_unix.go +++ b/redo/uitask_unix.go @@ -53,3 +53,8 @@ func doissue(data unsafe.Pointer) { // for the modal queue functions perform(data) } + +//export modalPanic +func modalPanic(reason *C.char, strerror *C.char) { + panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror))) +} diff --git a/redo/uitask_windows.go b/redo/uitask_windows.go index c3c1884..5d9d29a 100644 --- a/redo/uitask_windows.go +++ b/redo/uitask_windows.go @@ -68,3 +68,8 @@ func makemsgwin() error { func doissue(fp unsafe.Pointer) { perform(fp) } + +//export modalPanic +func modalPanic(reason *C.char, strerror *C.char) { + panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror))) +}