summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/tkWinClipboard.c7
-rw-r--r--win/tkWinCursor.c20
-rw-r--r--win/tkWinDialog.c152
-rw-r--r--win/tkWinEmbed.c27
-rw-r--r--win/tkWinMenu.c18
-rw-r--r--win/tkWinSend.c138
-rw-r--r--win/tkWinSendCom.c102
-rw-r--r--win/tkWinSendCom.h6
-rw-r--r--win/tkWinWm.c405
-rw-r--r--win/tkWinX.c9
-rw-r--r--win/ttkWinXPTheme.c14
11 files changed, 517 insertions, 381 deletions
diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c
index dcbce6c..2501688 100644
--- a/win/tkWinClipboard.c
+++ b/win/tkWinClipboard.c
@@ -162,9 +162,10 @@ TkSelGetSelection(
return result;
error:
- Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
- " selection doesn't exist or form \"",
- Tk_GetAtomName(tkwin, target), "\" not defined", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s selection doesn't exist or form \"%s\" not defined",
+ Tk_GetAtomName(tkwin, selection), Tk_GetAtomName(tkwin, target)));
+ Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL);
return TCL_ERROR;
}
diff --git a/win/tkWinCursor.c b/win/tkWinCursor.c
index 8366db3..e7dbc65 100644
--- a/win/tkWinCursor.c
+++ b/win/tkWinCursor.c
@@ -72,8 +72,7 @@ static struct CursorName {
*/
#define TK_DEFAULT_CURSOR IDC_ARROW
-
-
+
/*
*----------------------------------------------------------------------
*
@@ -131,8 +130,9 @@ TkGetCursorByName(
*/
if (Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't get cursor from a file in",
- " a safe interpreter", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't get cursor from a file in a safe interpreter",-1));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "SAFE", NULL);
ckfree(argv);
ckfree(cursorPtr);
return NULL;
@@ -166,13 +166,15 @@ TkGetCursorByName(
ckfree(cursorPtr);
badCursorSpec:
ckfree(argv);
- Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad cursor spec \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL);
return NULL;
}
ckfree(argv);
return (TkCursor *) cursorPtr;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -201,7 +203,7 @@ TkCreateCursorFromData(
{
return NULL;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -225,7 +227,7 @@ TkpFreeCursor(
{
/* TkWinCursor *winCursorPtr = (TkWinCursor *) cursorPtr; */
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -260,7 +262,7 @@ TkpSetCursor(
SetCursor(hcursor);
}
}
-
+
/*
* Local Variables:
* mode: c
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 4d60105..7f96ec2 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -361,9 +361,9 @@ Tk_ChooseColorObjCmd(
return TCL_ERROR;
}
if (i + 1 == objc) {
- string = Tcl_GetString(optionPtr);
- Tcl_AppendResult(interp, "value for \"", string, "\" missing",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "value for \"%s\" missing", Tcl_GetString(optionPtr)));
+ Tcl_SetErrorCode(interp, "TK", "COLORDIALOG", "VALUE", NULL);
return TCL_ERROR;
}
@@ -424,13 +424,11 @@ Tk_ChooseColorObjCmd(
/*
* User has selected a color
*/
- char color[100];
- sprintf(color, "#%02x%02x%02x",
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%02x%02x%02x",
GetRValue(chooseColor.rgbResult),
GetGValue(chooseColor.rgbResult),
- GetBValue(chooseColor.rgbResult));
- Tcl_AppendResult(interp, color, NULL);
+ GetBValue(chooseColor.rgbResult)));
oldColor = chooseColor.rgbResult;
result = TCL_OK;
}
@@ -583,7 +581,7 @@ GetFileName(
Tcl_Obj *filterObj = NULL, *initialTypeObj = NULL, *typeVariableObj = NULL;
Tcl_DString utfFilterString, utfDirString, ds;
Tcl_DString extString, filterString, dirString, titleString;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
static const char *const saveOptionStrings[] = {
"-confirmoverwrite", "-defaultextension", "-filetypes", "-initialdir",
@@ -594,8 +592,8 @@ GetFileName(
"-multiple", "-parent", "-title", "-typevariable", NULL
};
enum options {
- FILE_CONFIRMOW, FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE,
- FILE_MULTIPLE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE
+ FILE_CONFIRMOW, FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE,
+ FILE_MULTIPLE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE
};
file[0] = '\0';
@@ -619,9 +617,9 @@ GetFileName(
}
if (i + 1 == objc) {
- string = Tcl_GetString(objv[i]);
- Tcl_AppendResult(interp, "value for \"", string, "\" missing",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "value for \"%s\" missing", Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL);
goto end;
}
@@ -647,9 +645,9 @@ GetFileName(
if (Tcl_TranslateFileName(interp, string, &ds) == NULL) {
goto end;
}
- Tcl_UtfToExternal(NULL, TkWinGetUnicodeEncoding(), Tcl_DStringValue(&ds),
- Tcl_DStringLength(&ds), 0, NULL, (char *) file,
- sizeof(file), NULL, NULL, NULL);
+ Tcl_UtfToExternal(NULL, TkWinGetUnicodeEncoding(),
+ Tcl_DStringValue(&ds), Tcl_DStringLength(&ds), 0, NULL,
+ (char *) file, sizeof(file), NULL, NULL, NULL);
Tcl_DStringFree(&ds);
break;
case FILE_PARENT:
@@ -870,8 +868,8 @@ GetFileName(
Tcl_SetObjResult(interp, returnList);
Tcl_DStringFree(&ds);
} else {
- Tcl_AppendResult(interp, ConvertExternalFilename(ofn.lpstrFile,
- &ds), NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ ConvertExternalFilename(ofn.lpstrFile, &ds), -1));
gotFilename = (Tcl_DStringLength(&ds) > 0);
Tcl_DStringFree(&ds);
}
@@ -895,9 +893,10 @@ GetFileName(
}
}
} else if (cdlgerr == FNERR_INVALIDFILENAME) {
- Tcl_SetResult(interp, "invalid filename \"", TCL_STATIC);
- Tcl_AppendResult(interp, ConvertExternalFilename(ofn.lpstrFile,
- &ds), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid filename \"%s\"",
+ ConvertExternalFilename(ofn.lpstrFile, &ds)));
+ Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "INVALIDFILENAME", NULL);
Tcl_DStringFree(&ds);
} else {
result = TCL_OK;
@@ -962,14 +961,16 @@ OFNHookProc(
OFNOTIFY *notifyPtr = (OFNOTIFY *) lParam;
/*
- * This is weird... or not. The CDN_FILEOK is NOT sent when the selection
- * exceeds declared buffer size (the nMaxFile member of the OPENFILENAME
- * struct passed to GetOpenFileName function). So, we have to rely on
- * the most recent CDN_SELCHANGE then. Unfortunately this means, that
- * gathering the selected filenames happens twice when they fit into the
- * declared buffer. Luckily, it's not frequent operation so it should
- * not incur any noticeable delay. See [tktoolkit-Bugs-2987995]
+ * This is weird... or not. The CDN_FILEOK is NOT sent when the
+ * selection exceeds declared buffer size (the nMaxFile member of the
+ * OPENFILENAME struct passed to GetOpenFileName function). So, we
+ * have to rely on the most recent CDN_SELCHANGE then. Unfortunately
+ * this means, that gathering the selected filenames happens twice
+ * when they fit into the declared buffer. Luckily, it's not frequent
+ * operation so it should not incur any noticeable delay. See [Bug
+ * 2987995]
*/
+
if (notifyPtr->hdr.code == CDN_FILEOK ||
notifyPtr->hdr.code == CDN_SELCHANGE) {
int dirsize, selsize;
@@ -991,8 +992,10 @@ OFNHookProc(
buffersize = (selsize + dirsize + 1);
/*
- * Just empty the buffer if dirsize indicates an error [Bug 3071836]
+ * Just empty the buffer if dirsize indicates an error. [Bug
+ * 3071836]
*/
+
if ((selsize > 1) && (dirsize > 0)) {
if (ofnData->dynFileBufferSize < buffersize) {
buffer = ckrealloc(buffer, buffersize * sizeof(TCHAR));
@@ -1357,9 +1360,9 @@ Tk_ChooseDirectoryObjCmd(
goto cleanup;
}
if (i + 1 == objc) {
- string = Tcl_GetString(optionPtr);
- Tcl_AppendResult(interp, "value for \"", string, "\" missing",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "value for \"%s\" missing", Tcl_GetString(optionPtr)));
+ Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "VALUE", NULL);
goto cleanup;
}
@@ -1369,7 +1372,8 @@ Tk_ChooseDirectoryObjCmd(
if (Tcl_TranslateFileName(interp,string,&initDirString) == NULL) {
goto cleanup;
}
- Tcl_WinUtfToTChar(Tcl_DStringValue(&initDirString), -1, &tempString);
+ Tcl_WinUtfToTChar(Tcl_DStringValue(&initDirString), -1,
+ &tempString);
uniStr = (TCHAR *) Tcl_DStringValue(&tempString);
/*
@@ -1461,10 +1465,11 @@ Tk_ChooseDirectoryObjCmd(
pidl = SHBrowseForFolder(&bInfo);
/*
- * This is a fix for Windows 2000, which seems to modify the folder name
- * buffer even when the dialog is canceled (in this case the buffer
- * contains garbage). See [Bug #3002230]
+ * This is a fix for Windows 2000, which seems to modify the folder
+ * name buffer even when the dialog is canceled (in this case the
+ * buffer contains garbage). See [Bug #3002230]
*/
+
path[0] = '\0';
/*
@@ -1473,9 +1478,10 @@ Tk_ChooseDirectoryObjCmd(
if (pidl != NULL) {
if (!SHGetPathFromIDList(pidl, path)) {
- Tcl_SetResult(interp, "Error: Not a file system folder\n",
- TCL_VOLATILE);
- };
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "error: not a file system folder", -1));
+ Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "PSEUDO", NULL);
+ }
pMalloc->lpVtbl->Free(pMalloc, (void *) pidl);
} else if (_tcslen(cdCBData.retDir) > 0) {
_tcscpy(path, cdCBData.retDir);
@@ -1502,8 +1508,8 @@ Tk_ChooseDirectoryObjCmd(
if (*path) {
Tcl_DString ds;
- Tcl_AppendResult(interp, ConvertExternalFilename(path, &ds),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ ConvertExternalFilename(path, &ds), -1));
Tcl_DStringFree(&ds);
}
@@ -1578,7 +1584,8 @@ ChooseDirectoryValidateProc(
Tcl_DStringFree(&initDirString);
Tcl_WinUtfToTChar(Tcl_DStringValue(&tempString), -1, &initDirString);
Tcl_DStringFree(&tempString);
- _tcsncpy(string, (TCHAR *) Tcl_DStringValue(&initDirString), MAX_PATH);
+ _tcsncpy(string, (TCHAR *) Tcl_DStringValue(&initDirString),
+ MAX_PATH);
Tcl_DStringFree(&initDirString);
if (SetCurrentDirectory(string) == 0) {
@@ -1596,7 +1603,9 @@ ChooseDirectoryValidateProc(
* User HAS to select a valid directory.
*/
- wsprintf(selDir, TEXT("Directory '%s' does not exist,\nplease select or enter an existing directory."), chooseDirSharedData->retDir);
+ wsprintf(selDir, TEXT("Directory '%s' does not exist,\n"
+ "please select or enter an existing directory."),
+ chooseDirSharedData->retDir);
MessageBox(NULL, selDir, NULL, MB_ICONEXCLAMATION|MB_OK);
chooseDirSharedData->retDir[0] = '\0';
return 1;
@@ -1732,7 +1741,6 @@ Tk_MessageBoxObjCmd(
for (i = 1; i < objc; i += 2) {
int index;
- const char *string;
Tcl_Obj *optionPtr, *valuePtr;
optionPtr = objv[i];
@@ -1743,9 +1751,9 @@ Tk_MessageBoxObjCmd(
return TCL_ERROR;
}
if (i + 1 == objc) {
- string = Tcl_GetString(optionPtr);
- Tcl_AppendResult(interp, "value for \"", string, "\" missing",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "value for \"%s\" missing", Tcl_GetString(optionPtr)));
+ Tcl_SetErrorCode(interp, "TK", "MSGBOX", "VALUE", NULL);
return TCL_ERROR;
}
@@ -1814,9 +1822,10 @@ Tk_MessageBoxObjCmd(
}
}
if (defaultBtnIdx < 0) {
- Tcl_AppendResult(interp, "invalid default button \"",
- TkFindStateString(buttonMap, defaultBtn),
- "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid default button \"%s\"",
+ TkFindStateString(buttonMap, defaultBtn)));
+ Tcl_SetErrorCode(interp, "TK", "MSGBOX", "DEFAULT", NULL);
return TCL_ERROR;
}
break;
@@ -1864,9 +1873,8 @@ Tk_MessageBoxObjCmd(
EnableWindow(hWnd, 1);
Tcl_DecrRefCount(tmpObj);
-
- Tcl_SetResult(interp,
- (char *)TkFindStateString(buttonMap, winCode), TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ TkFindStateString(buttonMap, winCode), -1));
return TCL_OK;
}
@@ -1934,6 +1942,7 @@ SetTkDialog(
/*
* Factored out a common pattern in use in this file.
*/
+
static const char *
ConvertExternalFilename(
TCHAR *filename,
@@ -1969,7 +1978,9 @@ ConvertExternalFilename(
*/
static Tcl_Obj *
-GetFontObj(HDC hdc, LOGFONT *plf)
+GetFontObj(
+ HDC hdc,
+ LOGFONT *plf)
{
Tcl_DString ds;
Tcl_Obj *resObj;
@@ -2001,7 +2012,11 @@ GetFontObj(HDC hdc, LOGFONT *plf)
}
static void
-ApplyLogfont(Tcl_Interp *interp, Tcl_Obj *cmdObj, HDC hdc, LOGFONT *logfontPtr)
+ApplyLogfont(
+ Tcl_Interp *interp,
+ Tcl_Obj *cmdObj,
+ HDC hdc,
+ LOGFONT *logfontPtr)
{
int objc;
Tcl_Obj **objv, **tmpv;
@@ -2036,7 +2051,11 @@ typedef struct HookData {
} HookData;
static UINT_PTR CALLBACK
-HookProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+HookProc(
+ HWND hwndDlg,
+ UINT msg,
+ WPARAM wParam,
+ LPARAM lParam)
{
CHOOSEFONT *pcf = (CHOOSEFONT *) lParam;
HWND hwndCtrl;
@@ -2048,7 +2067,7 @@ HookProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
phd = (HookData *) pcf->lCustData;
phd->hwnd = hwndDlg;
if (tsdPtr->debugFlag) {
- tsdPtr->debugInterp = (Tcl_Interp *) phd->interp;
+ tsdPtr->debugInterp = phd->interp;
Tcl_DoWhenIdle(SetTkDialog, hwndDlg);
}
if (phd->titleObj != NULL) {
@@ -2115,7 +2134,9 @@ enum FontchooserOption {
};
static Tcl_Obj *
-FontchooserCget(HookData *hdPtr, int optionIndex)
+FontchooserCget(
+ HookData *hdPtr,
+ int optionIndex)
{
Tcl_Obj *resObj = NULL;
@@ -2225,16 +2246,18 @@ FontchooserConfigureCmd(
return TCL_OK;
}
if (i + 1 == objc) {
- Tcl_AppendResult(interp, "value for \"",
- Tcl_GetString(objv[i]), "\" missing", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "value for \"%s\" missing", Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "VALUE", NULL);
return TCL_ERROR;
}
switch (optionIndex) {
case FontchooserVisible: {
- const char *msg = "cannot change read-only option "
+ static const char *msg = "cannot change read-only option "
"\"-visible\": use the show or hide command";
Tcl_SetObjResult(interp, Tcl_NewStringObj(msg, -1));
+ Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", NULL);
return TCL_ERROR;
}
case FontchooserParent: {
@@ -2367,9 +2390,10 @@ FontchooserShowCmd(
}
fontPtr = (TkFont *) f;
cf.Flags |= CF_INITTOLOGFONTSTRUCT;
- Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds);
- _tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds), LF_FACESIZE-1);
- Tcl_DStringFree(&ds);
+ Tcl_WinUtfToTChar(fontPtr->fa.family, -1, &ds);
+ _tcsncpy(lf.lfFaceName, (TCHAR *)Tcl_DStringValue(&ds),
+ LF_FACESIZE-1);
+ Tcl_DStringFree(&ds);
lf.lfFaceName[LF_FACESIZE-1] = 0;
lf.lfHeight = -MulDiv(TkFontGetPoints(tkwin, fontPtr->fa.size),
GetDeviceCaps(hdc, LOGPIXELSY), 72);
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index 43cd419..7ea4222 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -134,7 +134,7 @@ Tk_DetachEmbeddedWindow(
TkpWinToplevelOverrideRedirect(winPtr, 0);
}
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -243,8 +243,9 @@ TkpUseWindow(
/*
if (winPtr->window != None) {
- Tcl_AppendResult(interp,
- "can't modify container after widget is created", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't modify container after widget is created", -1));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", NULL);
return TCL_ERROR;
}
*/
@@ -272,8 +273,9 @@ TkpUseWindow(
if (!IsWindow(hwnd)) {
if (interp != NULL) {
- Tcl_AppendResult(interp, "window \"", string,
- "\" doesn't exist", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" doesn't exist", string));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "EXIST", NULL);
}
return TCL_ERROR;
}
@@ -281,12 +283,15 @@ TkpUseWindow(
id = SendMessage(hwnd, TK_INFO, TK_CONTAINER_VERIFY, 0);
if (id == PTR2INT(hwnd)) {
if (!SendMessage(hwnd, TK_INFO, TK_CONTAINER_ISAVAILABLE, 0)) {
- Tcl_AppendResult(interp, "The container is already in use", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "The container is already in use", -1));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "USED", NULL);
return TCL_ERROR;
}
} else if (id == -PTR2INT(hwnd)) {
- Tcl_AppendResult(interp, "the window to use is not a Tk container",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "the window to use is not a Tk container", -1));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "NOT", NULL);
return TCL_ERROR;
} else {
/*
@@ -300,7 +305,9 @@ TkpUseWindow(
sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string);
if (IDCANCEL == MessageBoxA(hwnd, msg, "Tk Warning",
MB_OKCANCEL | MB_ICONWARNING)) {
- Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Operation has been canceled", -1));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "CANCEL", NULL);
return TCL_ERROR;
}
}
@@ -935,7 +942,7 @@ Tk_GetEmbeddedHWnd(
}
return NULL;
}
-
+
/*
*----------------------------------------------------------------------
*
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 245639d..f12e965 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -274,7 +274,8 @@ FreeID(
if (tsdPtr->menuHWND != NULL) {
Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable,
- ((char *) NULL) + commandID);
+ INT2PTR(commandID));
+
if (entryPtr != NULL) {
Tcl_DeleteHashEntry(entryPtr);
}
@@ -311,10 +312,10 @@ TkpNewMenu(
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
winMenuHdl = CreatePopupMenu();
-
if (winMenuHdl == NULL) {
- Tcl_AppendResult(menuPtr->interp, "No more menus can be allocated.",
- (char *) NULL);
+ Tcl_SetObjResult(menuPtr->interp, Tcl_NewStringObj(
+ "No more menus can be allocated.", -1));
+ Tcl_SetErrorCode(interp, "TK", "MENU", "SYSTEM_RESOURCES", NULL);
return TCL_ERROR;
}
@@ -923,11 +924,12 @@ UpdateEmbeddedMenu(
{
RECT rc;
HWND hMenuWnd = (HWND)clientData;
+
GetClientRect(hMenuWnd, &rc);
InvalidateRect(hMenuWnd, &rc, FALSE);
UpdateWindow(hMenuWnd);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -997,7 +999,7 @@ TkWinEmbeddedMenuProc(
}
return lResult;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -1090,7 +1092,7 @@ TkWinHandleMenuEvent(
break;
}
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable,
- ((char *) NULL) + LOWORD(*pwParam));
+ INT2PTR(LOWORD(*pwParam)));
if (hashEntryPtr == NULL) {
break;
}
@@ -1292,7 +1294,7 @@ TkWinHandleMenuEvent(
mePtr = menuPtr->entries[entryIndex];
} else {
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->commandTable,
- ((char *) NULL) + entryIndex);
+ INT2PTR(entryIndex));
if (hashEntryPtr != NULL) {
mePtr = (TkMenuEntry *)
Tcl_GetHashValue(hashEntryPtr);
diff --git a/win/tkWinSend.c b/win/tkWinSend.c
index b3edc62..a40c238 100644
--- a/win/tkWinSend.c
+++ b/win/tkWinSend.c
@@ -1,4 +1,4 @@
-/*
+`/*
* tkWinSend.c --
*
* This file provides functions that implement the "send" command,
@@ -55,7 +55,7 @@ typedef struct {
int initialized;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
-#endif
+#endif /* TK_SEND_ENABLED_ON_WINDOWS */
/*
* Functions internal to this file.
@@ -66,12 +66,12 @@ static void CmdDeleteProc(ClientData clientData);
static void InterpDeleteProc(ClientData clientData,
Tcl_Interp *interp);
static void RevokeObjectRegistration(RegisteredInterp *riPtr);
-#endif
+#endif /* TK_SEND_ENABLED_ON_WINDOWS */
static HRESULT BuildMoniker(const char *name, LPMONIKER *pmk);
#ifdef TK_SEND_ENABLED_ON_WINDOWS
static HRESULT RegisterInterp(const char *name,
RegisteredInterp *riPtr);
-#endif
+#endif /* TK_SEND_ENABLED_ON_WINDOWS */
static int FindInterpreterObject(Tcl_Interp *interp,
const char *name, LPDISPATCH *ppdisp);
static int Send(LPDISPATCH pdispInterp, Tcl_Interp *interp,
@@ -85,7 +85,7 @@ static Tcl_EventProc SendEventProc;
#define TRACE SendTrace
#else
#define TRACE 1 ? ((void)0) : SendTrace
-#endif
+#endif /* DEBUG || _DEBUG */
/*
*--------------------------------------------------------------
@@ -136,9 +136,7 @@ Tk_SetAppName(
HRESULT hr = S_OK;
interp = winPtr->mainPtr->interp;
-
- tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
* Initialise the COM library for this interpreter just once.
@@ -147,8 +145,9 @@ Tk_SetAppName(
if (tsdPtr->initialized == 0) {
hr = CoInitialize(0);
if (FAILED(hr)) {
- Tcl_SetResult(interp,
- "failed to initialize the COM library", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "failed to initialize the COM library", -1));
+ Tcl_SetErrorcode(interp, "TK", "SEND", "COM", NULL);
return "";
}
tsdPtr->initialized = 1;
@@ -363,8 +362,10 @@ Tk_SendObjCmd(
*/
if (displayPtr) {
- Tcl_SetResult(interp, "option not implemented: \"displayof\" is "
- "not available for this platform.", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "option not implemented: \"displayof\" is not available"
+ " for this platform.", -1));
+ Tcl_SetErrorcode(interp, "TK", "SEND", "DISPLAYOF_WIN", NULL);
result = TCL_ERROR;
}
@@ -436,9 +437,10 @@ FindInterpreterObject(
pUnkInterp->lpVtbl->Release(pUnkInterp);
} else {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp,
- "no application named \"", name, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "no application named \"%s\"", name));
+ Tcl_SetErrorcode(interp, "TK", "LOOKUP", "APPLICATION",
+ NULL);
result = TCL_ERROR;
}
@@ -553,7 +555,7 @@ RevokeObjectRegistration(
riPtr->name = NULL;
}
}
-#endif
+#endif /* TK_SEND_ENABLED_ON_WINDOWS */
/*
* ----------------------------------------------------------------------
@@ -580,7 +582,7 @@ InterpDeleteProc(
{
CoUninitialize();
}
-#endif
+#endif /* TK_SEND_ENABLED_ON_WINDOWS */
/*
* ----------------------------------------------------------------------
@@ -701,7 +703,7 @@ RegisterInterp(
Tcl_DStringFree(&dString);
return hr;
}
-#endif
+#endif /* TK_SEND_ENABLED_ON_WINDOWS */
/*
* ----------------------------------------------------------------------
@@ -782,21 +784,14 @@ Send(
* variables.
*/
- if (hr == DISP_E_EXCEPTION) {
+ if (hr == DISP_E_EXCEPTION && ei.bstrSource != NULL) {
Tcl_Obj *opError, *opErrorCode, *opErrorInfo;
- if (ei.bstrSource != NULL) {
- int len;
- const char *szErrorInfo;
-
- opError = Tcl_NewUnicodeObj(ei.bstrSource, -1);
- Tcl_ListObjIndex(interp, opError, 0, &opErrorCode);
- Tcl_SetObjErrorCode(interp, opErrorCode);
-
- Tcl_ListObjIndex(interp, opError, 1, &opErrorInfo);
- szErrorInfo = Tcl_GetStringFromObj(opErrorInfo, &len);
- Tcl_AddObjErrorInfo(interp, szErrorInfo, len);
- }
+ opError = Tcl_NewUnicodeObj(ei.bstrSource, -1);
+ Tcl_ListObjIndex(interp, opError, 0, &opErrorCode);
+ Tcl_SetObjErrorCode(interp, opErrorCode);
+ Tcl_ListObjIndex(interp, opError, 1, &opErrorInfo);
+ Tcl_AppendObjToErrorInfo(interp, opErrorInfo);
}
/*
@@ -852,7 +847,7 @@ Win32ErrorObj(
errPtr = Tcl_NewUnicodeObj(lpBuffer, (int)wcslen(lpBuffer));
#else
errPtr = Tcl_NewStringObj(lpBuffer, (int)strlen(lpBuffer));
-#endif
+#endif /* _UNICODE */
if (lpBuffer != sBuffer) {
LocalFree((HLOCAL)lpBuffer);
@@ -864,7 +859,7 @@ Win32ErrorObj(
/*
* ----------------------------------------------------------------------
*
- * SetErrorInfo --
+ * TkWinSend_SetExcepInfo --
*
* Convert the error information from a Tcl interpreter into a COM
* exception structure. This information is then registered with the COM
@@ -881,48 +876,51 @@ Win32ErrorObj(
*/
void
-SetExcepInfo(
- Tcl_Interp* interp,
+TkWinSend_SetExcepInfo(
+ Tcl_Interp *interp,
EXCEPINFO *pExcepInfo)
{
- if (pExcepInfo) {
- Tcl_Obj *opError, *opErrorInfo, *opErrorCode;
- ICreateErrorInfo *pCEI;
- IErrorInfo *pEI, **ppEI = &pEI;
- HRESULT hr;
-
- opError = Tcl_GetObjResult(interp);
- opErrorInfo = Tcl_GetVar2Ex(interp, "errorInfo",NULL, TCL_GLOBAL_ONLY);
- opErrorCode = Tcl_GetVar2Ex(interp, "errorCode",NULL, TCL_GLOBAL_ONLY);
-
- if (Tcl_IsShared(opErrorCode)) {
- Tcl_Obj *ec = Tcl_DuplicateObj(opErrorCode);
-
- Tcl_IncrRefCount(ec);
- Tcl_DecrRefCount(opErrorCode);
- opErrorCode = ec;
- }
- Tcl_ListObjAppendElement(interp, opErrorCode, opErrorInfo);
+ Tcl_Obj *opError, *opErrorInfo, *opErrorCode;
+ ICreateErrorInfo *pCEI;
+ IErrorInfo *pEI, **ppEI = &pEI;
+ HRESULT hr;
- pExcepInfo->bstrDescription = SysAllocString(Tcl_GetUnicode(opError));
- pExcepInfo->bstrSource = SysAllocString(Tcl_GetUnicode(opErrorCode));
- pExcepInfo->scode = E_FAIL;
+ if (!pExcepInfo) {
+ return;
+ }
- hr = CreateErrorInfo(&pCEI);
- if (SUCCEEDED(hr)) {
- hr = pCEI->lpVtbl->SetGUID(pCEI, &IID_IDispatch);
- hr = pCEI->lpVtbl->SetDescription(pCEI,
- pExcepInfo->bstrDescription);
- hr = pCEI->lpVtbl->SetSource(pCEI, pExcepInfo->bstrSource);
- hr = pCEI->lpVtbl->QueryInterface(pCEI, &IID_IErrorInfo,
- (void**) ppEI);
- if (SUCCEEDED(hr)) {
- SetErrorInfo(0, pEI);
- pEI->lpVtbl->Release(pEI);
- }
- pCEI->lpVtbl->Release(pCEI);
- }
+ opError = Tcl_GetObjResult(interp);
+ opErrorInfo = Tcl_GetVar2Ex(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY);
+ opErrorCode = Tcl_GetVar2Ex(interp, "errorCode", NULL, TCL_GLOBAL_ONLY);
+
+ /*
+ * Pack the trace onto the end of the Tcl exception descriptor.
+ */
+
+ opErrorCode = Tcl_DuplicateObj(opErrorCode);
+ Tcl_IncrRefCount(opErrorCode);
+ Tcl_ListObjAppendElement(interp, opErrorCode, opErrorInfo);
+ /* TODO: Handle failure to append */
+
+ pExcepInfo->bstrDescription = SysAllocString(Tcl_GetUnicode(opError));
+ pExcepInfo->bstrSource = SysAllocString(Tcl_GetUnicode(opErrorCode));
+ Tcl_DecrRefCount(opErrorCode);
+ pExcepInfo->scode = E_FAIL;
+
+ hr = CreateErrorInfo(&pCEI);
+ if (!SUCCEEDED(hr)) {
+ return;
+ }
+
+ hr = pCEI->lpVtbl->SetGUID(pCEI, &IID_IDispatch);
+ hr = pCEI->lpVtbl->SetDescription(pCEI, pExcepInfo->bstrDescription);
+ hr = pCEI->lpVtbl->SetSource(pCEI, pExcepInfo->bstrSource);
+ hr = pCEI->lpVtbl->QueryInterface(pCEI, &IID_IErrorInfo, (void **) ppEI);
+ if (SUCCEEDED(hr)) {
+ SetErrorInfo(0, pEI);
+ pEI->lpVtbl->Release(pEI);
}
+ pCEI->lpVtbl->Release(pCEI);
}
/*
diff --git a/win/tkWinSendCom.c b/win/tkWinSendCom.c
index c67e533..83dd56b 100644
--- a/win/tkWinSendCom.c
+++ b/win/tkWinSendCom.c
@@ -100,7 +100,6 @@ TkWinSendCom_CreateInstance(
ISupportErrorInfo_Release,
ISupportErrorInfo_InterfaceSupportsErrorInfo,
};
- HRESULT hr = S_OK;
TkWinSendCom *obj = NULL;
/*
@@ -111,21 +110,19 @@ TkWinSendCom_CreateInstance(
obj = (TkWinSendCom *) CoTaskMemAlloc(sizeof(TkWinSendCom));
if (obj == NULL) {
*ppv = NULL;
- hr = E_OUTOFMEMORY;
- } else {
- obj->lpVtbl = &vtbl;
- obj->lpVtbl2 = &vtbl2;
- obj->refcount = 0;
- obj->interp = interp;
-
- /*
- * lock the interp? Tcl_AddRef/Retain?
- */
-
- hr = obj->lpVtbl->QueryInterface((IDispatch*)obj, riid, ppv);
+ return E_OUTOFMEMORY;
}
- return hr;
+ obj->lpVtbl = &vtbl;
+ obj->lpVtbl2 = &vtbl2;
+ obj->refcount = 0;
+ obj->interp = interp;
+
+ /*
+ * lock the interp? Tcl_AddRef/Retain?
+ */
+
+ return obj->lpVtbl->QueryInterface((IDispatch *) obj, riid, ppv);
}
/*
@@ -147,7 +144,7 @@ static void
TkWinSendCom_Destroy(
LPDISPATCH pdisp)
{
- CoTaskMemFree((void*)pdisp);
+ CoTaskMemFree((void *) pdisp);
}
/*
@@ -169,17 +166,17 @@ WinSendCom_QueryInterface(
void **ppvObject)
{
HRESULT hr = E_NOINTERFACE;
- TkWinSendCom *this = (TkWinSendCom*)This;
+ TkWinSendCom *this = (TkWinSendCom *) This;
*ppvObject = NULL;
if (memcmp(riid, &IID_IUnknown, sizeof(IID)) == 0
|| memcmp(riid, &IID_IDispatch, sizeof(IID)) == 0) {
- *ppvObject = (void**)this;
+ *ppvObject = (void **) this;
this->lpVtbl->AddRef(This);
hr = S_OK;
} else if (memcmp(riid, &IID_ISupportErrorInfo, sizeof(IID)) == 0) {
- *ppvObject = (void**)(this + 1);
- this->lpVtbl2->AddRef((ISupportErrorInfo*)(this + 1));
+ *ppvObject = (void **) (this + 1);
+ this->lpVtbl2->AddRef((ISupportErrorInfo *) (this + 1));
hr = S_OK;
}
return hr;
@@ -316,16 +313,16 @@ ISupportErrorInfo_QueryInterface(
REFIID riid,
void **ppvObject)
{
- TkWinSendCom *this = (TkWinSendCom*)(This - 1);
+ TkWinSendCom *this = (TkWinSendCom *)(This - 1);
- return this->lpVtbl->QueryInterface((IDispatch*)this, riid, ppvObject);
+ return this->lpVtbl->QueryInterface((IDispatch *) this, riid, ppvObject);
}
static STDMETHODIMP_(ULONG)
ISupportErrorInfo_AddRef(
ISupportErrorInfo *This)
{
- TkWinSendCom *this = (TkWinSendCom*)(This - 1);
+ TkWinSendCom *this = (TkWinSendCom *)(This - 1);
return InterlockedIncrement(&this->refcount);
}
@@ -334,9 +331,9 @@ static STDMETHODIMP_(ULONG)
ISupportErrorInfo_Release(
ISupportErrorInfo *This)
{
- TkWinSendCom *this = (TkWinSendCom*)(This - 1);
+ TkWinSendCom *this = (TkWinSendCom *)(This - 1);
- return this->lpVtbl->Release((IDispatch*)this);
+ return this->lpVtbl->Release((IDispatch *) this);
}
static STDMETHODIMP
@@ -380,17 +377,15 @@ Async(
if (FAILED(hr)) {
Tcl_SetObjResult(obj->interp, Tcl_NewStringObj(
"invalid args: Async(command)", -1));
- SetExcepInfo(obj->interp, pExcepInfo);
+ TkWinSend_SetExcepInfo(obj->interp, pExcepInfo);
hr = DISP_E_EXCEPTION;
}
- if (SUCCEEDED(hr)) {
- if (obj->interp) {
- Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(vCmd.bstrVal,
- (int) SysStringLen(vCmd.bstrVal));
+ if (SUCCEEDED(hr) && obj->interp) {
+ Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(vCmd.bstrVal,
+ (int) SysStringLen(vCmd.bstrVal));
- TkWinSend_QueueCommand(obj->interp, scriptPtr);
- }
+ TkWinSend_QueueCommand(obj->interp, scriptPtr);
}
VariantClear(&vCmd);
@@ -427,29 +422,36 @@ Send(
HRESULT hr = S_OK;
int result = TCL_OK;
VARIANT v;
+ register Tcl_Interp *interp = obj->interp;
+ Tcl_Obj *scriptPtr;
+ if (interp == NULL) {
+ return S_OK;
+ }
VariantInit(&v);
hr = VariantChangeType(&v, &vCmd, 0, VT_BSTR);
- if (SUCCEEDED(hr)) {
- if (obj->interp) {
- Tcl_Obj *scriptPtr = Tcl_NewUnicodeObj(v.bstrVal,
- (int)SysStringLen(v.bstrVal));
-
- result = Tcl_EvalObjEx(obj->interp, scriptPtr,
- TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL);
- if (pvResult) {
- VariantInit(pvResult);
- pvResult->vt = VT_BSTR;
- pvResult->bstrVal = SysAllocString(
- Tcl_GetUnicode(Tcl_GetObjResult(obj->interp)));
- }
- if (result == TCL_ERROR) {
- hr = DISP_E_EXCEPTION;
- SetExcepInfo(obj->interp, pExcepInfo);
- }
- }
- VariantClear(&v);
+ if (!SUCCEEDED(hr)) {
+ return hr;
+ }
+
+ scriptPtr = Tcl_NewUnicodeObj(v.bstrVal, (int) SysStringLen(v.bstrVal));
+ Tcl_Preserve(interp);
+ Tcl_IncrRefCount(scriptPtr);
+ result = Tcl_EvalObjEx(interp, scriptPtr,
+ TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL);
+ Tcl_DecrRefCount(scriptPtr);
+ if (pvResult != NULL) {
+ VariantInit(pvResult);
+ pvResult->vt = VT_BSTR;
+ pvResult->bstrVal = SysAllocString(Tcl_GetUnicode(
+ Tcl_GetObjResult(interp)));
+ }
+ if (result == TCL_ERROR) {
+ hr = DISP_E_EXCEPTION;
+ TkWinSend_SetExcepInfo(interp, pExcepInfo);
}
+ Tcl_Release(interp);
+ VariantClear(&v);
return hr;
}
diff --git a/win/tkWinSendCom.h b/win/tkWinSendCom.h
index 4928bc7..cd6ec18 100644
--- a/win/tkWinSendCom.h
+++ b/win/tkWinSendCom.h
@@ -45,11 +45,11 @@ typedef struct {
* TkWinSendCom public functions
*/
-HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp,
+MODULE_SCOPE HRESULT TkWinSendCom_CreateInstance(Tcl_Interp *interp,
REFIID riid, void **ppv);
-int TkWinSend_QueueCommand(Tcl_Interp *interp,
+MODULE_SCOPE int TkWinSend_QueueCommand(Tcl_Interp *interp,
Tcl_Obj *cmdPtr);
-void SetExcepInfo(Tcl_Interp *interp,
+MODULE_SCOPE void TkWinSend_SetExcepInfo(Tcl_Interp *interp,
EXCEPINFO *pExcepInfo);
#endif /* _tkWinSendCom_h_INCLUDE */
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 45ccbe2..0686348 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -972,8 +972,9 @@ WinSetIcon(
}
if (!(Tk_IsTopLevel(tkw))) {
- Tcl_AppendResult(interp, "window \"", Tk_PathName(tkw),
- "\" isn't a top-level window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't a top-level window", Tk_PathName(tkw)));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", NULL);
return TCL_ERROR;
}
if (Tk_WindowId(tkw) == None) {
@@ -1006,7 +1007,9 @@ WinSetIcon(
if (!initialized) {
if (InitWindowClass(titlebaricon) != TCL_OK) {
- Tcl_AppendResult(interp, "Unable to set icon", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Unable to set icon", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "FAILED", NULL);
return TCL_ERROR;
}
} else {
@@ -1061,8 +1064,9 @@ WinSetIcon(
wmPtr = ((TkWindow *) tkw)->wmInfoPtr;
hwnd = wmPtr->wrapper;
if (hwnd == NULL) {
- Tcl_AppendResult(interp,
- "Can't set icon; window has no wrapper.", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Can't set icon; window has no wrapper.", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "WRAPPER", NULL);
return TCL_ERROR;
}
}
@@ -1575,8 +1579,9 @@ ReadIconOrCursorFromFile(
channel = Tcl_FSOpenFileChannel(interp, fileName, "r", 0);
if (channel == NULL) {
- Tcl_AppendResult(interp, "Error opening file \"",
- Tcl_GetString(fileName), "\" for reading", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error opening file \"%s\" for reading: %s",
+ Tcl_GetString(fileName), Tcl_PosixError(interp)));
return NULL;
}
if (Tcl_SetChannelOption(interp, channel, "-translation", "binary")
@@ -1602,7 +1607,7 @@ ReadIconOrCursorFromFile(
lpIR->nNumImages = ReadICOHeader(channel);
if (lpIR->nNumImages == -1) {
- Tcl_AppendResult(interp, "Invalid file header", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("Invalid file header", -1));
Tcl_Close(NULL, channel);
ckfree(lpIR);
return NULL;
@@ -1628,7 +1633,9 @@ ReadIconOrCursorFromFile(
dwBytesRead = Tcl_Read(channel, (char *) lpIDE,
(int) (lpIR->nNumImages * sizeof(ICONDIRENTRY)));
if (dwBytesRead != lpIR->nNumImages * sizeof(ICONDIRENTRY)) {
- Tcl_AppendResult(interp, "Error reading file", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error reading file: %s", Tcl_PosixError(interp)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "READ", NULL);
Tcl_Close(NULL, channel);
ckfree(lpIDE);
ckfree(lpIR);
@@ -1660,7 +1667,8 @@ ReadIconOrCursorFromFile(
*/
if (Tcl_Seek(channel, lpIDE[i].dwImageOffset, FILE_BEGIN) == -1) {
- Tcl_AppendResult(interp, "Error seeking in file", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error seeking in file: %s", Tcl_PosixError(interp)));
goto readError;
}
@@ -1671,7 +1679,8 @@ ReadIconOrCursorFromFile(
dwBytesRead = Tcl_Read(channel, (char *)lpIR->IconImages[i].lpBits,
(int) lpIDE[i].dwBytesInRes);
if (dwBytesRead != lpIDE[i].dwBytesInRes) {
- Tcl_AppendResult(interp, "Error reading file", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error reading file: ", Tcl_PosixError(interp)));
goto readError;
}
@@ -1680,8 +1689,9 @@ ReadIconOrCursorFromFile(
*/
if (!AdjustIconImagePointers(&lpIR->IconImages[i])) {
- Tcl_AppendResult(interp, "Error converting to internal format",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Error converting to internal format", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICON", "FORMAT", NULL);
goto readError;
}
lpIR->IconImages[i].hIcon =
@@ -1694,11 +1704,6 @@ ReadIconOrCursorFromFile(
ckfree(lpIDE);
Tcl_Close(NULL, channel);
- if (lpIR == NULL) {
- Tcl_AppendResult(interp, "Reading of ", Tcl_GetString(fileName),
- " failed!", NULL);
- return NULL;
- }
return lpIR;
readError:
@@ -2817,9 +2822,8 @@ Tk_WmObjCmd(
return TCL_ERROR;
}
if (objc == 2) {
- Tcl_SetResult(interp,
- ((dispPtr->flags & TK_DISPLAY_WM_TRACING) ? "on" : "off"),
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
+ dispPtr->flags & TK_DISPLAY_WM_TRACING));
return TCL_OK;
}
if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) {
@@ -2848,8 +2852,9 @@ Tk_WmObjCmd(
}
if (!Tk_IsTopLevel(winPtr) && (index != WMOPT_MANAGE)
&& (index != WMOPT_FORGET)) {
- Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't a top-level window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't a top-level window", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", NULL);
return TCL_ERROR;
}
@@ -2959,9 +2964,13 @@ WmAspectCmd(
}
if (objc == 3) {
if (wmPtr->sizeHintsFlags & PAspect) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d %d %d",
- wmPtr->minAspect.x, wmPtr->minAspect.y,
- wmPtr->maxAspect.x, wmPtr->maxAspect.y));
+ Tcl_Obj *results[4];
+
+ results[0] = Tcl_NewIntObj(wmPtr->minAspect.x);
+ results[1] = Tcl_NewIntObj(wmPtr->minAspect.y);
+ results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x);
+ results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
}
@@ -2975,7 +2984,9 @@ WmAspectCmd(
return TCL_ERROR;
}
if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) || (denom2 <= 0)) {
- Tcl_SetResult(interp, "aspect number can't be <= 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "aspect number can't be <= 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "ASPECT", NULL);
return TCL_ERROR;
}
wmPtr->minAspect.x = numer1;
@@ -3093,8 +3104,10 @@ WmAttributesCmd(
stylePtr = &exStyle;
styleBit = WS_EX_TOPMOST;
if ((i < objc-1) && (winPtr->flags & TK_EMBEDDED)) {
- Tcl_AppendResult(interp, "can't set topmost flag on ",
- winPtr->pathName, ": it is an embedded window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't set topmost flag on %s: it is an embedded window",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "TOPMOST", NULL);
return TCL_ERROR;
}
} else {
@@ -3249,10 +3262,11 @@ WmAttributesCmd(
if (fullscreen_attr_changed) {
if (fullscreen_attr) {
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp,
- "can't set fullscreen attribute for \"",
- winPtr->pathName, "\": override-redirect flag is set",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't set fullscreen attribute for \"%s\":"
+ " override-redirect flag is set", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ATTR",
+ "OVERRIDE_REDIRECT", NULL);
return TCL_ERROR;
}
@@ -3266,10 +3280,10 @@ WmAttributesCmd(
(WidthOfScreen(Tk_Screen(winPtr)) > wmPtr->maxWidth)) ||
((wmPtr->maxHeight > 0) &&
(HeightOfScreen(Tk_Screen(winPtr)) > wmPtr->maxHeight))) {
- Tcl_AppendResult(interp,
- "can't set fullscreen attribute for \"",
- winPtr->pathName, "\": max width/height is too small",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't set fullscreen attribute for \"%s\":"
+ " max width/height is too small", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ATTR", "SMALL_MAX", NULL);
return TCL_ERROR;
}
}
@@ -3315,7 +3329,8 @@ WmClientCmd(
}
if (objc == 3) {
if (wmPtr->clientMachine != NULL) {
- Tcl_SetResult(interp, wmPtr->clientMachine, TCL_STATIC);
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj(wmPtr->clientMachine, -1));
}
return TCL_OK;
}
@@ -3477,8 +3492,10 @@ WmCommandCmd(
}
if (objc == 3) {
if (wmPtr->cmdArgv != NULL) {
- char *merged = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv);
- Tcl_SetResult(interp, merged, TCL_DYNAMIC);
+ char *merged = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv);
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(merged, -1));
+ ckfree(merged);
}
return TCL_OK;
}
@@ -3540,14 +3557,18 @@ WmDeiconifyCmd(
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't deiconify ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't deiconify %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", NULL);
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
if (!SendMessage(wmPtr->wrapper, TK_DEICONIFY, 0, 0)) {
- Tcl_AppendResult(interp, "can't deiconify ", winPtr->pathName,
- ": the container does not support the request", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't deiconify %s: the container does not support the request",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "WHAT", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -3595,8 +3616,8 @@ WmFocusmodelCmd(
return TCL_ERROR;
}
if (objc == 3) {
- Tcl_SetResult(interp, (wmPtr->hints.input ? "passive" : "active"),
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ wmPtr->hints.input ? "passive" : "active", -1));
return TCL_OK;
}
@@ -3800,9 +3821,13 @@ WmGridCmd(
}
if (objc == 3) {
if (wmPtr->sizeHintsFlags & PBaseSize) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d %d %d",
- wmPtr->reqGridWidth, wmPtr->reqGridHeight,
- wmPtr->widthInc, wmPtr->heightInc));
+ Tcl_Obj *results[4];
+
+ results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth);
+ results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight);
+ results[2] = Tcl_NewIntObj(wmPtr->widthInc);
+ results[3] = Tcl_NewIntObj(wmPtr->heightInc);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
}
@@ -3829,19 +3854,27 @@ WmGridCmd(
return TCL_ERROR;
}
if (reqWidth < 0) {
- Tcl_SetResult(interp, "baseWidth can't be < 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "baseWidth can't be < 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
return TCL_ERROR;
}
if (reqHeight < 0) {
- Tcl_SetResult(interp, "baseHeight can't be < 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "baseHeight can't be < 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
return TCL_ERROR;
}
if (widthInc <= 0) {
- Tcl_SetResult(interp, "widthInc can't be <= 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "widthInc can't be <= 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
return TCL_ERROR;
}
if (heightInc <= 0) {
- Tcl_SetResult(interp, "heightInc can't be <= 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "heightInc can't be <= 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GRID", NULL);
return TCL_ERROR;
}
Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc,
@@ -3887,7 +3920,7 @@ WmGroupCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & WindowGroupHint) {
- Tcl_SetResult(interp, wmPtr->leaderName, TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->leaderName, -1));
}
return TCL_OK;
}
@@ -3954,8 +3987,9 @@ WmIconbitmapCmd(
const char *argv3 = Tcl_GetString(objv[3]);
if (strcmp(argv3, "-default")) {
- Tcl_AppendResult(interp, "illegal option \"", argv3,
- "\" must be \"-default\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "illegal option \"%s\" must be \"-default\"", argv3));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONBITMAP", "OPTION",NULL);
return TCL_ERROR;
}
useWinPtr = NULL;
@@ -3965,9 +3999,9 @@ WmIconbitmapCmd(
*/
if (wmPtr->hints.flags & IconPixmapHint) {
- Tcl_SetResult(interp, (char *)
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap),
- TCL_STATIC);
+ -1));
}
return TCL_OK;
}
@@ -4026,6 +4060,7 @@ WmIconbitmapCmd(
*/
Pixmap pixmap;
+
Tcl_ResetResult(interp);
pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, string);
if (pixmap == None) {
@@ -4080,24 +4115,35 @@ WmIconifyCmd(
}
if (winPtr->flags & TK_EMBEDDED) {
if (!SendMessage(wmPtr->wrapper, TK_ICONIFY, 0, 0)) {
- Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": the container does not support the request", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify %s: the container does not support the request",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "CANNOT_ICONIFY", "EMBEDDED",
+ NULL);
return TCL_ERROR;
}
}
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": override-redirect flag is set", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": override-redirect flag is set",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "CANNOT_ICONIFY",
+ "OVERRIDE_REDIRECT", NULL);
return TCL_ERROR;
}
if (wmPtr->masterPtr != NULL) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": it is a transient", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": it is a transient",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "CANNOT_ICONIFY", "TRANSIENT",
+ NULL);
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify %s: it is an icon for %s",
+ winPtr->pathName, Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "CANNOT_ICONIFY", "ICON", NULL);
return TCL_ERROR;
}
TkpWmSetState(winPtr, IconicState);
@@ -4139,9 +4185,9 @@ WmIconmaskCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & IconMaskHint) {
- Tcl_SetResult(interp, (char *)
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask),
- TCL_STATIC);
+ -1));
}
return TCL_OK;
}
@@ -4196,9 +4242,8 @@ WmIconnameCmd(
return TCL_ERROR;
}
if (objc == 3) {
- Tcl_SetResult(interp,
- ((wmPtr->iconName != NULL) ? wmPtr->iconName : ""),
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ (wmPtr->iconName ? wmPtr->iconName : ""), -1));
return TCL_OK;
} else {
if (wmPtr->iconName != NULL) {
@@ -4274,8 +4319,10 @@ WmIconphotoCmd(
for (i = startObj; i < objc; i++) {
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
if (photo == NULL) {
- Tcl_AppendResult(interp, "can't use \"", Tcl_GetString(objv[i]),
- "\" as iconphoto: not a photo image", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use \"%s\" as iconphoto: not a photo image",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL);
return TCL_ERROR;
}
}
@@ -4325,8 +4372,10 @@ WmIconphotoCmd(
&bgraPixel.voidPtr, NULL, 0);
if (!iconInfo.hbmColor) {
ckfree(lpIR);
- Tcl_AppendResult(interp, "failed to create color bitmap for \"",
- Tcl_GetString(objv[i]), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "failed to create color bitmap for \"%s\"",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "BITMAP", NULL);
return TCL_ERROR;
}
@@ -4355,8 +4404,10 @@ WmIconphotoCmd(
if (!iconInfo.hbmMask) {
DeleteObject(iconInfo.hbmColor);
ckfree(lpIR);
- Tcl_AppendResult(interp, "failed to create mask bitmap for \"",
- Tcl_GetString(objv[i]), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "failed to create mask bitmap for \"%s\"",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "MASK", NULL);
return TCL_ERROR;
}
@@ -4375,8 +4426,10 @@ WmIconphotoCmd(
*/
ckfree(lpIR);
- Tcl_AppendResult(interp, "failed to create icon for \"",
- Tcl_GetString(objv[i]), "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "failed to create icon for \"%s\"",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "ICON", NULL);
return TCL_ERROR;
}
lpIR->IconImages[i-startObj].Width = width;
@@ -4433,8 +4486,11 @@ WmIconpositionCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & IconPositionHint) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d",
- wmPtr->hints.icon_x, wmPtr->hints.icon_y));
+ Tcl_Obj *results[2];
+
+ results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x);
+ results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
}
return TCL_OK;
}
@@ -4488,7 +4544,7 @@ WmIconwindowCmd(
}
if (objc == 3) {
if (wmPtr->icon != NULL) {
- Tcl_SetResult(interp, Tk_PathName(wmPtr->icon), TCL_STATIC);
+ Tcl_SetObjResult(interp, TkNewWindowObj(wmPtr->icon));
}
return TCL_OK;
}
@@ -4513,15 +4569,18 @@ WmIconwindowCmd(
return TCL_ERROR;
}
if (!Tk_IsTopLevel(tkwin2)) {
- Tcl_AppendResult(interp, "can't use ", Tcl_GetString(objv[3]),
- " as icon window: not at top level", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use %s as icon window: not at top level",
+ Tcl_GetString(objv[3])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONWIN", "INNER", NULL);
return TCL_ERROR;
}
wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr;
if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, Tcl_GetString(objv[3]),
- " is already an icon for ", Tk_PathName(wmPtr2->iconFor),
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s is already an icon for %s",
+ Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONWIN", "ICON", NULL);
return TCL_ERROR;
}
if (wmPtr->icon != NULL) {
@@ -4589,9 +4648,10 @@ WmManageCmd(
if (!Tk_IsTopLevel(frameWin)) {
if (!Tk_IsManageable(frameWin)) {
- Tcl_AppendResult(interp, "window \"",
- Tk_PathName(frameWin), "\" is not manageable: must be "
- "a frame, labelframe or toplevel", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" is not manageable: must be a frame,"
+ " labelframe or toplevel", Tk_PathName(frameWin)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", "TYPE", NULL);
return TCL_ERROR;
}
TkFocusSplit(winPtr);
@@ -4645,8 +4705,12 @@ WmMaxsizeCmd(
return TCL_ERROR;
}
if (objc == 3) {
+ Tcl_Obj *results[2];
+
GetMaxSize(wmPtr, &width, &height);
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d", width, height));
+ results[0] = Tcl_NewIntObj(width);
+ results[1] = Tcl_NewIntObj(height);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK)
@@ -4692,8 +4756,12 @@ WmMinsizeCmd(
return TCL_ERROR;
}
if (objc == 3) {
+ Tcl_Obj *results[2];
+
GetMinSize(wmPtr, &width, &height);
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d", width, height));
+ results[0] = Tcl_NewIntObj(width);
+ results[1] = Tcl_NewIntObj(height);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK)
@@ -4742,8 +4810,10 @@ WmOverrideredirectCmd(
if (winPtr->flags & TK_EMBEDDED) {
curValue = SendMessage(wmPtr->wrapper, TK_OVERRIDEREDIRECT, -1, -1)-1;
if (curValue < 0) {
- Tcl_AppendResult(interp,
- "Container does not support overrideredirect", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Container does not support overrideredirect", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "OVERRIDE_REDIRECT", "WHAT",
+ NULL);
return TCL_ERROR;
}
} else {
@@ -4816,11 +4886,14 @@ WmPositionfromCmd(
return TCL_ERROR;
}
if (objc == 3) {
+ const char *sourceStr = "";
+
if (wmPtr->sizeHintsFlags & USPosition) {
- Tcl_SetResult(interp, "user", TCL_STATIC);
+ sourceStr = "user";
} else if (wmPtr->sizeHintsFlags & PPosition) {
- Tcl_SetResult(interp, "program", TCL_STATIC);
+ sourceStr = "program";
}
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sourceStr, -1));
return TCL_OK;
}
if (*Tcl_GetString(objv[3]) == '\0') {
@@ -4898,7 +4971,8 @@ WmProtocolCmd(
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
if (protPtr->protocol == protocol) {
- Tcl_SetResult(interp, protPtr->command, TCL_STATIC);
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj(protPtr->command, -1));
return TCL_OK;
}
}
@@ -4967,9 +5041,11 @@ WmResizableCmd(
return TCL_ERROR;
}
if (objc == 3) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d",
- (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) ? 0 : 1,
- (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) ? 0 : 1));
+ Tcl_Obj *results[2];
+
+ results[0] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_WIDTH_NOT_RESIZABLE));
+ results[1] = Tcl_NewBooleanObj(!(wmPtr->flags&WM_HEIGHT_NOT_RESIZABLE));
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK)
@@ -5033,11 +5109,14 @@ WmSizefromCmd(
return TCL_ERROR;
}
if (objc == 3) {
+ const char *sourceStr = "";
+
if (wmPtr->sizeHintsFlags & USSize) {
- Tcl_SetResult(interp, "user", TCL_STATIC);
+ sourceStr = "user";
} else if (wmPtr->sizeHintsFlags & PSize) {
- Tcl_SetResult(interp, "program", TCL_STATIC);
+ sourceStr = "program";
}
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sourceStr, -1));
return TCL_OK;
}
@@ -5111,7 +5190,7 @@ WmStackorderCmd(
return TCL_OK;
} else {
TkWindow *winPtr2, **winPtr2Ptr = &winPtr2;
- int index1=-1, index2=-1, result;
+ int index1 = -1, index2 = -1, result;
if (TkGetWindowFromObj(interp, tkwin, objv[4],
(Tk_Window *) winPtr2Ptr) != TCL_OK) {
@@ -5119,20 +5198,24 @@ WmStackorderCmd(
}
if (!Tk_IsTopLevel(winPtr2)) {
- Tcl_AppendResult(interp, "window \"", winPtr2->pathName,
- "\" isn't a top-level window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't a top-level window",
+ winPtr2->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr)) {
- Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't mapped", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't mapped", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr2)) {
- Tcl_AppendResult(interp, "window \"", winPtr2->pathName,
- "\" isn't mapped", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't mapped", winPtr2->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL);
return TCL_ERROR;
}
@@ -5143,7 +5226,9 @@ WmStackorderCmd(
windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr);
if (windows == NULL) {
- Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "TkWmStackorderToplevel failed", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "INTERNAL", NULL);
return TCL_ERROR;
}
@@ -5157,8 +5242,7 @@ WmStackorderCmd(
}
if (index1 == -1) {
Tcl_Panic("winPtr window not found");
- }
- if (index2 == -1) {
+ } else if (index2 == -1) {
Tcl_Panic("winPtr2 window not found");
}
@@ -5218,9 +5302,10 @@ WmStateCmd(
}
if (objc == 4) {
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't change state of ",
- Tcl_GetString(objv[2]), ": it is an icon for ",
- Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't change state of %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL);
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
@@ -5254,9 +5339,10 @@ WmStateCmd(
}
if (state+1 != SendMessage(wmPtr->wrapper, TK_STATE, state, 0)) {
- Tcl_AppendResult(interp, "can't change state of ",
- winPtr->pathName,
- ": the container does not support the request", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't change state of %s: the container does not support the request",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "WHAT", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -5272,13 +5358,19 @@ WmStateCmd(
*/
} else if (index == OPT_ICONIC) {
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": override-redirect flag is set", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": override-redirect flag is set",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE",
+ "ICONIFY_REDIRECTED", NULL);
return TCL_ERROR;
}
if (wmPtr->masterPtr != NULL) {
- Tcl_AppendResult(interp, "can't iconify \"",
- winPtr->pathName, "\": it is a transient", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": it is a transient",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE",
+ "ICONIFY_TRANSIENT", NULL);
return TCL_ERROR;
}
TkpWmSetState(winPtr, IconicState);
@@ -5291,31 +5383,26 @@ WmStateCmd(
Tcl_Panic("wm state not matched");
}
} else {
+ const char *stateStr = "";
+
if (wmPtr->iconFor != NULL) {
- Tcl_SetResult(interp, "icon", TCL_STATIC);
+ stateStr = "icon";
} else {
int state;
if (winPtr->flags & TK_EMBEDDED) {
- state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1)-1;
+ state = SendMessage(wmPtr->wrapper, TK_STATE, -1, -1) - 1;
} else {
state = wmPtr->hints.initial_state;
}
switch (state) {
- case NormalState:
- Tcl_SetResult(interp, "normal", TCL_STATIC);
- break;
- case IconicState:
- Tcl_SetResult(interp, "iconic", TCL_STATIC);
- break;
- case WithdrawnState:
- Tcl_SetResult(interp, "withdrawn", TCL_STATIC);
- break;
- case ZoomState:
- Tcl_SetResult(interp, "zoomed", TCL_STATIC);
- break;
+ case NormalState: stateStr = "normal"; break;
+ case IconicState: stateStr = "iconic"; break;
+ case WithdrawnState: stateStr = "withdrawn"; break;
+ case ZoomState: stateStr = "zoomed"; break;
}
}
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(stateStr, -1));
}
return TCL_OK;
}
@@ -5368,12 +5455,13 @@ WmTitleCmd(
GetWindowText(wrapper, buf, size);
Tcl_WinTCharToUtf(buf, -1, &titleString);
- Tcl_SetResult(interp, Tcl_DStringValue(&titleString), TCL_VOLATILE);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ Tcl_DStringValue(&titleString),
+ Tcl_DStringLength(&titleString)));
Tcl_DStringFree(&titleString);
} else {
- Tcl_SetResult(interp, (char *)
- ((wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid),
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ (wmPtr->title ? wmPtr->title : winPtr->nameUid), -1));
}
} else {
if (wmPtr->title != NULL) {
@@ -5429,7 +5517,7 @@ WmTransientCmd(
}
if (objc == 3) {
if (masterPtr != NULL) {
- Tcl_SetResult(interp, Tk_PathName(masterPtr), TCL_STATIC);
+ Tcl_SetObjResult(interp, TkNewWindowObj(masterPtr));
}
return TCL_OK;
}
@@ -5462,24 +5550,27 @@ WmTransientCmd(
Tk_MakeWindowExist((Tk_Window) masterPtr);
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[2]),
- "\" a transient: it is an icon for ",
- Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" a transient: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
return TCL_ERROR;
}
wmPtr2 = masterPtr->wmInfoPtr;
if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[3]),
- "\" a master: it is an icon for ",
- Tk_PathName(wmPtr2->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" a master: it is an icon for %s",
+ Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
return TCL_ERROR;
}
if (masterPtr == winPtr) {
- Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr),
- "\" its own master", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" its own master", Tk_PathName(winPtr)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
return TCL_ERROR;
} else if (masterPtr != wmPtr->masterPtr) {
/*
@@ -5547,15 +5638,19 @@ WmWithdrawCmd(
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't withdraw ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't withdraw %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL);
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
if (SendMessage(wmPtr->wrapper, TK_WITHDRAW, 0, 0) < 0) {
- Tcl_AppendResult(interp, "can't withdraw", Tcl_GetString(objv[2]),
- ": the container does not support the request", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't withdraw %s: the container does not support the request",
+ Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "WHAT", NULL);
return TCL_ERROR;
}
} else {
@@ -6277,7 +6372,9 @@ ParseGeometry(
return TCL_OK;
error:
- Tcl_AppendResult(interp, "bad geometry specifier \"", string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad geometry specifier \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", NULL);
return TCL_ERROR;
}
diff --git a/win/tkWinX.c b/win/tkWinX.c
index e85b7e7..22edb60 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -120,20 +120,19 @@ TkGetServerInfo(
Tk_Window tkwin) /* Token for window; this selects a particular
* display and server. */
{
- char buffer[60];
OSVERSIONINFO os;
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&os);
- sprintf(buffer, "Windows %d.%d %d %s", (int)os.dwMajorVersion,
- (int)os.dwMinorVersion, (int)os.dwBuildNumber,
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("Windows %d.%d %d %s",
+ (int) os.dwMajorVersion, (int) os.dwMinorVersion,
+ (int) os.dwBuildNumber,
#ifdef _WIN64
"Win64"
#else
"Win32"
#endif
- );
- Tcl_SetResult(interp, buffer, TCL_VOLATILE);
+ ));
}
/*
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index 08e8a8e..a343216 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -1062,7 +1062,8 @@ GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK)
return TCL_ERROR;
if (objc != 2) {
- Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args", -1));
+ Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
return TCL_ERROR;
}
for (i = 0; i < objc; ++i) {
@@ -1116,8 +1117,9 @@ Ttk_CreateVsapiElement(
O_HALFHEIGHT, O_HALFWIDTH };
if (objc < 2) {
- Tcl_AppendResult(interp,
- "missing required arguments 'class' and/or 'partId'", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "missing required arguments 'class' and/or 'partId'", -1));
+ Tcl_SetErrorCode(interp, "TCL", "VSAPI", "REQUIRED", NULL);
return TCL_ERROR;
}
@@ -1132,8 +1134,10 @@ Ttk_CreateVsapiElement(
for (i = 3; i < objc; i += 2) {
int tmp = 0;
if (i == objc -1) {
- Tcl_AppendResult(interp, "Missing value for \"",
- Tcl_GetString(objv[i]), "\".", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Missing value for \"%s\".",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TCL", "VSAPI", "MISSING", NULL);
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings,