summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.c
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2008-01-11 10:54:48 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2008-01-11 10:54:48 (GMT)
commit289b2781681f8116ff2540bdffc717fc78f39fae (patch)
treee5272edc786b794af1622d65133492b3e113f7df /unix/tclUnixThrd.c
parentc1ca08db8c81d3993594cb75b7ff33a35a9bd321 (diff)
downloadtcl-289b2781681f8116ff2540bdffc717fc78f39fae.zip
tcl-289b2781681f8116ff2540bdffc717fc78f39fae.tar.gz
tcl-289b2781681f8116ff2540bdffc717fc78f39fae.tar.bz2
* unix/tclUnixThrd.c (TclpThreadGetStackSize): fix for crash in
freebsd [Bug 1860425].
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 99351a9..dfed046 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixThrd.c,v 1.55 2007/12/13 15:28:42 dgp Exp $
+ * RCS: @(#) $Id: tclUnixThrd.c,v 1.56 2008/01/11 10:54:49 msofer Exp $
*/
#include "tclInt.h"
@@ -253,14 +253,11 @@ TclpThreadGetStackSize(void)
if (!initialized) {
initialized = 1;
-#if 0
- if (pthread_attr_init(&threadAttr) != 0) {
- return 0;
- }
-#else
return 0;
-#endif
} else {
+ if (pthread_attr_init(&threadAttr) != 0) {
+ return -1;
+ }
if (TclpPthreadGetAttrs(pthread_self(), &threadAttr) != 0) {
pthread_attr_destroy(&threadAttr);
return (size_t)-1;
t">(type="dialog") # -------------------------------------------------------------------- # convenience dialogues class _QueryDialog(Dialog): def __init__(self, title, prompt, initialvalue=None, minvalue = None, maxvalue = None, parent = None): self.prompt = prompt self.minvalue = minvalue self.maxvalue = maxvalue self.initialvalue = initialvalue Dialog.__init__(self, parent, title) def destroy(self): self.entry = None Dialog.destroy(self) def body(self, master): w = Label(master, text=self.prompt, justify=LEFT) w.grid(row=0, padx=5, sticky=W) self.entry = Entry(master, name="entry") self.entry.grid(row=1, padx=5, sticky=W+E) if self.initialvalue is not None: self.entry.insert(0, self.initialvalue) self.entry.select_range(0, END) return self.entry def validate(self): try: result = self.getresult() except ValueError: messagebox.showwarning( "Illegal value", self.errormessage + "\nPlease try again", parent = self ) return 0 if self.minvalue is not None and result < self.minvalue: messagebox.showwarning( "Too small", "The allowed minimum value is %s. " "Please try again." % self.minvalue, parent = self ) return 0 if self.maxvalue is not None and result > self.maxvalue: messagebox.showwarning( "Too large", "The allowed maximum value is %s. " "Please try again." % self.maxvalue, parent = self ) return 0 self.result = result return 1 class _QueryInteger(_QueryDialog): errormessage = "Not an integer." def getresult(self): return self.getint(self.entry.get()) def askinteger(title, prompt, **kw): '''get an integer from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is an integer ''' d = _QueryInteger(title, prompt, **kw) return d.result class _QueryFloat(_QueryDialog): errormessage = "Not a floating point value." def getresult(self): return self.getdouble(self.entry.get()) def askfloat(title, prompt, **kw): '''get a float from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a float ''' d = _QueryFloat(title, prompt, **kw) return d.result class _QueryString(_QueryDialog): def __init__(self, *args, **kw): if "show" in kw: self.__show = kw["show"] del kw["show"] else: self.__show = None _QueryDialog.__init__(self, *args, **kw) def body(self, master): entry = _QueryDialog.body(self, master) if self.__show is not None: entry.configure(show=self.__show) return entry def getresult(self): return self.entry.get() def askstring(title, prompt, **kw): '''get a string from the user Arguments: title -- the dialog title prompt -- the label text **kw -- see SimpleDialog class Return value is a string ''' d = _QueryString(title, prompt, **kw) return d.result if __name__ == '__main__': def test(): root = Tk() def doit(root=root): d = SimpleDialog(root, text="This is a test dialog. " "Would this have been an actual dialog, " "the buttons below would have been glowing " "in soft pink light.\n" "Do you believe this?", buttons=["Yes", "No", "Cancel"], default=0, cancel=2, title="Test Dialog") print(d.go()) print(askinteger("Spam", "Egg count", initialvalue=12*12)) print(askfloat("Spam", "Egg weight\n(in tons)", minvalue=1, maxvalue=100)) print(askstring("Spam", "Egg label")) t = Button(root, text='Test', command=doit) t.pack() q = Button(root, text='Quit', command=t.quit) q.pack() t.mainloop() test()