Got rid of most of Windows's complain()s.
This commit is contained in:
parent
6d2d977363
commit
8067dc76b7
|
@ -44,7 +44,7 @@ static WCHAR *expandYear(WCHAR *dts, int n)
|
||||||
if (*p == L'\'')
|
if (*p == L'\'')
|
||||||
break;
|
break;
|
||||||
if (*p == L'\0')
|
if (*p == L'\0')
|
||||||
complain("unterminated quote in system-provided locale date string in expandYear()");
|
implbug("unterminated quote in system-provided locale date string in expandYear()");
|
||||||
*q++ = *p;
|
*q++ = *p;
|
||||||
}
|
}
|
||||||
// and fall through to copy the closing quote
|
// and fall through to copy the closing quote
|
||||||
|
|
|
@ -71,10 +71,10 @@ void realbug(const char *file, const char *line, const char *func, const char *p
|
||||||
va_copy(ap2, ap);
|
va_copy(ap2, ap);
|
||||||
n = _vscprintf(format, ap2);
|
n = _vscprintf(format, ap2);
|
||||||
va_end(ap2);
|
va_end(ap2);
|
||||||
n++; // terminating L'\0'
|
n++; // terminating '\0'
|
||||||
|
|
||||||
buf = (char *) uiAlloc(n * sizeof (char), "char[]");
|
buf = (char *) uiAlloc(n * sizeof (char), "char[]");
|
||||||
// includes terminating L'\0' according to example in https://msdn.microsoft.com/en-us/library/xa1a1a6z.aspx
|
// includes terminating '\0' according to example in https://msdn.microsoft.com/en-us/library/xa1a1a6z.aspx
|
||||||
vsprintf_s(msg, n, format, ap);
|
vsprintf_s(msg, n, format, ap);
|
||||||
|
|
||||||
final = strf(L"[libui] %hs:%hs:%hs() %hs%hs\n", file, line, func, prefix, msg);
|
final = strf(L"[libui] %hs:%hs:%hs() %hs%hs\n", file, line, func, prefix, msg);
|
||||||
|
|
|
@ -95,8 +95,8 @@ void freeContext(uiDrawContext *c)
|
||||||
if (c->currentClip != NULL)
|
if (c->currentClip != NULL)
|
||||||
c->currentClip->Release();
|
c->currentClip->Release();
|
||||||
if (c->states->size() != 0)
|
if (c->states->size() != 0)
|
||||||
// TODO userbug()
|
// TODO do this on other platforms
|
||||||
complain("unbalanced save/restore");
|
userbug("You did not balance uiDrawSave() and uiDrawRestore() calls.");
|
||||||
delete c->states;
|
delete c->states;
|
||||||
uiFree(c);
|
uiFree(c);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,9 @@ static ID2D1Brush *makeBrush(uiDrawBrush *b, ID2D1RenderTarget *rt)
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
complain("invalid brush type %d in makeBrush()", b->Type);
|
// TODO do this on all platforms
|
||||||
|
userbug("Invalid brush type %d given to drawing operation.", b->Type);
|
||||||
|
// TODO dummy brush?
|
||||||
return NULL; // make compiler happy
|
return NULL; // make compiler happy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,6 @@ void uiDrawPathEnd(uiDrawPath *p)
|
||||||
ID2D1PathGeometry *pathGeometry(uiDrawPath *p)
|
ID2D1PathGeometry *pathGeometry(uiDrawPath *p)
|
||||||
{
|
{
|
||||||
if (p->sink != NULL)
|
if (p->sink != NULL)
|
||||||
// TODO userbug()
|
userbug("You cannot draw with a uiDrawPath that was not ended. (path: %p)", p);
|
||||||
complain("path not ended");
|
|
||||||
return p->path;
|
return p->path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ void attrToDWriteAttr(struct dwriteAttr *attr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
complain("invalid weight %d passed to attrToDWriteAttr()", attr->weight);
|
userbug("Invalid text weight %d passed to text function.", attr->weight);
|
||||||
|
|
||||||
found = false;
|
found = false;
|
||||||
for (i = 0; ; i++) {
|
for (i = 0; ; i++) {
|
||||||
|
@ -152,7 +152,7 @@ void attrToDWriteAttr(struct dwriteAttr *attr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
complain("invalid italic %d passed to attrToDWriteAttr()", attr->italic);
|
userbug("Invalid text italic %d passed to text function.", attr->italic);
|
||||||
|
|
||||||
found = false;
|
found = false;
|
||||||
for (i = 0; ; i++) {
|
for (i = 0; ; i++) {
|
||||||
|
@ -165,7 +165,8 @@ void attrToDWriteAttr(struct dwriteAttr *attr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
complain("invalid stretch %d passed to attrToDWriteAttr()", attr->stretch);
|
// TODO on other platforms too
|
||||||
|
userbug("Invalid text stretch %d passed to text function.", attr->stretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dwriteAttrToAttr(struct dwriteAttr *attr)
|
void dwriteAttrToAttr(struct dwriteAttr *attr)
|
||||||
|
@ -204,7 +205,8 @@ void dwriteAttrToAttr(struct dwriteAttr *attr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
complain("invalid italic %d passed to dwriteAttrToAttr()", attr->ditalic);
|
// these are implbug()s because users shouldn't be able to get here directly; TODO?
|
||||||
|
implbug("invalid italic %d passed to dwriteAttrToAttr()", attr->ditalic);
|
||||||
|
|
||||||
found = false;
|
found = false;
|
||||||
for (i = 0; ; i++) {
|
for (i = 0; ; i++) {
|
||||||
|
@ -217,7 +219,7 @@ void dwriteAttrToAttr(struct dwriteAttr *attr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
complain("invalid stretch %d passed to dwriteAttrToAttr()", attr->dstretch);
|
implbug("invalid stretch %d passed to dwriteAttrToAttr()", attr->dstretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
||||||
|
@ -242,7 +244,7 @@ uiDrawTextFont *uiDrawLoadClosestFont(const uiDrawTextFontDescriptor *desc)
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT(L"error finding font family", hr);
|
logHRESULT(L"error finding font family", hr);
|
||||||
if (!exists)
|
if (!exists)
|
||||||
complain("TODO family not found in uiDrawLoadClosestFont()", hr);
|
implbug("TODO family not found in uiDrawLoadClosestFont()", hr);
|
||||||
hr = collection->GetFontFamily(index, &family);
|
hr = collection->GetFontFamily(index, &family);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
logHRESULT(L"error loading font family", hr);
|
logHRESULT(L"error loading font family", hr);
|
||||||
|
|
|
@ -87,7 +87,7 @@ void uiMenuItemDisable(uiMenuItem *i)
|
||||||
void uiMenuItemOnClicked(uiMenuItem *i, void (*f)(uiMenuItem *, uiWindow *, void *), void *data)
|
void uiMenuItemOnClicked(uiMenuItem *i, void (*f)(uiMenuItem *, uiWindow *, void *), void *data)
|
||||||
{
|
{
|
||||||
if (i->type == typeQuit)
|
if (i->type == typeQuit)
|
||||||
complain("attempt to call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead");
|
userbug("You can not call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead.");
|
||||||
i->onClicked = f;
|
i->onClicked = f;
|
||||||
i->onClickedData = data;
|
i->onClickedData = data;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
||||||
uiMenuItem *item;
|
uiMenuItem *item;
|
||||||
|
|
||||||
if (menusFinalized)
|
if (menusFinalized)
|
||||||
complain("attempt to create a new menu item after menus have been finalized");
|
userbug("You can not create a new menu item after menus have been finalized.");
|
||||||
|
|
||||||
if (m->len >= m->cap) {
|
if (m->len >= m->cap) {
|
||||||
m->cap += grow;
|
m->cap += grow;
|
||||||
|
@ -167,7 +167,7 @@ uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name)
|
||||||
uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)
|
uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)
|
||||||
{
|
{
|
||||||
if (hasQuit)
|
if (hasQuit)
|
||||||
complain("attempt to add multiple Quit menu items");
|
userbug("You can not have multiple Quit menu items in a program.");
|
||||||
hasQuit = TRUE;
|
hasQuit = TRUE;
|
||||||
newItem(m, typeSeparator, NULL);
|
newItem(m, typeSeparator, NULL);
|
||||||
return newItem(m, typeQuit, NULL);
|
return newItem(m, typeQuit, NULL);
|
||||||
|
@ -176,7 +176,7 @@ uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)
|
||||||
uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)
|
uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)
|
||||||
{
|
{
|
||||||
if (hasPreferences)
|
if (hasPreferences)
|
||||||
complain("attempt to add multiple Preferences menu items");
|
userbug("You can not have multiple Preferences menu items in a program.");
|
||||||
hasPreferences = TRUE;
|
hasPreferences = TRUE;
|
||||||
newItem(m, typeSeparator, NULL);
|
newItem(m, typeSeparator, NULL);
|
||||||
return newItem(m, typePreferences, NULL);
|
return newItem(m, typePreferences, NULL);
|
||||||
|
@ -185,7 +185,8 @@ uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)
|
||||||
uiMenuItem *uiMenuAppendAboutItem(uiMenu *m)
|
uiMenuItem *uiMenuAppendAboutItem(uiMenu *m)
|
||||||
{
|
{
|
||||||
if (hasAbout)
|
if (hasAbout)
|
||||||
complain("attempt to add multiple About menu items");
|
// TODO place these userbug strings in a header?
|
||||||
|
userbug("You can not have multiple About menu items in a program.");
|
||||||
hasAbout = TRUE;
|
hasAbout = TRUE;
|
||||||
newItem(m, typeSeparator, NULL);
|
newItem(m, typeSeparator, NULL);
|
||||||
return newItem(m, typeAbout, NULL);
|
return newItem(m, typeAbout, NULL);
|
||||||
|
@ -201,7 +202,7 @@ uiMenu *uiNewMenu(const char *name)
|
||||||
uiMenu *m;
|
uiMenu *m;
|
||||||
|
|
||||||
if (menusFinalized)
|
if (menusFinalized)
|
||||||
complain("attempt to create a new menu after menus have been finalized");
|
userbug("You can not create a new menu after menus have been finalized.");
|
||||||
if (len >= cap) {
|
if (len >= cap) {
|
||||||
cap += grow;
|
cap += grow;
|
||||||
menus = (uiMenu **) uiRealloc(menus, cap * sizeof (uiMenu *), "uiMenu *[]");
|
menus = (uiMenu **) uiRealloc(menus, cap * sizeof (uiMenu *), "uiMenu *[]");
|
||||||
|
@ -290,7 +291,7 @@ void runMenuEvent(WORD id, uiWindow *w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no match
|
// no match
|
||||||
complain("unknown menu ID %hu in runMenuEvent()", id);
|
implbug("unknown menu ID %hu in runMenuEvent()", id);
|
||||||
|
|
||||||
found:
|
found:
|
||||||
// first toggle checkboxes, if any
|
// first toggle checkboxes, if any
|
||||||
|
@ -313,7 +314,7 @@ static void freeMenu(uiMenu *m, HMENU submenu)
|
||||||
if (item->hmenus[j] == submenu)
|
if (item->hmenus[j] == submenu)
|
||||||
break;
|
break;
|
||||||
if (j >= item->len)
|
if (j >= item->len)
|
||||||
complain("submenu handle %p not found in freeMenu()", submenu);
|
implbug("submenu handle %p not found in freeMenu()", submenu);
|
||||||
for (; j < item->len - 1; j++)
|
for (; j < item->len - 1; j++)
|
||||||
item->hmenus[j] = item->hmenus[j + 1];
|
item->hmenus[j] = item->hmenus[j + 1];
|
||||||
item->hmenus[j] = NULL;
|
item->hmenus[j] = NULL;
|
||||||
|
@ -349,7 +350,8 @@ void uninitMenus(void)
|
||||||
for (j = 0; j < m->len; j++) {
|
for (j = 0; j < m->len; j++) {
|
||||||
item = m->items[j];
|
item = m->items[j];
|
||||||
if (item->len != 0)
|
if (item->len != 0)
|
||||||
complain("menu item %p (%ws) still has uiWindows attached; did you forget to destroy some windows?", item, item->name);
|
// TODO userbug()?
|
||||||
|
implbug("menu item %p (%ws) still has uiWindows attached; did you forget to destroy some windows?", item, item->name);
|
||||||
if (item->name != NULL)
|
if (item->name != NULL)
|
||||||
uiFree(item->name);
|
uiFree(item->name);
|
||||||
if (item->hmenus != NULL)
|
if (item->hmenus != NULL)
|
||||||
|
|
|
@ -33,7 +33,7 @@ static void uiProgressBarMinimumSize(uiWindowsControl *c, intmax_t *width, intma
|
||||||
void uiProgressBarSetValue(uiProgressBar *p, int value)
|
void uiProgressBarSetValue(uiProgressBar *p, int value)
|
||||||
{
|
{
|
||||||
if (value < 0 || value > 100)
|
if (value < 0 || value > 100)
|
||||||
complain("value %d out of range in uiProgressBarSetValue()", value);
|
userbug("Value %d is out of range for uiProgressBars.", value);
|
||||||
if (value == 100) { // because we can't 101
|
if (value == 100) { // because we can't 101
|
||||||
SendMessageW(p->hwnd, PBM_SETRANGE32, 0, 101);
|
SendMessageW(p->hwnd, PBM_SETRANGE32, 0, 101);
|
||||||
SendMessageW(p->hwnd, PBM_SETPOS, 101, 0);
|
SendMessageW(p->hwnd, PBM_SETPOS, 101, 0);
|
||||||
|
|
|
@ -184,7 +184,8 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
|
||||||
uiSpinbox *s;
|
uiSpinbox *s;
|
||||||
|
|
||||||
if (min >= max)
|
if (min >= max)
|
||||||
complain("error: min >= max in uiNewSpinbox()");
|
// TODO
|
||||||
|
implbug("error: min >= max in uiNewSpinbox()");
|
||||||
|
|
||||||
uiWindowsNewControl(uiSpinbox, s);
|
uiWindowsNewControl(uiSpinbox, s);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue