From 6c208deebcce1a0d90a5721f7a5f96213c26e147 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 1 Aug 2013 08:47:37 +0000 Subject: Make sure that in test-cases, Tk_DeleteOptionTable() is never called more times than the corresponding Tk_CreateOptionTable(). Although it doesn't crash now, this behavior cannot be depended on. --- generic/tkTest.c | 10 +++++++--- tests/config.test | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index 03431c9..8146c69 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -497,11 +497,11 @@ TestobjconfigObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { static const char *const options[] = { - "alltypes", "chain1", "chain2", "configerror", "delete", "info", + "alltypes", "chain1", "chain2", "chain3", "configerror", "delete", "info", "internal", "new", "notenoughparams", "twowindows", NULL }; enum { - ALL_TYPES, CHAIN1, CHAIN2, CONFIG_ERROR, + ALL_TYPES, CHAIN1, CHAIN2, CHAIN3, CONFIG_ERROR, DEL, /* Can't use DELETE: VC++ compiler barfs. */ INFO, INTERNAL, NEW, NOT_ENOUGH_PARAMS, TWO_WINDOWS }; @@ -720,7 +720,8 @@ TestobjconfigObjCmd( break; } - case CHAIN2: { + case CHAIN2: + case CHAIN3: { ExtensionWidgetRecord *recordPtr; static const Tk_OptionSpec extensionSpecs[] = { {TK_OPTION_STRING, "-three", "three", "Three", "three", @@ -803,6 +804,9 @@ TestobjconfigObjCmd( } if (tables[index] != NULL) { Tk_DeleteOptionTable(tables[index]); + /* Make sure that Tk_DeleteOptionTable() is never done + * twice for the same table. */ + tables[index] = NULL; } break; diff --git a/tests/config.test b/tests/config.test index 8f7aa9f..4430000 100644 --- a/tests/config.test +++ b/tests/config.test @@ -16,8 +16,8 @@ proc killTables {} { # chain2 depends on chain1. If chain1 is deleted first, the # delete of chain2 will crash. deleteWindows - foreach t {alltypes chain2 chain1 configerror internal new notenoughparams - twowindows} { + foreach t {alltypes chain3 chain2 chain1 configerror internal + new notenoughparams twowindows} { while {[testobjconfig info $t] != ""} { testobjconfig delete $t } @@ -126,9 +126,9 @@ test config-2.1 {Tk_DeleteOptionTable - reference counts} -constraints { set x {} testobjconfig chain1 .a testobjconfig chain2 .b - testobjconfig chain2 .c + testobjconfig chain3 .c deleteWindows - testobjconfig delete chain2 + testobjconfig delete chain3 lappend x [testobjconfig info chain2] [testobjconfig info chain1] testobjconfig delete chain2 lappend x [testobjconfig info chain2] [testobjconfig info chain1] -- cgit v0.12