Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use both TCL_SETVAR and TCL_SETVAR2 for tcl 9 support#29144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 2 commits intomatplotlib:mainfromksunden:tcl9
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletionssrc/_tkagg.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,6 +92,7 @@
// Global vars for Tcl functions. We load these symbols from the tkinter
// extension module or loaded Tcl libraries at run-time.
static Tcl_SetVar_t TCL_SETVAR;
static Tcl_SetVar2_t TCL_SETVAR2;

static void
mpl_tk_blit(py::object interp_obj, const char *photo_name,
Expand DownExpand Up@@ -173,7 +174,15 @@
std::string dpi = std::to_string(LOWORD(wParam));

Tcl_Interp* interp = (Tcl_Interp*)dwRefData;
TCL_SETVAR(interp, var_name.c_str(), dpi.c_str(), 0);
if (TCL_SETVAR) {
TCL_SETVAR(interp, var_name.c_str(), dpi.c_str(), 0);
} else if (TCL_SETVAR2) {
TCL_SETVAR2(interp, var_name.c_str(), NULL, dpi.c_str(), 0);
} else {
// This should be prevented at import time, and therefore unreachable.
// But defensively throw just in case.
throw std::runtime_error("Unable to call Tcl_SetVar or Tcl_SetVar2");
}
}
return 0;
case WM_NCDESTROY:
Expand DownExpand Up@@ -246,13 +255,16 @@
if (auto ptr = dlsym(lib, "Tcl_SetVar")) {
TCL_SETVAR = (Tcl_SetVar_t)ptr;
}
if (auto ptr = dlsym(lib, "Tcl_SetVar2")) {
TCL_SETVAR2 = (Tcl_SetVar2_t)ptr;
}
if (auto ptr = dlsym(lib, "Tk_FindPhoto")) {
TK_FIND_PHOTO = (Tk_FindPhoto_t)ptr;
}
if (auto ptr = dlsym(lib, "Tk_PhotoPutBlock")) {
TK_PHOTO_PUT_BLOCK = (Tk_PhotoPutBlock_t)ptr;
}
return TCL_SETVAR && TK_FIND_PHOTO && TK_PHOTO_PUT_BLOCK;
return(TCL_SETVAR || TCL_SETVAR2) && TK_FIND_PHOTO && TK_PHOTO_PUT_BLOCK;
}

#ifdef WIN32_DLL
Expand DownExpand Up@@ -343,8 +355,8 @@
throw py::error_already_set();
}

if (!TCL_SETVAR) {
throw py::import_error("Failed to load Tcl_SetVar");
if (!(TCL_SETVAR || TCL_SETVAR2)) {
throw py::import_error("Failed to load Tcl_SetVar or Tcl_SetVar2");

Check warning on line 359 in src/_tkagg.cpp

View check run for this annotation

Codecov/ codecov/patch

src/_tkagg.cpp#L359

Added line #L359 was not covered by tests
} else if (!TK_FIND_PHOTO) {
throw py::import_error("Failed to load Tk_FindPhoto");
} else if (!TK_PHOTO_PUT_BLOCK) {
Expand Down
3 changes: 3 additions & 0 deletionssrc/_tkmini.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,9 @@ typedef int (*Tk_PhotoPutBlock_t) (Tcl_Interp *interp, Tk_PhotoHandle handle,
/* Tcl_SetVar typedef */
typedef const char *(*Tcl_SetVar_t)(Tcl_Interp *interp, const char *varName,
const char *newValue, int flags);
/* Tcl_SetVar2 typedef */
typedef const char *(*Tcl_SetVar2_t)(Tcl_Interp *interp, const char *part1, const char *part2,
const char *newValue, int flags);

#ifdef __cplusplus
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp