Migrated implbug() and userbug() to uipriv forms.
This commit is contained in:
parent
c6bb463692
commit
f93973d3cb
|
@ -1,16 +1,4 @@
|
|||
|
||||
// ugh, this was only introduced in MSVC 2015...
|
||||
#ifdef _MSC_VER
|
||||
#define __func__ __FUNCTION__
|
||||
#endif
|
||||
extern void realbug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap);
|
||||
#define _ns2(s) #s
|
||||
#define _ns(s) _ns2(s)
|
||||
extern void _implbug(const char *file, const char *line, const char *func, const char *format, ...);
|
||||
#define implbug(...) _implbug(__FILE__, _ns(__LINE__), __func__, __VA_ARGS__)
|
||||
extern void _userbug(const char *file, const char *line, const char *func, const char *format, ...);
|
||||
#define userbug(...) _userbug(__FILE__, _ns(__LINE__), __func__, __VA_ARGS__)
|
||||
|
||||
// control.c
|
||||
extern uiControl *newControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr);
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const c
|
|||
void uiFreeControl(uiControl *c)
|
||||
{
|
||||
if (uiControlParent(c) != NULL)
|
||||
userbug("You cannot destroy a uiControl while it still has a parent. (control: %p)", c);
|
||||
uiprivUserBug("You cannot destroy a uiControl while it still has a parent. (control: %p)", c);
|
||||
uiprivFree(c);
|
||||
}
|
||||
|
||||
|
@ -82,12 +82,12 @@ void uiControlVerifySetParent(uiControl *c, uiControl *parent)
|
|||
uiControl *curParent;
|
||||
|
||||
if (uiControlToplevel(c))
|
||||
userbug("You cannot give a toplevel uiControl a parent. (control: %p)", c);
|
||||
uiprivUserBug("You cannot give a toplevel uiControl a parent. (control: %p)", c);
|
||||
curParent = uiControlParent(c);
|
||||
if (parent != NULL && curParent != NULL)
|
||||
userbug("You cannot give a uiControl a parent while it already has one. (control: %p; current parent: %p; new parent: %p)", c, curParent, parent);
|
||||
uiprivUserBug("You cannot give a uiControl a parent while it already has one. (control: %p; current parent: %p; new parent: %p)", c, curParent, parent);
|
||||
if (parent == NULL && curParent == NULL)
|
||||
implbug("attempt to double unparent uiControl %p", c);
|
||||
uiprivImplBug("attempt to double unparent uiControl %p", c);
|
||||
}
|
||||
|
||||
int uiControlEnabledToUser(uiControl *c)
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
#include "../ui.h"
|
||||
#include "uipriv.h"
|
||||
|
||||
void _implbug(const char *file, const char *line, const char *func, const char *format, ...)
|
||||
void uiprivDoImplBug(const char *file, const char *line, const char *func, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
realbug(file, line, func, "POSSIBLE IMPLEMENTATION BUG; CONTACT ANDLABS:\n", format, ap);
|
||||
uiprivRealBug(file, line, func, "POSSIBLE IMPLEMENTATION BUG; CONTACT ANDLABS:\n", format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void _userbug(const char *file, const char *line, const char *func, const char *format, ...)
|
||||
void uiprivDoUserBug(const char *file, const char *line, const char *func, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
realbug(file, line, func, "You have a bug: ", format, ap);
|
||||
uiprivRealBug(file, line, func, "You have a bug: ", format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
|
|
@ -8,24 +8,30 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// OS-specific init.* or main.* files
|
||||
extern uiInitOptions uiprivOptions;
|
||||
|
||||
// OS-specific alloc.* files
|
||||
extern void *uiprivAlloc(size_t, const char *);
|
||||
#define uiprivNew(T) ((T *) uiprivAlloc(sizeof (T), #T))
|
||||
extern void *uiprivRealloc(void *, size_t, const char *);
|
||||
extern void uiprivFree(void *);
|
||||
|
||||
// ugh, this was only introduced in MSVC 2015...
|
||||
// debug.c and OS-specific debug.* files
|
||||
// TODO get rid of this mess...
|
||||
// ugh, __func__ was only introduced in MSVC 2015...
|
||||
#ifdef _MSC_VER
|
||||
#define __func__ __FUNCTION__
|
||||
#define uiprivMacro__func__ __FUNCTION__
|
||||
#else
|
||||
#define uiprivMacro__func__ __func__
|
||||
#endif
|
||||
extern void realbug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap);
|
||||
#define _ns2(s) #s
|
||||
#define _ns(s) _ns2(s)
|
||||
extern void _implbug(const char *file, const char *line, const char *func, const char *format, ...);
|
||||
#define implbug(...) _implbug(__FILE__, _ns(__LINE__), __func__, __VA_ARGS__)
|
||||
extern void _userbug(const char *file, const char *line, const char *func, const char *format, ...);
|
||||
#define userbug(...) _userbug(__FILE__, _ns(__LINE__), __func__, __VA_ARGS__)
|
||||
extern void uiprivRealBug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap);
|
||||
#define uiprivMacro_ns2(s) #s
|
||||
#define uiprivMacro_ns(s) uiprivMacro_ns2(s)
|
||||
extern void uiprivDoImplBug(const char *file, const char *line, const char *func, const char *format, ...);
|
||||
#define uiprivImplBug(...) uiprivDoImplBug(__FILE__, uiprivMacro_ns(__LINE__), uiprivMacro__func__, __VA_ARGS__)
|
||||
extern void uiprivDoUserBug(const char *file, const char *line, const char *func, const char *format, ...);
|
||||
#define uiprivUserBug(...) uiprivDoUserBug(__FILE__, uiprivMacro_ns(__LINE__), uiprivMacro__func__, __VA_ARGS__)
|
||||
|
||||
// control.c
|
||||
extern uiControl *newControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr);
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
void uiUserBugCannotSetParentOnToplevel(const char *type)
|
||||
{
|
||||
userbug("You cannot make a %s a child of another uiControl,", type);
|
||||
uiprivUserBug("You cannot make a %s a child of another uiControl,", type);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ void uninitAlloc(void)
|
|||
ptr = [v pointerValue];
|
||||
[str appendString:[NSString stringWithFormat:@"%p %s\n", ptr, *TYPE(ptr)]];
|
||||
}
|
||||
userbug("Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:\n%s", [str UTF8String]);
|
||||
uiprivUserBug("Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:\n%s", [str UTF8String]);
|
||||
[str release];
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ void *uiprivRealloc(void *p, size_t new, const char *type)
|
|||
void uiprivFree(void *p)
|
||||
{
|
||||
if (p == NULL)
|
||||
implbug("attempt to uiprivFree(NULL)");
|
||||
uiprivImplBug("attempt to uiprivFree(NULL)");
|
||||
p = BASE(p);
|
||||
free(p);
|
||||
[allocations removeObject:[NSValue valueWithPointer:p]];
|
||||
|
|
|
@ -390,7 +390,7 @@ int sendAreaEvents(NSEvent *e)
|
|||
void uiAreaSetSize(uiArea *a, int width, int height)
|
||||
{
|
||||
if (!a->scrolling)
|
||||
userbug("You cannot call uiAreaSetSize() on a non-scrolling uiArea. (area: %p)", a);
|
||||
uiprivUserBug("You cannot call uiAreaSetSize() on a non-scrolling uiArea. (area: %p)", a);
|
||||
[a->area setScrollingSize:NSMakeSize(width, height)];
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ void uiAreaQueueRedrawAll(uiArea *a)
|
|||
void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height)
|
||||
{
|
||||
if (!a->scrolling)
|
||||
userbug("You cannot call uiAreaScrollTo() on a non-scrolling uiArea. (area: %p)", a);
|
||||
uiprivUserBug("You cannot call uiAreaScrollTo() on a non-scrolling uiArea. (area: %p)", a);
|
||||
[a->area scrollRectToVisible:NSMakeRect(x, y, width, height)];
|
||||
// don't worry about the return value; it just says whether scrolling was needed
|
||||
}
|
||||
|
|
|
@ -428,7 +428,7 @@ void uiBoxAppend(uiBox *b, uiControl *c, int stretchy)
|
|||
// LONGTERM on other platforms
|
||||
// or at leat allow this and implicitly turn it into a spacer
|
||||
if (c == NULL)
|
||||
userbug("You cannot add NULL to a uiBox.");
|
||||
uiprivUserBug("You cannot add NULL to a uiBox.");
|
||||
[b->view append:c stretchy:stretchy];
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
// LONGTERM don't halt on release builds
|
||||
|
||||
void realbug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
void uiprivRealBug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
{
|
||||
NSMutableString *str;
|
||||
NSString *formatted;
|
||||
|
|
|
@ -27,7 +27,7 @@ void uiDrawFreePath(uiDrawPath *p)
|
|||
void uiDrawPathNewFigure(uiDrawPath *p, double x, double y)
|
||||
{
|
||||
if (p->ended)
|
||||
userbug("You cannot call uiDrawPathNewFigure() on a uiDrawPath that has already been ended. (path; %p)", p);
|
||||
uiprivUserBug("You cannot call uiDrawPathNewFigure() on a uiDrawPath that has already been ended. (path; %p)", p);
|
||||
CGPathMoveToPoint(p->path, NULL, x, y);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, d
|
|||
double startx, starty;
|
||||
|
||||
if (p->ended)
|
||||
userbug("You cannot call uiDrawPathNewFigureWithArc() on a uiDrawPath that has already been ended. (path; %p)", p);
|
||||
uiprivUserBug("You cannot call uiDrawPathNewFigureWithArc() on a uiDrawPath that has already been ended. (path; %p)", p);
|
||||
sinStart = sin(startAngle);
|
||||
cosStart = cos(startAngle);
|
||||
startx = xCenter + radius * cosStart;
|
||||
|
@ -50,7 +50,7 @@ void uiDrawPathLineTo(uiDrawPath *p, double x, double y)
|
|||
{
|
||||
// TODO refine this to require being in a path
|
||||
if (p->ended)
|
||||
implbug("attempt to add line to ended path in uiDrawPathLineTo()");
|
||||
uiprivImplBug("attempt to add line to ended path in uiDrawPathLineTo()");
|
||||
CGPathAddLineToPoint(p->path, NULL, x, y);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radiu
|
|||
|
||||
// TODO likewise
|
||||
if (p->ended)
|
||||
implbug("attempt to add arc to ended path in uiDrawPathArcTo()");
|
||||
uiprivImplBug("attempt to add arc to ended path in uiDrawPathArcTo()");
|
||||
if (sweep > 2 * uiPi)
|
||||
sweep = 2 * uiPi;
|
||||
cw = false;
|
||||
|
@ -77,7 +77,7 @@ void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, doubl
|
|||
{
|
||||
// TODO likewise
|
||||
if (p->ended)
|
||||
implbug("attempt to add bezier to ended path in uiDrawPathBezierTo()");
|
||||
uiprivImplBug("attempt to add bezier to ended path in uiDrawPathBezierTo()");
|
||||
CGPathAddCurveToPoint(p->path, NULL,
|
||||
c1x, c1y,
|
||||
c2x, c2y,
|
||||
|
@ -88,14 +88,14 @@ void uiDrawPathCloseFigure(uiDrawPath *p)
|
|||
{
|
||||
// TODO likewise
|
||||
if (p->ended)
|
||||
implbug("attempt to close figure of ended path in uiDrawPathCloseFigure()");
|
||||
uiprivImplBug("attempt to close figure of ended path in uiDrawPathCloseFigure()");
|
||||
CGPathCloseSubpath(p->path);
|
||||
}
|
||||
|
||||
void uiDrawPathAddRectangle(uiDrawPath *p, double x, double y, double width, double height)
|
||||
{
|
||||
if (p->ended)
|
||||
userbug("You cannot call uiDrawPathAddRectangle() on a uiDrawPath that has already been ended. (path; %p)", p);
|
||||
uiprivUserBug("You cannot call uiDrawPathAddRectangle() on a uiDrawPath that has already been ended. (path; %p)", p);
|
||||
CGPathAddRect(p->path, NULL, CGRectMake(x, y, width, height));
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStro
|
|||
uiDrawPath p2;
|
||||
|
||||
if (!path->ended)
|
||||
userbug("You cannot call uiDrawStroke() on a uiDrawPath that has not been ended. (path: %p)", path);
|
||||
uiprivUserBug("You cannot call uiDrawStroke() on a uiDrawPath that has not been ended. (path: %p)", path);
|
||||
|
||||
switch (p->Cap) {
|
||||
case uiDrawLineCapFlat:
|
||||
|
@ -280,7 +280,7 @@ static void fillGradient(CGContextRef ctxt, uiDrawPath *p, uiDrawBrush *b)
|
|||
void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b)
|
||||
{
|
||||
if (!path->ended)
|
||||
userbug("You cannot call uiDrawStroke() on a uiDrawPath that has not been ended. (path: %p)", path);
|
||||
uiprivUserBug("You cannot call uiDrawStroke() on a uiDrawPath that has not been ended. (path: %p)", path);
|
||||
CGContextAddPath(c->c, (CGPathRef) (path->path));
|
||||
switch (b->Type) {
|
||||
case uiDrawBrushTypeSolid:
|
||||
|
@ -294,7 +294,7 @@ void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b)
|
|||
// TODO
|
||||
return;
|
||||
}
|
||||
userbug("Unknown brush type %d passed to uiDrawFill().", b->Type);
|
||||
uiprivUserBug("Unknown brush type %d passed to uiDrawFill().", b->Type);
|
||||
}
|
||||
|
||||
static void m2c(uiDrawMatrix *m, CGAffineTransform *c)
|
||||
|
@ -425,7 +425,7 @@ void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m)
|
|||
void uiDrawClip(uiDrawContext *c, uiDrawPath *path)
|
||||
{
|
||||
if (!path->ended)
|
||||
userbug("You cannot call uiDrawCilp() on a uiDrawPath that has not been ended. (path: %p)", path);
|
||||
uiprivUserBug("You cannot call uiDrawCilp() on a uiDrawPath that has not been ended. (path: %p)", path);
|
||||
CGContextAddPath(c->c, (CGPathRef) (path->path));
|
||||
switch (path->fillMode) {
|
||||
case uiDrawFillModeWinding:
|
||||
|
|
|
@ -530,7 +530,7 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy)
|
|||
// LONGTERM on other platforms
|
||||
// or at leat allow this and implicitly turn it into a spacer
|
||||
if (c == NULL)
|
||||
userbug("You cannot add NULL to a uiForm.");
|
||||
uiprivUserBug("You cannot add NULL to a uiForm.");
|
||||
[f->view append:toNSString(label) c:c stretchy:stretchy];
|
||||
}
|
||||
|
||||
|
|
|
@ -574,7 +574,7 @@ struct uiGrid {
|
|||
break;
|
||||
}
|
||||
if (!found)
|
||||
userbug("Existing control %p is not in grid %p; you cannot add other controls next to it", c, self->g);
|
||||
uiprivUserBug("Existing control %p is not in grid %p; you cannot add other controls next to it", c, self->g);
|
||||
|
||||
switch (at) {
|
||||
case uiAtLeading:
|
||||
|
@ -742,9 +742,9 @@ static gridChild *toChild(uiControl *c, int xspan, int yspan, int hexpand, uiAli
|
|||
gridChild *gc;
|
||||
|
||||
if (xspan < 0)
|
||||
userbug("You cannot have a negative xspan in a uiGrid cell.");
|
||||
uiprivUserBug("You cannot have a negative xspan in a uiGrid cell.");
|
||||
if (yspan < 0)
|
||||
userbug("You cannot have a negative yspan in a uiGrid cell.");
|
||||
uiprivUserBug("You cannot have a negative yspan in a uiGrid cell.");
|
||||
gc = [gridChild new];
|
||||
gc.xspan = xspan;
|
||||
gc.yspan = yspan;
|
||||
|
@ -763,7 +763,7 @@ void uiGridAppend(uiGrid *g, uiControl *c, int left, int top, int xspan, int ysp
|
|||
// LONGTERM on other platforms
|
||||
// or at leat allow this and implicitly turn it into a spacer
|
||||
if (c == NULL)
|
||||
userbug("You cannot add NULL to a uiGrid.");
|
||||
uiprivUserBug("You cannot add NULL to a uiGrid.");
|
||||
gc = toChild(c, xspan, yspan, hexpand, halign, vexpand, valign, g);
|
||||
gc.left = left;
|
||||
gc.top = top;
|
||||
|
|
|
@ -57,7 +57,7 @@ static BOOL stepsIsRunning;
|
|||
NSEvent *e;
|
||||
|
||||
if (!canQuit)
|
||||
implbug("call to [NSApp terminate:] when not ready to terminate; definitely contact andlabs");
|
||||
uiprivImplBug("call to [NSApp terminate:] when not ready to terminate; definitely contact andlabs");
|
||||
|
||||
[realNSApp() stop:realNSApp()];
|
||||
// stop: won't register until another event has passed; let's synthesize one
|
||||
|
@ -139,9 +139,8 @@ const char *uiInit(uiInitOptions *o)
|
|||
|
||||
void uiUninit(void)
|
||||
{
|
||||
if (!globalPool) {
|
||||
userbug("You must call uiInit() first!");
|
||||
}
|
||||
if (!globalPool)
|
||||
uiprivUserBug("You must call uiInit() first!");
|
||||
[globalPool release];
|
||||
|
||||
@autoreleasepool {
|
||||
|
|
|
@ -22,7 +22,7 @@ struct mapTable *newMap(void)
|
|||
void mapDestroy(struct mapTable *m)
|
||||
{
|
||||
if ([m->m count] != 0)
|
||||
implbug("attempt to destroy map with items inside");
|
||||
uiprivImplBug("attempt to destroy map with items inside");
|
||||
[m->m release];
|
||||
uiprivFree(m);
|
||||
}
|
||||
|
|
|
@ -80,17 +80,17 @@ static void mapItemReleaser(void *key, void *value)
|
|||
switch (smi->type) {
|
||||
case typeQuit:
|
||||
if (self->hasQuit)
|
||||
userbug("You can't have multiple Quit menu items in one program.");
|
||||
uiprivUserBug("You can't have multiple Quit menu items in one program.");
|
||||
self->hasQuit = YES;
|
||||
break;
|
||||
case typePreferences:
|
||||
if (self->hasPreferences)
|
||||
userbug("You can't have multiple Preferences menu items in one program.");
|
||||
uiprivUserBug("You can't have multiple Preferences menu items in one program.");
|
||||
self->hasPreferences = YES;
|
||||
break;
|
||||
case typeAbout:
|
||||
if (self->hasAbout)
|
||||
userbug("You can't have multiple About menu items in one program.");
|
||||
uiprivUserBug("You can't have multiple About menu items in one program.");
|
||||
self->hasAbout = YES;
|
||||
break;
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ void uiMenuItemDisable(uiMenuItem *item)
|
|||
void uiMenuItemOnClicked(uiMenuItem *item, void (*f)(uiMenuItem *, uiWindow *, void *), void *data)
|
||||
{
|
||||
if (item->type == typeQuit)
|
||||
userbug("You can't call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead.");
|
||||
uiprivUserBug("You can't call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead.");
|
||||
item->onClicked = f;
|
||||
item->onClickedData = data;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
|||
uiMenuItem *item;
|
||||
|
||||
if (menusFinalized)
|
||||
userbug("You can't create a new menu item after menus have been finalized.");
|
||||
uiprivUserBug("You can't create a new menu item after menus have been finalized.");
|
||||
|
||||
item = uiprivNew(uiMenuItem);
|
||||
|
||||
|
@ -315,7 +315,7 @@ uiMenu *uiNewMenu(const char *name)
|
|||
uiMenu *m;
|
||||
|
||||
if (menusFinalized)
|
||||
userbug("You can't create a new menu after menus have been finalized.");
|
||||
uiprivUserBug("You can't create a new menu after menus have been finalized.");
|
||||
if (menus == nil)
|
||||
menus = [NSMutableArray new];
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void uiProgressBarSetValue(uiProgressBar *p, int value)
|
|||
}
|
||||
|
||||
if (value < 0 || value > 100)
|
||||
userbug("Value %d out of range for a uiProgressBar.", value);
|
||||
uiprivUserBug("Value %d out of range for a uiProgressBar.", value);
|
||||
|
||||
// on 10.8 there's an animation when the progress bar increases, just like with Aero
|
||||
if (value == 100) {
|
||||
|
|
|
@ -39,7 +39,7 @@ void uninitAlloc(void)
|
|||
return;
|
||||
}
|
||||
g_ptr_array_foreach(allocations, uninitComplain, &str);
|
||||
userbug("Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:\n%s", str);
|
||||
uiprivUserBug("Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:\n%s", str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ void *uiprivRealloc(void *p, size_t new, const char *type)
|
|||
memset(((uint8_t *) DATA(out)) + *s, 0, new - *s);
|
||||
*s = new;
|
||||
if (g_ptr_array_remove(allocations, p) == FALSE)
|
||||
implbug("%p not found in allocations array in uiprivRealloc()", p);
|
||||
uiprivImplBug("%p not found in allocations array in uiprivRealloc()", p);
|
||||
g_ptr_array_add(allocations, out);
|
||||
return DATA(out);
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ void *uiprivRealloc(void *p, size_t new, const char *type)
|
|||
void uiprivFree(void *p)
|
||||
{
|
||||
if (p == NULL)
|
||||
implbug("attempt to uiprivFree(NULL)");
|
||||
uiprivImplBug("attempt to uiprivFree(NULL)");
|
||||
p = BASE(p);
|
||||
g_free(p);
|
||||
if (g_ptr_array_remove(allocations, p) == FALSE)
|
||||
implbug("%p not found in allocations array in uiprivFree()", p);
|
||||
uiprivImplBug("%p not found in allocations array in uiprivFree()", p);
|
||||
}
|
||||
|
|
|
@ -499,7 +499,7 @@ uiUnixControlAllDefaults(uiArea)
|
|||
void uiAreaSetSize(uiArea *a, int width, int height)
|
||||
{
|
||||
if (!a->scrolling)
|
||||
userbug("You cannot call uiAreaSetSize() on a non-scrolling uiArea. (area: %p)", a);
|
||||
uiprivUserBug("You cannot call uiAreaSetSize() on a non-scrolling uiArea. (area: %p)", a);
|
||||
a->scrollWidth = width;
|
||||
a->scrollHeight = height;
|
||||
gtk_widget_queue_resize(a->areaWidget);
|
||||
|
@ -521,7 +521,7 @@ void uiAreaBeginUserWindowMove(uiArea *a)
|
|||
GtkWidget *toplevel;
|
||||
|
||||
if (a->dragevent == NULL)
|
||||
userbug("cannot call uiAreaBeginUserWindowMove() outside of a Mouse() with Down != 0");
|
||||
uiprivUserBug("cannot call uiAreaBeginUserWindowMove() outside of a Mouse() with Down != 0");
|
||||
// TODO don't we have a libui function for this? did I scrap it?
|
||||
// TODO widget or areaWidget?
|
||||
toplevel = gtk_widget_get_toplevel(a->widget);
|
||||
|
@ -561,7 +561,7 @@ void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge)
|
|||
GtkWidget *toplevel;
|
||||
|
||||
if (a->dragevent == NULL)
|
||||
userbug("cannot call uiAreaBeginUserWindowResize() outside of a Mouse() with Down != 0");
|
||||
uiprivUserBug("cannot call uiAreaBeginUserWindowResize() outside of a Mouse() with Down != 0");
|
||||
// TODO don't we have a libui function for this? did I scrap it?
|
||||
// TODO widget or areaWidget?
|
||||
toplevel = gtk_widget_get_toplevel(a->widget);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
// LONGTERM don't halt on release builds
|
||||
|
||||
void realbug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
void uiprivRealBug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
{
|
||||
char *a, *b;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ static cairo_pattern_t *mkbrush(uiDrawBrush *b)
|
|||
// case uiDrawBrushTypeImage:
|
||||
}
|
||||
if (cairo_pattern_status(pat) != CAIRO_STATUS_SUCCESS)
|
||||
implbug("error creating pattern in mkbrush(): %s",
|
||||
uiprivImplBug("error creating pattern in mkbrush(): %s",
|
||||
cairo_status_to_string(cairo_pattern_status(pat)));
|
||||
switch (b->Type) {
|
||||
case uiDrawBrushTypeLinearGradient:
|
||||
|
|
|
@ -43,7 +43,7 @@ void uiDrawFreePath(uiDrawPath *p)
|
|||
static void add(uiDrawPath *p, struct piece *piece)
|
||||
{
|
||||
if (p->ended)
|
||||
userbug("You cannot modify a uiDrawPath that has been ended. (path: %p)", p);
|
||||
uiprivUserBug("You cannot modify a uiDrawPath that has been ended. (path: %p)", p);
|
||||
g_array_append_vals(p->pieces, piece, 1);
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ void runPath(uiDrawPath *p, cairo_t *cr)
|
|||
void (*arc)(cairo_t *, double, double, double, double, double);
|
||||
|
||||
if (!p->ended)
|
||||
userbug("You cannot draw with a uiDrawPath that has not been ended. (path: %p)", p);
|
||||
uiprivUserBug("You cannot draw with a uiDrawPath that has not been ended. (path: %p)", p);
|
||||
cairo_new_path(cr);
|
||||
for (i = 0; i < p->pieces->len; i++) {
|
||||
piece = &g_array_index(p->pieces, struct piece, i);
|
||||
|
|
18
unix/menu.c
18
unix/menu.c
|
@ -109,7 +109,7 @@ void uiMenuItemDisable(uiMenuItem *item)
|
|||
void uiMenuItemOnClicked(uiMenuItem *item, void (*f)(uiMenuItem *, uiWindow *, void *), void *data)
|
||||
{
|
||||
if (item->type == typeQuit)
|
||||
userbug("You cannot call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead.");
|
||||
uiprivUserBug("You cannot call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead.");
|
||||
item->onClicked = f;
|
||||
item->onClickedData = data;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
|||
uiMenuItem *item;
|
||||
|
||||
if (menusFinalized)
|
||||
userbug("You cannot create a new menu item after menus have been finalized.");
|
||||
uiprivUserBug("You cannot create a new menu item after menus have been finalized.");
|
||||
|
||||
item = uiprivNew(uiMenuItem);
|
||||
|
||||
|
@ -196,7 +196,7 @@ uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name)
|
|||
uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)
|
||||
{
|
||||
if (hasQuit)
|
||||
userbug("You cannot have multiple Quit menu items in the same program.");
|
||||
uiprivUserBug("You cannot have multiple Quit menu items in the same program.");
|
||||
hasQuit = TRUE;
|
||||
newItem(m, typeSeparator, NULL);
|
||||
return newItem(m, typeQuit, NULL);
|
||||
|
@ -205,7 +205,7 @@ uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)
|
|||
uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)
|
||||
{
|
||||
if (hasPreferences)
|
||||
userbug("You cannot have multiple Preferences menu items in the same program.");
|
||||
uiprivUserBug("You cannot have multiple Preferences menu items in the same program.");
|
||||
hasPreferences = TRUE;
|
||||
newItem(m, typeSeparator, NULL);
|
||||
return newItem(m, typePreferences, NULL);
|
||||
|
@ -214,7 +214,7 @@ uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)
|
|||
uiMenuItem *uiMenuAppendAboutItem(uiMenu *m)
|
||||
{
|
||||
if (hasAbout)
|
||||
userbug("You cannot have multiple About menu items in the same program.");
|
||||
uiprivUserBug("You cannot have multiple About menu items in the same program.");
|
||||
hasAbout = TRUE;
|
||||
newItem(m, typeSeparator, NULL);
|
||||
return newItem(m, typeAbout, NULL);
|
||||
|
@ -230,7 +230,7 @@ uiMenu *uiNewMenu(const char *name)
|
|||
uiMenu *m;
|
||||
|
||||
if (menusFinalized)
|
||||
userbug("You cannot create a new menu after menus have been finalized.");
|
||||
uiprivUserBug("You cannot create a new menu after menus have been finalized.");
|
||||
if (menus == NULL)
|
||||
menus = g_array_new(FALSE, TRUE, sizeof (uiMenu *));
|
||||
|
||||
|
@ -308,7 +308,7 @@ static void freeMenuItem(GtkWidget *widget, gpointer data)
|
|||
item = g_array_index(fmi->items, uiMenuItem *, fmi->i);
|
||||
w = (struct menuItemWindow *) g_hash_table_lookup(item->windows, widget);
|
||||
if (g_hash_table_remove(item->windows, widget) == FALSE)
|
||||
implbug("GtkMenuItem %p not in menu item's item/window map", widget);
|
||||
uiprivImplBug("GtkMenuItem %p not in menu item's item/window map", widget);
|
||||
uiprivFree(w);
|
||||
fmi->i++;
|
||||
}
|
||||
|
@ -353,8 +353,8 @@ void uninitMenus(void)
|
|||
for (j = 0; j < m->items->len; j++) {
|
||||
item = g_array_index(m->items, uiMenuItem *, j);
|
||||
if (g_hash_table_size(item->windows) != 0)
|
||||
// TODO is this really a userbug()?
|
||||
implbug("menu item %p (%s) still has uiWindows attached; did you forget to destroy some windows?", item, item->name);
|
||||
// TODO is this really a uiprivUserBug()?
|
||||
uiprivImplBug("menu item %p (%s) still has uiWindows attached; did you forget to destroy some windows?", item, item->name);
|
||||
g_free(item->name);
|
||||
g_hash_table_destroy(item->windows);
|
||||
uiprivFree(item);
|
||||
|
|
|
@ -53,7 +53,7 @@ void uiProgressBarSetValue(uiProgressBar *p, int value)
|
|||
}
|
||||
|
||||
if (value < 0 || value > 100)
|
||||
userbug("Value %d is out of range for a uiProgressBar.", value);
|
||||
uiprivUserBug("Value %d is out of range for a uiProgressBar.", value);
|
||||
|
||||
gtk_progress_bar_set_fraction(p->pbar, ((gdouble) value) / 100);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ void uninitAlloc(void)
|
|||
// note the void * cast; otherwise it'll be treated as a string
|
||||
oss << (void *) (alloc.first) << " " << types[alloc.second] << "\n";
|
||||
ossstr = oss.str();
|
||||
userbug("Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:\n%s", ossstr.c_str());
|
||||
uiprivUserBug("Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:\n%s", ossstr.c_str());
|
||||
}
|
||||
|
||||
#define rawBytes(pa) (&((*pa)[0]))
|
||||
|
@ -57,7 +57,7 @@ void uiprivFree(void *_p)
|
|||
uint8_t *p = (uint8_t *) _p;
|
||||
|
||||
if (p == NULL)
|
||||
implbug("attempt to uiprivFree(NULL)");
|
||||
uiprivImplBug("attempt to uiprivFree(NULL)");
|
||||
types.erase(heap[p]);
|
||||
delete heap[p];
|
||||
heap.erase(p);
|
||||
|
|
|
@ -44,7 +44,7 @@ static WCHAR *expandYear(WCHAR *dts, int n)
|
|||
if (*p == L'\'')
|
||||
break;
|
||||
if (*p == L'\0')
|
||||
implbug("unterminated quote in system-provided locale date string in expandYear()");
|
||||
uiprivImplBug("unterminated quote in system-provided locale date string in expandYear()");
|
||||
*q++ = *p;
|
||||
}
|
||||
// and fall through to copy the closing quote
|
||||
|
|
|
@ -59,7 +59,7 @@ HRESULT _logHRESULT(debugargs, const WCHAR *s, HRESULT hr)
|
|||
return hr;
|
||||
}
|
||||
|
||||
void realbug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
void uiprivRealBug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
{
|
||||
va_list ap2;
|
||||
char *msg;
|
||||
|
|
|
@ -120,7 +120,7 @@ void freeContext(uiDrawContext *c)
|
|||
c->currentClip->Release();
|
||||
if (c->states->size() != 0)
|
||||
// TODO do this on other platforms
|
||||
userbug("You did not balance uiDrawSave() and uiDrawRestore() calls.");
|
||||
uiprivUserBug("You did not balance uiDrawSave() and uiDrawRestore() calls.");
|
||||
delete c->states;
|
||||
uiprivFree(c);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ static ID2D1Brush *makeBrush(uiDrawBrush *b, ID2D1RenderTarget *rt)
|
|||
}
|
||||
|
||||
// TODO do this on all platforms
|
||||
userbug("Invalid brush type %d given to drawing operation.", b->Type);
|
||||
uiprivUserBug("Invalid brush type %d given to drawing operation.", b->Type);
|
||||
// TODO dummy brush?
|
||||
return NULL; // make compiler happy
|
||||
}
|
||||
|
|
|
@ -242,6 +242,6 @@ void uiDrawPathEnd(uiDrawPath *p)
|
|||
ID2D1PathGeometry *pathGeometry(uiDrawPath *p)
|
||||
{
|
||||
if (p->sink != NULL)
|
||||
userbug("You cannot draw with a uiDrawPath that was not ended. (path: %p)", p);
|
||||
uiprivUserBug("You cannot draw with a uiDrawPath that was not ended. (path: %p)", p);
|
||||
return p->path;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ static std::map<HWND, struct handler> handlers;
|
|||
void uiWindowsRegisterWM_COMMANDHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c)
|
||||
{
|
||||
if (handlers[hwnd].commandHandler != NULL)
|
||||
implbug("already registered a WM_COMMAND handler to window handle %p", hwnd);
|
||||
uiprivImplBug("already registered a WM_COMMAND handler to window handle %p", hwnd);
|
||||
handlers[hwnd].commandHandler = handler;
|
||||
handlers[hwnd].c = c;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ void uiWindowsRegisterWM_COMMANDHandler(HWND hwnd, BOOL (*handler)(uiControl *,
|
|||
void uiWindowsRegisterWM_NOTIFYHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *c)
|
||||
{
|
||||
if (handlers[hwnd].notifyHandler != NULL)
|
||||
implbug("already registered a WM_NOTIFY handler to window handle %p", hwnd);
|
||||
uiprivImplBug("already registered a WM_NOTIFY handler to window handle %p", hwnd);
|
||||
handlers[hwnd].notifyHandler = handler;
|
||||
handlers[hwnd].c = c;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ void uiWindowsRegisterWM_NOTIFYHandler(HWND hwnd, BOOL (*handler)(uiControl *, H
|
|||
void uiWindowsRegisterWM_HSCROLLHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c)
|
||||
{
|
||||
if (handlers[hwnd].hscrollHandler != NULL)
|
||||
implbug("already registered a WM_HSCROLL handler to window handle %p", hwnd);
|
||||
uiprivImplBug("already registered a WM_HSCROLL handler to window handle %p", hwnd);
|
||||
handlers[hwnd].hscrollHandler = handler;
|
||||
handlers[hwnd].c = c;
|
||||
}
|
||||
|
@ -47,21 +47,21 @@ void uiWindowsRegisterWM_HSCROLLHandler(HWND hwnd, BOOL (*handler)(uiControl *,
|
|||
void uiWindowsUnregisterWM_COMMANDHandler(HWND hwnd)
|
||||
{
|
||||
if (handlers[hwnd].commandHandler == NULL)
|
||||
implbug("window handle %p not registered to receive WM_COMMAND events", hwnd);
|
||||
uiprivImplBug("window handle %p not registered to receive WM_COMMAND events", hwnd);
|
||||
handlers[hwnd].commandHandler = NULL;
|
||||
}
|
||||
|
||||
void uiWindowsUnregisterWM_NOTIFYHandler(HWND hwnd)
|
||||
{
|
||||
if (handlers[hwnd].notifyHandler == NULL)
|
||||
implbug("window handle %p not registered to receive WM_NOTIFY events", hwnd);
|
||||
uiprivImplBug("window handle %p not registered to receive WM_NOTIFY events", hwnd);
|
||||
handlers[hwnd].notifyHandler = NULL;
|
||||
}
|
||||
|
||||
void uiWindowsUnregisterWM_HSCROLLHandler(HWND hwnd)
|
||||
{
|
||||
if (handlers[hwnd].hscrollHandler == NULL)
|
||||
implbug("window handle %p not registered to receive WM_HSCROLL events", hwnd);
|
||||
uiprivImplBug("window handle %p not registered to receive WM_HSCROLL events", hwnd);
|
||||
handlers[hwnd].hscrollHandler = NULL;
|
||||
}
|
||||
|
||||
|
@ -131,14 +131,14 @@ static std::map<HWND, bool> wininichanges;
|
|||
void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd)
|
||||
{
|
||||
if (wininichanges[hwnd])
|
||||
implbug("window handle %p already subscribed to receive WM_WINICHANGEs", hwnd);
|
||||
uiprivImplBug("window handle %p already subscribed to receive WM_WINICHANGEs", hwnd);
|
||||
wininichanges[hwnd] = true;
|
||||
}
|
||||
|
||||
void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd)
|
||||
{
|
||||
if (!wininichanges[hwnd])
|
||||
implbug("window handle %p not registered to receive WM_WININICHANGEs", hwnd);
|
||||
uiprivImplBug("window handle %p not registered to receive WM_WININICHANGEs", hwnd);
|
||||
wininichanges[hwnd] = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -562,9 +562,9 @@ static struct gridChild *toChild(uiControl *c, int xspan, int yspan, int hexpand
|
|||
struct gridChild *gc;
|
||||
|
||||
if (xspan < 0)
|
||||
userbug("You cannot have a negative xspan in a uiGrid cell.");
|
||||
uiprivUserBug("You cannot have a negative xspan in a uiGrid cell.");
|
||||
if (yspan < 0)
|
||||
userbug("You cannot have a negative yspan in a uiGrid cell.");
|
||||
uiprivUserBug("You cannot have a negative yspan in a uiGrid cell.");
|
||||
gc = uiprivNew(struct gridChild);
|
||||
gc->c = c;
|
||||
gc->xspan = xspan;
|
||||
|
|
|
@ -87,7 +87,7 @@ void uiMenuItemDisable(uiMenuItem *i)
|
|||
void uiMenuItemOnClicked(uiMenuItem *i, void (*f)(uiMenuItem *, uiWindow *, void *), void *data)
|
||||
{
|
||||
if (i->type == typeQuit)
|
||||
userbug("You can not call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead.");
|
||||
uiprivUserBug("You can not call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead.");
|
||||
i->onClicked = f;
|
||||
i->onClickedData = data;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
|||
uiMenuItem *item;
|
||||
|
||||
if (menusFinalized)
|
||||
userbug("You can not create a new menu item after menus have been finalized.");
|
||||
uiprivUserBug("You can not create a new menu item after menus have been finalized.");
|
||||
|
||||
if (m->len >= m->cap) {
|
||||
m->cap += grow;
|
||||
|
@ -169,7 +169,7 @@ uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name)
|
|||
uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)
|
||||
{
|
||||
if (hasQuit)
|
||||
userbug("You can not have multiple Quit menu items in a program.");
|
||||
uiprivUserBug("You can not have multiple Quit menu items in a program.");
|
||||
hasQuit = TRUE;
|
||||
newItem(m, typeSeparator, NULL);
|
||||
return newItem(m, typeQuit, NULL);
|
||||
|
@ -178,7 +178,7 @@ uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)
|
|||
uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)
|
||||
{
|
||||
if (hasPreferences)
|
||||
userbug("You can not have multiple Preferences menu items in a program.");
|
||||
uiprivUserBug("You can not have multiple Preferences menu items in a program.");
|
||||
hasPreferences = TRUE;
|
||||
newItem(m, typeSeparator, NULL);
|
||||
return newItem(m, typePreferences, NULL);
|
||||
|
@ -187,8 +187,8 @@ uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)
|
|||
uiMenuItem *uiMenuAppendAboutItem(uiMenu *m)
|
||||
{
|
||||
if (hasAbout)
|
||||
// TODO place these userbug strings in a header
|
||||
userbug("You can not have multiple About menu items in a program.");
|
||||
// TODO place these uiprivImplBug() and uiprivUserBug() strings in a header
|
||||
uiprivUserBug("You can not have multiple About menu items in a program.");
|
||||
hasAbout = TRUE;
|
||||
newItem(m, typeSeparator, NULL);
|
||||
return newItem(m, typeAbout, NULL);
|
||||
|
@ -204,7 +204,7 @@ uiMenu *uiNewMenu(const char *name)
|
|||
uiMenu *m;
|
||||
|
||||
if (menusFinalized)
|
||||
userbug("You can not create a new menu after menus have been finalized.");
|
||||
uiprivUserBug("You can not create a new menu after menus have been finalized.");
|
||||
if (len >= cap) {
|
||||
cap += grow;
|
||||
menus = (uiMenu **) uiprivRealloc(menus, cap * sizeof (uiMenu *), "uiMenu *[]");
|
||||
|
@ -293,7 +293,7 @@ void runMenuEvent(WORD id, uiWindow *w)
|
|||
}
|
||||
}
|
||||
// no match
|
||||
implbug("unknown menu ID %hu in runMenuEvent()", id);
|
||||
uiprivImplBug("unknown menu ID %hu in runMenuEvent()", id);
|
||||
|
||||
found:
|
||||
// first toggle checkboxes, if any
|
||||
|
@ -316,7 +316,7 @@ static void freeMenu(uiMenu *m, HMENU submenu)
|
|||
if (item->hmenus[j] == submenu)
|
||||
break;
|
||||
if (j >= item->len)
|
||||
implbug("submenu handle %p not found in freeMenu()", submenu);
|
||||
uiprivImplBug("submenu handle %p not found in freeMenu()", submenu);
|
||||
for (; j < item->len - 1; j++)
|
||||
item->hmenus[j] = item->hmenus[j + 1];
|
||||
item->hmenus[j] = NULL;
|
||||
|
@ -352,8 +352,8 @@ void uninitMenus(void)
|
|||
for (j = 0; j < m->len; j++) {
|
||||
item = m->items[j];
|
||||
if (item->len != 0)
|
||||
// LONGTERM userbug()?
|
||||
implbug("menu item %p (%ws) still has uiWindows attached; did you forget to destroy some windows?", item, item->name);
|
||||
// LONGTERM uiprivUserBug()?
|
||||
uiprivImplBug("menu item %p (%ws) still has uiWindows attached; did you forget to destroy some windows?", item, item->name);
|
||||
if (item->name != NULL)
|
||||
uiprivFree(item->name);
|
||||
if (item->hmenus != NULL)
|
||||
|
|
|
@ -54,7 +54,7 @@ void uiProgressBarSetValue(uiProgressBar *p, int value)
|
|||
}
|
||||
|
||||
if (value < 0 || value > 100)
|
||||
userbug("Value %d is out of range for uiProgressBars.", value);
|
||||
uiprivUserBug("Value %d is out of range for uiProgressBars.", value);
|
||||
|
||||
if (value == 100) { // because we can't 101
|
||||
SendMessageW(p->hwnd, PBM_SETRANGE32, 0, 101);
|
||||
|
|
Loading…
Reference in New Issue