From: Robert Roebling Date: Sun, 3 Jan 1999 16:54:26 +0000 (+0000) Subject: Proofed that iostreams break threads X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f5abe9111b4f425bc2430111b2b77844e87b2f29 Proofed that iostreams break threads git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1313 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/textctrl.h b/include/wx/gtk/textctrl.h index 061e82e3bd..cc3ad2a303 100644 --- a/include/wx/gtk/textctrl.h +++ b/include/wx/gtk/textctrl.h @@ -21,12 +21,20 @@ #include "wx/string.h" #include "wx/control.h" +#ifdef wxUSE_STD_IOSTREAM + #if wxUSE_IOSTREAMH #include #else #include #endif +#else + +#define NO_TEXT_WINDOW_STREAM + +#endif + //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- @@ -43,7 +51,11 @@ extern const char *wxTextCtrlNameStr; // wxTextCtrl //----------------------------------------------------------------------------- +#ifndef NO_TEXT_WINDOW_STREAM class wxTextCtrl: public wxControl, public streambuf +#else +class wxTextCtrl: public wxControl +#endif { DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxTextCtrl); @@ -89,6 +101,7 @@ class wxTextCtrl: public wxControl, public streambuf void OnChar( wxKeyEvent &event ); +#ifndef NO_TEXT_WINDOW_STREAM int overflow(int i); int sync(); int underflow(); @@ -99,6 +112,7 @@ class wxTextCtrl: public wxControl, public streambuf wxTextCtrl& operator<<(float f); wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(const char c); +#endif void SetFont( const wxFont &font ); void SetForegroundColour(const wxColour &colour); diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index fc4a1e35e2..833f5d2375 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -40,8 +40,10 @@ extern wxList wxTopLevelWindows; class wxLayoutConstraints; class wxSizer; +#if wxUSE_WX_RESOURCES class wxResourceTable; class wxItemResource; +#endif class wxClientData; class wxVoidClientData; @@ -120,10 +122,12 @@ public: const wxString& name = wxPanelNameStr); virtual ~wxWindow(); +#if wxUSE_WX_RESOURCES virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = (const wxResourceTable *) NULL); virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, const wxResourceTable *table = (const wxResourceTable *) NULL); +#endif bool Close( bool force = FALSE ); virtual bool Destroy(); diff --git a/include/wx/gtk1/textctrl.h b/include/wx/gtk1/textctrl.h index 061e82e3bd..cc3ad2a303 100644 --- a/include/wx/gtk1/textctrl.h +++ b/include/wx/gtk1/textctrl.h @@ -21,12 +21,20 @@ #include "wx/string.h" #include "wx/control.h" +#ifdef wxUSE_STD_IOSTREAM + #if wxUSE_IOSTREAMH #include #else #include #endif +#else + +#define NO_TEXT_WINDOW_STREAM + +#endif + //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- @@ -43,7 +51,11 @@ extern const char *wxTextCtrlNameStr; // wxTextCtrl //----------------------------------------------------------------------------- +#ifndef NO_TEXT_WINDOW_STREAM class wxTextCtrl: public wxControl, public streambuf +#else +class wxTextCtrl: public wxControl +#endif { DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxTextCtrl); @@ -89,6 +101,7 @@ class wxTextCtrl: public wxControl, public streambuf void OnChar( wxKeyEvent &event ); +#ifndef NO_TEXT_WINDOW_STREAM int overflow(int i); int sync(); int underflow(); @@ -99,6 +112,7 @@ class wxTextCtrl: public wxControl, public streambuf wxTextCtrl& operator<<(float f); wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(const char c); +#endif void SetFont( const wxFont &font ); void SetForegroundColour(const wxColour &colour); diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index fc4a1e35e2..833f5d2375 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -40,8 +40,10 @@ extern wxList wxTopLevelWindows; class wxLayoutConstraints; class wxSizer; +#if wxUSE_WX_RESOURCES class wxResourceTable; class wxItemResource; +#endif class wxClientData; class wxVoidClientData; @@ -120,10 +122,12 @@ public: const wxString& name = wxPanelNameStr); virtual ~wxWindow(); +#if wxUSE_WX_RESOURCES virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = (const wxResourceTable *) NULL); virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, const wxResourceTable *table = (const wxResourceTable *) NULL); +#endif bool Close( bool force = FALSE ); virtual bool Destroy(); diff --git a/include/wx/log.h b/include/wx/log.h index 32c9b1f0e8..074adb078f 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -180,6 +180,7 @@ private: FILE *m_fp; }; +#ifdef wxUSE_STD_IOSTREAM // log everything to an "ostream", cerr by default class WXDLLEXPORT wxLogStream : public wxLog { @@ -194,9 +195,11 @@ protected: // @@ using ptr here to avoid including from this file ostream *m_ostr; }; +#endif #ifndef wxUSE_NOGUI +#ifdef wxUSE_STD_IOSTREAM // log everything to a text window (GUI only of course) class WXDLLEXPORT wxLogTextCtrl : public wxLogStream { @@ -205,6 +208,7 @@ public: wxLogTextCtrl(wxTextCtrl *pTextCtrl); ~wxLogTextCtrl(); }; +#endif // ---------------------------------------------------------------------------- // GUI log target, the default one for wxWindows programs diff --git a/setup/maketmpl.in b/setup/maketmpl.in index 799888f218..c4f007c35a 100644 --- a/setup/maketmpl.in +++ b/setup/maketmpl.in @@ -33,11 +33,11 @@ DEBUG = @WXDEBUG@ @WXDEBUG_DEFINE@ CC = @CC@ CPP = @CPP@ CPPFLAGS=@CPPFLAGS@ -CFLAGS = @CFLAGS@ $(CPPFLAGS) $(OPTIMISE) $(PROFILE) $(DEBUG) +CFLAGS = @CFLAGS@ $(CPPFLAGS) $(OPTIMISE) $(PROFILE) $(DEBUG) -D_REENTRANT # c++-compiler stuff CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ $(CPPFLAGS) $(OPTIMISE) $(PROFILE) $(DEBUG) +CXXFLAGS = @CXXFLAGS@ $(CPPFLAGS) $(OPTIMISE) $(PROFILE) $(DEBUG) -D_REENTRANT CXXCPP = @CXXCPP@ # shared compile stuff diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index af885044bd..7716488573 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -75,6 +75,7 @@ #endif #include "wx/setup.h" +#include "wx/log.h" // No, Cygwin doesn't appear to have fnmatch.h after all. #if defined(HAVE_FNMATCH_H) @@ -1091,7 +1092,7 @@ char *wxGetTempFileName(const wxString& prefix, char *buf) return buf; } } - cerr << _("wxWindows: error finding temporary file name.\n"); + wxLogError( _("wxWindows: error finding temporary file name.\n") ); if (buf) buf[0] = 0; return (char *) NULL; #endif diff --git a/src/common/log.cpp b/src/common/log.cpp index f92320b0f8..7e7d4f8566 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -389,6 +389,7 @@ void wxLogStderr::DoLogString(const char *szString) // wxLogStream implementation // ---------------------------------------------------------------------------- +#ifdef wxUSE_STD_IOSTREAM wxLogStream::wxLogStream(ostream *ostr) { if ( ostr == NULL ) @@ -401,15 +402,17 @@ void wxLogStream::DoLogString(const char *szString) { (*m_ostr) << szString << endl << flush; } +#endif #ifndef wxUSE_NOGUI + // ---------------------------------------------------------------------------- // wxLogTextCtrl implementation // ---------------------------------------------------------------------------- -wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl) -// @@@ TODO: in wxGTK wxTextCtrl doesn't derive from streambuf -// Also, in DLL mode in wxMSW, can't use it. +#ifdef wxUSE_STD_IOSTREAM +wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl) +// DLL mode in wxMSW, can't use it. #if defined(NO_TEXT_WINDOW_STREAM) #else : wxLogStream(new ostream(pTextCtrl)) @@ -421,6 +424,7 @@ wxLogTextCtrl::~wxLogTextCtrl() { delete m_ostr; } +#endif // ---------------------------------------------------------------------------- // wxLogGui implementation diff --git a/src/gtk.inc b/src/gtk.inc index f0179c8f59..974a86ad3d 100644 --- a/src/gtk.inc +++ b/src/gtk.inc @@ -8,6 +8,7 @@ LIB_MINOR=1 # define library sources + LIB_CPP_SRC=\ \ common/cmndata.cpp \ @@ -38,7 +39,6 @@ LIB_CPP_SRC=\ common/dbtable.cpp \ common/postscrp.cpp \ common/prntbase.cpp \ - common/resource.cpp \ common/serbase.cpp \ common/string.cpp \ common/textfile.cpp \ @@ -57,7 +57,6 @@ LIB_CPP_SRC=\ common/validate.cpp \ common/valtext.cpp \ common/variant.cpp \ - common/wxexpr.cpp \ common/socket.cpp \ common/sckaddr.cpp \ common/sckipc.cpp \ @@ -66,6 +65,8 @@ LIB_CPP_SRC=\ common/ftp.cpp \ common/url.cpp \ common/tokenzr.cpp \ + common/resource.cpp \ + common/wxexpr.cpp \ \ gtk/accel.cpp \ gtk/app.cpp \ diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 13757a06a7..87715dd428 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -19,7 +19,9 @@ #include "wx/memory.h" #include "wx/font.h" #include "wx/settings.h" +#ifdef wxUSE_WX_RESOURCES #include "wx/resource.h" +#endif #include "wx/module.h" #include "wx/image.h" #include "wx/thread.h" @@ -320,8 +322,7 @@ void wxApp::CommonInit(void) #endif */ wxSystemSettings::Init(); - wxTheResourceCache = new wxResourceCache(wxKEY_STRING); - + wxTheFontNameDirectory = new wxFontNameDirectory; wxTheFontNameDirectory->Initialize(); @@ -331,7 +332,11 @@ void wxApp::CommonInit(void) wxInitializeStockLists(); wxInitializeStockObjects(); +#ifdef wxUSE_WX_RESOURCES + wxTheResourceCache = new wxResourceCache(wxKEY_STRING); + wxInitializeResourceSystem(); +#endif wxImage::InitStandardHandlers(); @@ -344,14 +349,16 @@ void wxApp::CommonCleanUp(void) wxDELETE(wxTheFontNameDirectory); wxDeleteStockObjects(); +#ifdef wxUSE_WX_RESOURCES wxFlushResources(); wxDELETE(wxTheResourceCache); + + wxCleanUpResourceSystem(); +#endif wxDeleteStockLists(); - wxCleanUpResourceSystem(); - wxImage::CleanUpHandlers(); wxSystemSettings::Done(); diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 147c0d5a1c..50fff73132 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -180,7 +180,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) else { /* the user pressed on the menu item -> report */ - item->m_isChecked; /* make consistent again */ + item->m_isChecked = item->IsChecked(); /* make consistent again */ } } diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index ea17cd1920..401fd4d460 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -68,13 +68,21 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_CHAR(wxTextCtrl::OnChar) END_EVENT_TABLE() +#ifndef NO_TEXT_WINDOW_STREAM wxTextCtrl::wxTextCtrl() : streambuf() { if (allocate()) setp(base(),ebuf()); m_modified = FALSE; } +#else +wxTextCtrl::wxTextCtrl() +{ + m_modified = FALSE; +} +#endif +#ifndef NO_TEXT_WINDOW_STREAM wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, int style, const wxValidator& validator, const wxString &name ) : streambuf() @@ -84,6 +92,15 @@ wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, m_modified = FALSE; Create( parent, id, value, pos, size, style, validator, name ); } +#else +wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, + const wxPoint &pos, const wxSize &size, + int style, const wxValidator& validator, const wxString &name ) +{ + m_modified = FALSE; + Create( parent, id, value, pos, size, style, validator, name ); +} +#endif bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, @@ -621,6 +638,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) key_event.Skip(); } +#ifndef NO_TEXT_WINDOW_STREAM int wxTextCtrl::overflow( int WXUNUSED(c) ) { int len = pptr() - pbase(); @@ -697,6 +715,7 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) WriteText(buf); return *this; } +#endif GtkWidget* wxTextCtrl::GetConnectWidget() { diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 13757a06a7..87715dd428 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -19,7 +19,9 @@ #include "wx/memory.h" #include "wx/font.h" #include "wx/settings.h" +#ifdef wxUSE_WX_RESOURCES #include "wx/resource.h" +#endif #include "wx/module.h" #include "wx/image.h" #include "wx/thread.h" @@ -320,8 +322,7 @@ void wxApp::CommonInit(void) #endif */ wxSystemSettings::Init(); - wxTheResourceCache = new wxResourceCache(wxKEY_STRING); - + wxTheFontNameDirectory = new wxFontNameDirectory; wxTheFontNameDirectory->Initialize(); @@ -331,7 +332,11 @@ void wxApp::CommonInit(void) wxInitializeStockLists(); wxInitializeStockObjects(); +#ifdef wxUSE_WX_RESOURCES + wxTheResourceCache = new wxResourceCache(wxKEY_STRING); + wxInitializeResourceSystem(); +#endif wxImage::InitStandardHandlers(); @@ -344,14 +349,16 @@ void wxApp::CommonCleanUp(void) wxDELETE(wxTheFontNameDirectory); wxDeleteStockObjects(); +#ifdef wxUSE_WX_RESOURCES wxFlushResources(); wxDELETE(wxTheResourceCache); + + wxCleanUpResourceSystem(); +#endif wxDeleteStockLists(); - wxCleanUpResourceSystem(); - wxImage::CleanUpHandlers(); wxSystemSettings::Done(); diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 147c0d5a1c..50fff73132 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -180,7 +180,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) else { /* the user pressed on the menu item -> report */ - item->m_isChecked; /* make consistent again */ + item->m_isChecked = item->IsChecked(); /* make consistent again */ } } diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index ea17cd1920..401fd4d460 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -68,13 +68,21 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_CHAR(wxTextCtrl::OnChar) END_EVENT_TABLE() +#ifndef NO_TEXT_WINDOW_STREAM wxTextCtrl::wxTextCtrl() : streambuf() { if (allocate()) setp(base(),ebuf()); m_modified = FALSE; } +#else +wxTextCtrl::wxTextCtrl() +{ + m_modified = FALSE; +} +#endif +#ifndef NO_TEXT_WINDOW_STREAM wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, int style, const wxValidator& validator, const wxString &name ) : streambuf() @@ -84,6 +92,15 @@ wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, m_modified = FALSE; Create( parent, id, value, pos, size, style, validator, name ); } +#else +wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, + const wxPoint &pos, const wxSize &size, + int style, const wxValidator& validator, const wxString &name ) +{ + m_modified = FALSE; + Create( parent, id, value, pos, size, style, validator, name ); +} +#endif bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, @@ -621,6 +638,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event ) key_event.Skip(); } +#ifndef NO_TEXT_WINDOW_STREAM int wxTextCtrl::overflow( int WXUNUSED(c) ) { int len = pptr() - pbase(); @@ -697,6 +715,7 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) WriteText(buf); return *this; } +#endif GtkWidget* wxTextCtrl::GetConnectWidget() {