summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-08 17:06:23 -0400
committerPietro Gagliardi <[email protected]>2015-04-08 17:08:25 -0400
commitec070204a55be1c3f046cdc1896225a6cddf1b2f (patch)
tree5575c543b107d3c61d818a97ebcda7ce697679de
parenta97c9297c306f5796c00812edb6e018cbdc52b8b (diff)
More TODO resolving. More TODOs.
-rw-r--r--new/comctl32_windows.c25
-rw-r--r--new/container_unix.c28
-rw-r--r--new/init_windows.c1
3 files changed, 31 insertions, 23 deletions
diff --git a/new/comctl32_windows.c b/new/comctl32_windows.c
index 65473d6..93b3a27 100644
--- a/new/comctl32_windows.c
+++ b/new/comctl32_windows.c
@@ -43,29 +43,28 @@ const char *initCommonControls(void)
BOOL (*WINAPI ficc)(const LPINITCOMMONCONTROLSEX);
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)
- return "getting temporary filename for writing manifest file";
+ return "getting temporary filename for writing manifest file in initCommonControls()";
file = CreateFileW(filename, GENERIC_WRITE,
0, // don't share while writing
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 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)
SetLastError(0); // catch errorless short writes
if (WriteFile(file, manifest, nExpected, &nGot, NULL) == 0)
- return "writing manifest file";
+ return "writing manifest file in initCommonControls()";
if (nGot != nExpected) {
DWORD lasterr;
lasterr = GetLastError();
- // TODO reword these
if (lasterr == 0)
- return "short write to manifest file without error code";
- return "short write to manifest file";
+ return "writing entire manifest file (short write) without error code in initCommonControls()";
+ return "writing entire manifest file (short write) in initCommonControls()";
}
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));
actctx.cbSize = sizeof (ACTCTX);
@@ -73,9 +72,9 @@ const char *initCommonControls(void)
actctx.lpSource = filename;
ac = CreateActCtx(&actctx);
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)
- return "activating activation context for synthesized manifest file";
+ return "activating activation context for synthesized manifest file in initCommonControls()";
ZeroMemory(&icc, sizeof (INITCOMMONCONTROLSEX));
icc.dwSize = sizeof (INITCOMMONCONTROLSEX);
@@ -83,12 +82,12 @@ const char *initCommonControls(void)
comctl32 = LoadLibraryW(L"comctl32.dll");
if (comctl32 == NULL)
- return "loading comctl32.dll";
+ return "loading comctl32.dll in initCommonControls()";
// GetProcAddress() only takes a multibyte string
#define LOAD(fn) f = GetProcAddress(comctl32, fn); \
if (f == NULL) \
- return "loading " fn "()";
+ return "loading " fn "() in initCommonControls()";
LOAD("InitCommonControlsEx");
ficc = (BOOL (*WINAPI)(const LPINITCOMMONCONTROLSEX)) f;
@@ -100,7 +99,7 @@ const char *initCommonControls(void)
fv_DefSubclassProc = (LRESULT (*WINAPI)(HWND, UINT, WPARAM, LPARAM)) f;
if ((*ficc)(&icc) == FALSE)
- return "initializing Common Controls (comctl32.dll)";
+ return "initializing Common Controls (comctl32.dll) in initCommonControls()";
return NULL;
}
diff --git a/new/container_unix.c b/new/container_unix.c
index f5cd056..047b40a 100644
--- a/new/container_unix.c
+++ b/new/container_unix.c
@@ -12,18 +12,25 @@ static void uiContainer_init(uiContainer *c)
gtk_widget_set_has_window(GTK_WIDGET(c), FALSE);
}
-// TODO explain the order here
-// TODO guard against use of forall after the ptr array unref
+// instead of having GtkContainer itself unref all our controls, we'll run our own uiControlDestroy() functions for child, which will do that and more
+// 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)
{
- g_ptr_array_unref(uiContainer(obj)->children);
- if (uiContainer(obj)->child != NULL) {
- uiControlDestroy(uiContainer(obj)->child);
- uiContainer(obj)->child = NULL;
+ uiContainer *c = uiContainer(obj);
+
+ if (c->children != 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);
}
+// TODO switch from using uiContainer() directly below
+
static void uiContainer_finalize(GObject *obj)
{
G_OBJECT_CLASS(uiContainer_parent_class)->finalize(obj);
@@ -35,13 +42,15 @@ static void uiContainer_finalize(GObject *obj)
static void uiContainer_add(GtkContainer *container, GtkWidget *widget)
{
gtk_widget_set_parent(widget, GTK_WIDGET(container));
- g_ptr_array_add(uiContainer(container)->children, widget);
+ if (uiContainer(container)->children != NULL)
+ g_ptr_array_add(uiContainer(container)->children, widget);
}
static void uiContainer_remove(GtkContainer *container, GtkWidget *widget)
{
gtk_widget_unparent(widget);
- g_ptr_array_remove(uiContainer(container)->children, widget);
+ if (uiContainer(container)->children != NULL)
+ g_ptr_array_remove(uiContainer(container)->children, widget);
}
static void uiContainer_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
@@ -73,7 +82,8 @@ static void uiContainer_forall(GtkContainer *container, gboolean includeInternal
s.callback = callback;
s.data = data;
- g_ptr_array_foreach(uiContainer(container)->children, doforall, &s);
+ if (uiContainer(container)->children != NULL)
+ g_ptr_array_foreach(uiContainer(container)->children, doforall, &s);
}
static void uiContainer_class_init(uiContainerClass *class)
diff --git a/new/init_windows.c b/new/init_windows.c
index c484ed3..8a0a9ad 100644
--- a/new/init_windows.c
+++ b/new/init_windows.c
@@ -45,7 +45,6 @@ uiInitError *uiInit(uiInitOptions *o)
if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0)
nCmdShow = si.wShowWindow;
- // TODO add "in initCommonControls()" to each of the messages this returns
ce = initCommonControls();
if (ce != NULL)
return loadLastError(err, ce);