Renamed uiFreeEvent() to uiEventFree() for consistency with uiControlFree().
This commit is contained in:
parent
57dc482f2a
commit
26e492539d
|
@ -60,7 +60,7 @@ uiEvent *uiNewEvent(const uiEventOptions *options)
|
|||
return ret; \
|
||||
}
|
||||
|
||||
void uiFreeEvent(uiEvent *e)
|
||||
void uiEventFree(uiEvent *e)
|
||||
{
|
||||
if (!uiprivCheckInitializedAndThread())
|
||||
return;
|
||||
|
|
|
@ -50,15 +50,15 @@ uiEvent *uiNewEvent(const uiEventOptions *options);
|
|||
|
||||
It is a programmer error to specify `NULL` for `options`.
|
||||
|
||||
### `uiFreeEvent()`
|
||||
### `uiEventFree()`
|
||||
|
||||
```c
|
||||
uiprivExtern void uiFreeEvent(uiEvent *e);
|
||||
uiprivExtern void uiEventFree(uiEvent *e);
|
||||
```
|
||||
|
||||
Frees the given event. The event must not be a libui-provided event, and must not have any handlers registered to it.
|
||||
|
||||
It is a programmer error to pass `NULL` for `e`. It is also a programmer error to call `uiFreeEvent()` on an event while that event is being fired.
|
||||
It is a programmer error to pass `NULL` for `e`. It is also a programmer error to call `uiEventFree()` on an event while that event is being fired.
|
||||
|
||||
### `uiEventAddHandler()`
|
||||
|
||||
|
|
|
@ -165,9 +165,9 @@ static void deferFree(testingT *t, void *data)
|
|||
free(data);
|
||||
}
|
||||
|
||||
static void deferFreeEvent(testingT *t, void *data)
|
||||
static void deferEventFree(testingT *t, void *data)
|
||||
{
|
||||
uiFreeEvent((uiEvent *) data);
|
||||
uiEventFree((uiEvent *) data);
|
||||
}
|
||||
|
||||
static void deferUnregisterHandler(testingT *t, void *data)
|
||||
|
@ -186,7 +186,7 @@ static void basicEventFunctionalityImpl(testingT *t, void *data)
|
|||
opts.Size = sizeof (uiEventOptions);
|
||||
opts.Global = p->global;
|
||||
e = uiNewEvent(&opts);
|
||||
testingTDefer(t, deferFreeEvent, e);
|
||||
testingTDefer(t, deferEventFree, e);
|
||||
|
||||
h = allocHandlers(t, 1);
|
||||
testingTDefer(t, deferFree, h);
|
||||
|
@ -219,7 +219,7 @@ static void addDeleteEventHandlersImpl(testingT *t, void *data)
|
|||
opts.Size = sizeof (uiEventOptions);
|
||||
opts.Global = p->global;
|
||||
e = uiNewEvent(&opts);
|
||||
testingTDefer(t, deferFreeEvent, e);
|
||||
testingTDefer(t, deferEventFree, e);
|
||||
|
||||
h = allocHandlers(t, 6);
|
||||
testingTDefer(t, deferFree, h);
|
||||
|
@ -341,7 +341,7 @@ static void eventSendersHonoredImpl(testingT *t, void *data)
|
|||
opts.Size = sizeof (uiEventOptions);
|
||||
opts.Global = false;
|
||||
e = uiNewEvent(&opts);
|
||||
testingTDefer(t, deferFreeEvent, e);
|
||||
testingTDefer(t, deferEventFree, e);
|
||||
|
||||
h = allocHandlers(t, 4);
|
||||
testingTDefer(t, deferFree, h);
|
||||
|
@ -447,7 +447,7 @@ static void eventBlocksHonoredImpl(testingT *t, void *data)
|
|||
opts.Size = sizeof (uiEventOptions);
|
||||
opts.Global = p->global;
|
||||
e = uiNewEvent(&opts);
|
||||
testingTDefer(t, deferFreeEvent, e);
|
||||
testingTDefer(t, deferEventFree, e);
|
||||
|
||||
h = allocHandlers(t, 3);
|
||||
testingTDefer(t, deferFree, h);
|
||||
|
@ -577,7 +577,7 @@ static void eventBlocksHonoredWithDifferentSendersImpl(testingT *t, void *data)
|
|||
opts.Size = sizeof (uiEventOptions);
|
||||
opts.Global = false;
|
||||
e = uiNewEvent(&opts);
|
||||
testingTDefer(t, deferFreeEvent, e);
|
||||
testingTDefer(t, deferEventFree, e);
|
||||
|
||||
h = allocHandlers(t, 4);
|
||||
testingTDefer(t, deferFree, h);
|
||||
|
@ -756,8 +756,8 @@ static void testWhileFiring(void *sender, void *args, void *data)
|
|||
idPlaceholder = 0;
|
||||
blockedPlaceholder = false;
|
||||
|
||||
testProgrammerError(t, uiFreeEvent(firingEvent),
|
||||
"attempt to change a uiEvent with uiFreeEvent() while it is firing");
|
||||
testProgrammerError(t, uiEventFree(firingEvent),
|
||||
"attempt to change a uiEvent with uiEventFree() while it is firing");
|
||||
testProgrammerError(t, uiEventAddHandler(firingEvent, handler, senderPlaceholder, dataPlaceholder),
|
||||
"attempt to change a uiEvent with uiEventAddHandler() while it is firing");
|
||||
testProgrammerError(t, uiEventDeleteHandler(firingEvent, idPlaceholder),
|
||||
|
@ -804,13 +804,13 @@ testingTest(EventErrors)
|
|||
opts.Size = sizeof (uiEventOptions);
|
||||
opts.Global = true;
|
||||
globalEvent = uiNewEvent(&opts);
|
||||
testingTDefer(t, deferFreeEvent, globalEvent);
|
||||
testingTDefer(t, deferEventFree, globalEvent);
|
||||
opts.Global = false;
|
||||
nonglobalEvent = uiNewEvent(&opts);
|
||||
testingTDefer(t, deferFreeEvent, nonglobalEvent);
|
||||
testingTDefer(t, deferEventFree, nonglobalEvent);
|
||||
|
||||
testProgrammerError(t, uiFreeEvent(NULL),
|
||||
"invalid null pointer for uiEvent passed into uiFreeEvent()");
|
||||
testProgrammerError(t, uiEventFree(NULL),
|
||||
"invalid null pointer for uiEvent passed into uiEventFree()");
|
||||
// We test trying to free a uiEvent with handlers later, when we actually need to make one for testing firing.
|
||||
|
||||
eventPlaceholder = globalEvent;
|
||||
|
@ -856,7 +856,7 @@ testingTest(EventErrors)
|
|||
opts.Size = sizeof (uiEventOptions);
|
||||
opts.Global = true;
|
||||
firingEvent = uiNewEvent(&opts);
|
||||
testingTDefer(t, deferFreeEvent, firingEvent);
|
||||
testingTDefer(t, deferEventFree, firingEvent);
|
||||
fp = (struct deferDeleteFiringHandlerParams *) malloc(sizeof (struct deferDeleteFiringHandlerParams));
|
||||
if (fp == NULL)
|
||||
testingTFatalf(t, "memory exhausted allocating storage for deleting firing event handler");
|
||||
|
@ -864,7 +864,7 @@ testingTest(EventErrors)
|
|||
fp->e = firingEvent;
|
||||
fp->id = uiEventAddHandler(fp->e, testWhileFiring, NULL, t);
|
||||
testingTDefer(t, deferDeleteFiringHandler, fp);
|
||||
testProgrammerError(t, uiFreeEvent(firingEvent),
|
||||
testProgrammerError(t, uiEventFree(firingEvent),
|
||||
"attempt to free a uiEvent that still has handlers registered");
|
||||
uiEventFire(firingEvent, NULL, firingEvent);
|
||||
}
|
||||
|
|
2
ui.h
2
ui.h
|
@ -54,7 +54,7 @@ struct uiEventOptions {
|
|||
};
|
||||
|
||||
uiprivExtern uiEvent *uiNewEvent(const uiEventOptions *options);
|
||||
uiprivExtern void uiFreeEvent(uiEvent *e);
|
||||
uiprivExtern void uiEventFree(uiEvent *e);
|
||||
uiprivExtern int uiEventAddHandler(uiEvent *e, uiEventHandler handler, void *sender, void *data);
|
||||
uiprivExtern void uiEventDeleteHandler(uiEvent *e, int id);
|
||||
uiprivExtern void uiEventFire(uiEvent *e, void *sender, void *args);
|
||||
|
|
Loading…
Reference in New Issue