More TODO resolving. More TODOs.
This commit is contained in:
parent
a97c9297c3
commit
ec070204a5
|
@ -43,29 +43,28 @@ const char *initCommonControls(void)
|
||||||
BOOL (*WINAPI ficc)(const LPINITCOMMONCONTROLSEX);
|
BOOL (*WINAPI ficc)(const LPINITCOMMONCONTROLSEX);
|
||||||
|
|
||||||
if (GetTempPathW(MAX_PATH + 1, temppath) == 0)
|
if (GetTempPathW(MAX_PATH + 1, temppath) == 0)
|
||||||
return "getting temporary path for writing manifest file";
|
return "getting temporary path for writing manifest file in initCommonControls()";
|
||||||
if (GetTempFileNameW(temppath, L"manifest", 0, filename) == 0)
|
if (GetTempFileNameW(temppath, L"manifest", 0, filename) == 0)
|
||||||
return "getting temporary filename for writing manifest file";
|
return "getting temporary filename for writing manifest file in initCommonControls()";
|
||||||
file = CreateFileW(filename, GENERIC_WRITE,
|
file = CreateFileW(filename, GENERIC_WRITE,
|
||||||
0, // don't share while writing
|
0, // don't share while writing
|
||||||
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return "creating manifest file";
|
return "creating manifest file in initCommonControls()";
|
||||||
nExpected = (sizeof manifest / sizeof manifest[0]) - 1; // - 1 to omit the terminating null character)
|
nExpected = (sizeof manifest / sizeof manifest[0]) - 1; // - 1 to omit the terminating null character)
|
||||||
SetLastError(0); // catch errorless short writes
|
SetLastError(0); // catch errorless short writes
|
||||||
if (WriteFile(file, manifest, nExpected, &nGot, NULL) == 0)
|
if (WriteFile(file, manifest, nExpected, &nGot, NULL) == 0)
|
||||||
return "writing manifest file";
|
return "writing manifest file in initCommonControls()";
|
||||||
if (nGot != nExpected) {
|
if (nGot != nExpected) {
|
||||||
DWORD lasterr;
|
DWORD lasterr;
|
||||||
|
|
||||||
lasterr = GetLastError();
|
lasterr = GetLastError();
|
||||||
// TODO reword these
|
|
||||||
if (lasterr == 0)
|
if (lasterr == 0)
|
||||||
return "short write to manifest file without error code";
|
return "writing entire manifest file (short write) without error code in initCommonControls()";
|
||||||
return "short write to manifest file";
|
return "writing entire manifest file (short write) in initCommonControls()";
|
||||||
}
|
}
|
||||||
if (CloseHandle(file) == 0)
|
if (CloseHandle(file) == 0)
|
||||||
return "closing manifest file (this IS an error here because not doing so will prevent Windows from being able to use the manifest file in an activation context)";
|
return "closing manifest file (this IS an error here because not doing so will prevent Windows from being able to use the manifest file in an activation context) in initCommonControls()";
|
||||||
|
|
||||||
ZeroMemory(&actctx, sizeof (ACTCTX));
|
ZeroMemory(&actctx, sizeof (ACTCTX));
|
||||||
actctx.cbSize = sizeof (ACTCTX);
|
actctx.cbSize = sizeof (ACTCTX);
|
||||||
|
@ -73,9 +72,9 @@ const char *initCommonControls(void)
|
||||||
actctx.lpSource = filename;
|
actctx.lpSource = filename;
|
||||||
ac = CreateActCtx(&actctx);
|
ac = CreateActCtx(&actctx);
|
||||||
if (ac == INVALID_HANDLE_VALUE)
|
if (ac == INVALID_HANDLE_VALUE)
|
||||||
return "creating activation context for synthesized manifest file";
|
return "creating activation context for synthesized manifest file in initCommonControls()";
|
||||||
if (ActivateActCtx(ac, &comctlManifestCookie) == FALSE)
|
if (ActivateActCtx(ac, &comctlManifestCookie) == FALSE)
|
||||||
return "activating activation context for synthesized manifest file";
|
return "activating activation context for synthesized manifest file in initCommonControls()";
|
||||||
|
|
||||||
ZeroMemory(&icc, sizeof (INITCOMMONCONTROLSEX));
|
ZeroMemory(&icc, sizeof (INITCOMMONCONTROLSEX));
|
||||||
icc.dwSize = sizeof (INITCOMMONCONTROLSEX);
|
icc.dwSize = sizeof (INITCOMMONCONTROLSEX);
|
||||||
|
@ -83,12 +82,12 @@ const char *initCommonControls(void)
|
||||||
|
|
||||||
comctl32 = LoadLibraryW(L"comctl32.dll");
|
comctl32 = LoadLibraryW(L"comctl32.dll");
|
||||||
if (comctl32 == NULL)
|
if (comctl32 == NULL)
|
||||||
return "loading comctl32.dll";
|
return "loading comctl32.dll in initCommonControls()";
|
||||||
|
|
||||||
// GetProcAddress() only takes a multibyte string
|
// GetProcAddress() only takes a multibyte string
|
||||||
#define LOAD(fn) f = GetProcAddress(comctl32, fn); \
|
#define LOAD(fn) f = GetProcAddress(comctl32, fn); \
|
||||||
if (f == NULL) \
|
if (f == NULL) \
|
||||||
return "loading " fn "()";
|
return "loading " fn "() in initCommonControls()";
|
||||||
|
|
||||||
LOAD("InitCommonControlsEx");
|
LOAD("InitCommonControlsEx");
|
||||||
ficc = (BOOL (*WINAPI)(const LPINITCOMMONCONTROLSEX)) f;
|
ficc = (BOOL (*WINAPI)(const LPINITCOMMONCONTROLSEX)) f;
|
||||||
|
@ -100,7 +99,7 @@ const char *initCommonControls(void)
|
||||||
fv_DefSubclassProc = (LRESULT (*WINAPI)(HWND, UINT, WPARAM, LPARAM)) f;
|
fv_DefSubclassProc = (LRESULT (*WINAPI)(HWND, UINT, WPARAM, LPARAM)) f;
|
||||||
|
|
||||||
if ((*ficc)(&icc) == FALSE)
|
if ((*ficc)(&icc) == FALSE)
|
||||||
return "initializing Common Controls (comctl32.dll)";
|
return "initializing Common Controls (comctl32.dll) in initCommonControls()";
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,18 +12,25 @@ static void uiContainer_init(uiContainer *c)
|
||||||
gtk_widget_set_has_window(GTK_WIDGET(c), FALSE);
|
gtk_widget_set_has_window(GTK_WIDGET(c), FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO explain the order here
|
// instead of having GtkContainer itself unref all our controls, we'll run our own uiControlDestroy() functions for child, which will do that and more
|
||||||
// TODO guard against use of forall after the ptr array unref
|
// we still chain up because we need to, but by that point there will be no children for GtkContainer to free
|
||||||
static void uiContainer_dispose(GObject *obj)
|
static void uiContainer_dispose(GObject *obj)
|
||||||
{
|
{
|
||||||
g_ptr_array_unref(uiContainer(obj)->children);
|
uiContainer *c = uiContainer(obj);
|
||||||
if (uiContainer(obj)->child != NULL) {
|
|
||||||
uiControlDestroy(uiContainer(obj)->child);
|
if (c->children != NULL) {
|
||||||
uiContainer(obj)->child = NULL;
|
g_ptr_array_unref(c->children);
|
||||||
|
c->children = NULL;
|
||||||
|
}
|
||||||
|
if (c->child != NULL) {
|
||||||
|
uiControlDestroy(c->child);
|
||||||
|
c->child = NULL;
|
||||||
}
|
}
|
||||||
G_OBJECT_CLASS(uiContainer_parent_class)->dispose(obj);
|
G_OBJECT_CLASS(uiContainer_parent_class)->dispose(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO switch from using uiContainer() directly below
|
||||||
|
|
||||||
static void uiContainer_finalize(GObject *obj)
|
static void uiContainer_finalize(GObject *obj)
|
||||||
{
|
{
|
||||||
G_OBJECT_CLASS(uiContainer_parent_class)->finalize(obj);
|
G_OBJECT_CLASS(uiContainer_parent_class)->finalize(obj);
|
||||||
|
@ -35,12 +42,14 @@ static void uiContainer_finalize(GObject *obj)
|
||||||
static void uiContainer_add(GtkContainer *container, GtkWidget *widget)
|
static void uiContainer_add(GtkContainer *container, GtkWidget *widget)
|
||||||
{
|
{
|
||||||
gtk_widget_set_parent(widget, GTK_WIDGET(container));
|
gtk_widget_set_parent(widget, GTK_WIDGET(container));
|
||||||
|
if (uiContainer(container)->children != NULL)
|
||||||
g_ptr_array_add(uiContainer(container)->children, widget);
|
g_ptr_array_add(uiContainer(container)->children, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uiContainer_remove(GtkContainer *container, GtkWidget *widget)
|
static void uiContainer_remove(GtkContainer *container, GtkWidget *widget)
|
||||||
{
|
{
|
||||||
gtk_widget_unparent(widget);
|
gtk_widget_unparent(widget);
|
||||||
|
if (uiContainer(container)->children != NULL)
|
||||||
g_ptr_array_remove(uiContainer(container)->children, widget);
|
g_ptr_array_remove(uiContainer(container)->children, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +82,7 @@ static void uiContainer_forall(GtkContainer *container, gboolean includeInternal
|
||||||
|
|
||||||
s.callback = callback;
|
s.callback = callback;
|
||||||
s.data = data;
|
s.data = data;
|
||||||
|
if (uiContainer(container)->children != NULL)
|
||||||
g_ptr_array_foreach(uiContainer(container)->children, doforall, &s);
|
g_ptr_array_foreach(uiContainer(container)->children, doforall, &s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ uiInitError *uiInit(uiInitOptions *o)
|
||||||
if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0)
|
if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0)
|
||||||
nCmdShow = si.wShowWindow;
|
nCmdShow = si.wShowWindow;
|
||||||
|
|
||||||
// TODO add "in initCommonControls()" to each of the messages this returns
|
|
||||||
ce = initCommonControls();
|
ce = initCommonControls();
|
||||||
if (ce != NULL)
|
if (ce != NULL)
|
||||||
return loadLastError(err, ce);
|
return loadLastError(err, ce);
|
||||||
|
|
Loading…
Reference in New Issue