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