Proofed that iostreams break threads

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1313 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-01-03 16:54:26 +00:00
parent 2d17d68f47
commit f5abe9111b
15 changed files with 116 additions and 18 deletions

View File

@@ -21,12 +21,20 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/control.h" #include "wx/control.h"
#ifdef wxUSE_STD_IOSTREAM
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <iostream.h> #include <iostream.h>
#else #else
#include <iostream> #include <iostream>
#endif #endif
#else
#define NO_TEXT_WINDOW_STREAM
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -43,7 +51,11 @@ extern const char *wxTextCtrlNameStr;
// wxTextCtrl // wxTextCtrl
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef NO_TEXT_WINDOW_STREAM
class wxTextCtrl: public wxControl, public streambuf class wxTextCtrl: public wxControl, public streambuf
#else
class wxTextCtrl: public wxControl
#endif
{ {
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxTextCtrl); DECLARE_DYNAMIC_CLASS(wxTextCtrl);
@@ -89,6 +101,7 @@ class wxTextCtrl: public wxControl, public streambuf
void OnChar( wxKeyEvent &event ); void OnChar( wxKeyEvent &event );
#ifndef NO_TEXT_WINDOW_STREAM
int overflow(int i); int overflow(int i);
int sync(); int sync();
int underflow(); int underflow();
@@ -99,6 +112,7 @@ class wxTextCtrl: public wxControl, public streambuf
wxTextCtrl& operator<<(float f); wxTextCtrl& operator<<(float f);
wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const char c); wxTextCtrl& operator<<(const char c);
#endif
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
void SetForegroundColour(const wxColour &colour); void SetForegroundColour(const wxColour &colour);

View File

@@ -40,8 +40,10 @@ extern wxList wxTopLevelWindows;
class wxLayoutConstraints; class wxLayoutConstraints;
class wxSizer; class wxSizer;
#if wxUSE_WX_RESOURCES
class wxResourceTable; class wxResourceTable;
class wxItemResource; class wxItemResource;
#endif
class wxClientData; class wxClientData;
class wxVoidClientData; class wxVoidClientData;
@@ -120,10 +122,12 @@ public:
const wxString& name = wxPanelNameStr); const wxString& name = wxPanelNameStr);
virtual ~wxWindow(); virtual ~wxWindow();
#if wxUSE_WX_RESOURCES
virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
const wxResourceTable *table = (const wxResourceTable *) NULL); const wxResourceTable *table = (const wxResourceTable *) NULL);
virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
const wxResourceTable *table = (const wxResourceTable *) NULL); const wxResourceTable *table = (const wxResourceTable *) NULL);
#endif
bool Close( bool force = FALSE ); bool Close( bool force = FALSE );
virtual bool Destroy(); virtual bool Destroy();

View File

@@ -21,12 +21,20 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/control.h" #include "wx/control.h"
#ifdef wxUSE_STD_IOSTREAM
#if wxUSE_IOSTREAMH #if wxUSE_IOSTREAMH
#include <iostream.h> #include <iostream.h>
#else #else
#include <iostream> #include <iostream>
#endif #endif
#else
#define NO_TEXT_WINDOW_STREAM
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -43,7 +51,11 @@ extern const char *wxTextCtrlNameStr;
// wxTextCtrl // wxTextCtrl
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef NO_TEXT_WINDOW_STREAM
class wxTextCtrl: public wxControl, public streambuf class wxTextCtrl: public wxControl, public streambuf
#else
class wxTextCtrl: public wxControl
#endif
{ {
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxTextCtrl); DECLARE_DYNAMIC_CLASS(wxTextCtrl);
@@ -89,6 +101,7 @@ class wxTextCtrl: public wxControl, public streambuf
void OnChar( wxKeyEvent &event ); void OnChar( wxKeyEvent &event );
#ifndef NO_TEXT_WINDOW_STREAM
int overflow(int i); int overflow(int i);
int sync(); int sync();
int underflow(); int underflow();
@@ -99,6 +112,7 @@ class wxTextCtrl: public wxControl, public streambuf
wxTextCtrl& operator<<(float f); wxTextCtrl& operator<<(float f);
wxTextCtrl& operator<<(double d); wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const char c); wxTextCtrl& operator<<(const char c);
#endif
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
void SetForegroundColour(const wxColour &colour); void SetForegroundColour(const wxColour &colour);

View File

@@ -40,8 +40,10 @@ extern wxList wxTopLevelWindows;
class wxLayoutConstraints; class wxLayoutConstraints;
class wxSizer; class wxSizer;
#if wxUSE_WX_RESOURCES
class wxResourceTable; class wxResourceTable;
class wxItemResource; class wxItemResource;
#endif
class wxClientData; class wxClientData;
class wxVoidClientData; class wxVoidClientData;
@@ -120,10 +122,12 @@ public:
const wxString& name = wxPanelNameStr); const wxString& name = wxPanelNameStr);
virtual ~wxWindow(); virtual ~wxWindow();
#if wxUSE_WX_RESOURCES
virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName, virtual bool LoadFromResource( wxWindow *parent, const wxString& resourceName,
const wxResourceTable *table = (const wxResourceTable *) NULL); const wxResourceTable *table = (const wxResourceTable *) NULL);
virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource,
const wxResourceTable *table = (const wxResourceTable *) NULL); const wxResourceTable *table = (const wxResourceTable *) NULL);
#endif
bool Close( bool force = FALSE ); bool Close( bool force = FALSE );
virtual bool Destroy(); virtual bool Destroy();

View File

@@ -180,6 +180,7 @@ private:
FILE *m_fp; FILE *m_fp;
}; };
#ifdef wxUSE_STD_IOSTREAM
// log everything to an "ostream", cerr by default // log everything to an "ostream", cerr by default
class WXDLLEXPORT wxLogStream : public wxLog class WXDLLEXPORT wxLogStream : public wxLog
{ {
@@ -194,9 +195,11 @@ protected:
// @@ using ptr here to avoid including <iostream.h> from this file // @@ using ptr here to avoid including <iostream.h> from this file
ostream *m_ostr; ostream *m_ostr;
}; };
#endif
#ifndef wxUSE_NOGUI #ifndef wxUSE_NOGUI
#ifdef wxUSE_STD_IOSTREAM
// log everything to a text window (GUI only of course) // log everything to a text window (GUI only of course)
class WXDLLEXPORT wxLogTextCtrl : public wxLogStream class WXDLLEXPORT wxLogTextCtrl : public wxLogStream
{ {
@@ -205,6 +208,7 @@ public:
wxLogTextCtrl(wxTextCtrl *pTextCtrl); wxLogTextCtrl(wxTextCtrl *pTextCtrl);
~wxLogTextCtrl(); ~wxLogTextCtrl();
}; };
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// GUI log target, the default one for wxWindows programs // GUI log target, the default one for wxWindows programs

View File

@@ -33,11 +33,11 @@ DEBUG = @WXDEBUG@ @WXDEBUG_DEFINE@
CC = @CC@ CC = @CC@
CPP = @CPP@ CPP = @CPP@
CPPFLAGS=@CPPFLAGS@ CPPFLAGS=@CPPFLAGS@
CFLAGS = @CFLAGS@ $(CPPFLAGS) $(OPTIMISE) $(PROFILE) $(DEBUG) CFLAGS = @CFLAGS@ $(CPPFLAGS) $(OPTIMISE) $(PROFILE) $(DEBUG) -D_REENTRANT
# c++-compiler stuff # c++-compiler stuff
CXX = @CXX@ CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ $(CPPFLAGS) $(OPTIMISE) $(PROFILE) $(DEBUG) CXXFLAGS = @CXXFLAGS@ $(CPPFLAGS) $(OPTIMISE) $(PROFILE) $(DEBUG) -D_REENTRANT
CXXCPP = @CXXCPP@ CXXCPP = @CXXCPP@
# shared compile stuff # shared compile stuff

View File

@@ -75,6 +75,7 @@
#endif #endif
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/log.h"
// No, Cygwin doesn't appear to have fnmatch.h after all. // No, Cygwin doesn't appear to have fnmatch.h after all.
#if defined(HAVE_FNMATCH_H) #if defined(HAVE_FNMATCH_H)
@@ -1091,7 +1092,7 @@ char *wxGetTempFileName(const wxString& prefix, char *buf)
return buf; return buf;
} }
} }
cerr << _("wxWindows: error finding temporary file name.\n"); wxLogError( _("wxWindows: error finding temporary file name.\n") );
if (buf) buf[0] = 0; if (buf) buf[0] = 0;
return (char *) NULL; return (char *) NULL;
#endif #endif

View File

@@ -389,6 +389,7 @@ void wxLogStderr::DoLogString(const char *szString)
// wxLogStream implementation // wxLogStream implementation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifdef wxUSE_STD_IOSTREAM
wxLogStream::wxLogStream(ostream *ostr) wxLogStream::wxLogStream(ostream *ostr)
{ {
if ( ostr == NULL ) if ( ostr == NULL )
@@ -401,15 +402,17 @@ void wxLogStream::DoLogString(const char *szString)
{ {
(*m_ostr) << szString << endl << flush; (*m_ostr) << szString << endl << flush;
} }
#endif
#ifndef wxUSE_NOGUI #ifndef wxUSE_NOGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxLogTextCtrl implementation // 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) #if defined(NO_TEXT_WINDOW_STREAM)
#else #else
: wxLogStream(new ostream(pTextCtrl)) : wxLogStream(new ostream(pTextCtrl))
@@ -421,6 +424,7 @@ wxLogTextCtrl::~wxLogTextCtrl()
{ {
delete m_ostr; delete m_ostr;
} }
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxLogGui implementation // wxLogGui implementation

View File

@@ -8,6 +8,7 @@ LIB_MINOR=1
# define library sources # define library sources
LIB_CPP_SRC=\ LIB_CPP_SRC=\
\ \
common/cmndata.cpp \ common/cmndata.cpp \
@@ -38,7 +39,6 @@ LIB_CPP_SRC=\
common/dbtable.cpp \ common/dbtable.cpp \
common/postscrp.cpp \ common/postscrp.cpp \
common/prntbase.cpp \ common/prntbase.cpp \
common/resource.cpp \
common/serbase.cpp \ common/serbase.cpp \
common/string.cpp \ common/string.cpp \
common/textfile.cpp \ common/textfile.cpp \
@@ -57,7 +57,6 @@ LIB_CPP_SRC=\
common/validate.cpp \ common/validate.cpp \
common/valtext.cpp \ common/valtext.cpp \
common/variant.cpp \ common/variant.cpp \
common/wxexpr.cpp \
common/socket.cpp \ common/socket.cpp \
common/sckaddr.cpp \ common/sckaddr.cpp \
common/sckipc.cpp \ common/sckipc.cpp \
@@ -66,6 +65,8 @@ LIB_CPP_SRC=\
common/ftp.cpp \ common/ftp.cpp \
common/url.cpp \ common/url.cpp \
common/tokenzr.cpp \ common/tokenzr.cpp \
common/resource.cpp \
common/wxexpr.cpp \
\ \
gtk/accel.cpp \ gtk/accel.cpp \
gtk/app.cpp \ gtk/app.cpp \

View File

@@ -19,7 +19,9 @@
#include "wx/memory.h" #include "wx/memory.h"
#include "wx/font.h" #include "wx/font.h"
#include "wx/settings.h" #include "wx/settings.h"
#ifdef wxUSE_WX_RESOURCES
#include "wx/resource.h" #include "wx/resource.h"
#endif
#include "wx/module.h" #include "wx/module.h"
#include "wx/image.h" #include "wx/image.h"
#include "wx/thread.h" #include "wx/thread.h"
@@ -320,7 +322,6 @@ void wxApp::CommonInit(void)
#endif #endif
*/ */
wxSystemSettings::Init(); wxSystemSettings::Init();
wxTheResourceCache = new wxResourceCache(wxKEY_STRING);
wxTheFontNameDirectory = new wxFontNameDirectory; wxTheFontNameDirectory = new wxFontNameDirectory;
wxTheFontNameDirectory->Initialize(); wxTheFontNameDirectory->Initialize();
@@ -331,7 +332,11 @@ void wxApp::CommonInit(void)
wxInitializeStockLists(); wxInitializeStockLists();
wxInitializeStockObjects(); wxInitializeStockObjects();
#ifdef wxUSE_WX_RESOURCES
wxTheResourceCache = new wxResourceCache(wxKEY_STRING);
wxInitializeResourceSystem(); wxInitializeResourceSystem();
#endif
wxImage::InitStandardHandlers(); wxImage::InitStandardHandlers();
@@ -344,13 +349,15 @@ void wxApp::CommonCleanUp(void)
wxDELETE(wxTheFontNameDirectory); wxDELETE(wxTheFontNameDirectory);
wxDeleteStockObjects(); wxDeleteStockObjects();
#ifdef wxUSE_WX_RESOURCES
wxFlushResources(); wxFlushResources();
wxDELETE(wxTheResourceCache); wxDELETE(wxTheResourceCache);
wxDeleteStockLists();
wxCleanUpResourceSystem(); wxCleanUpResourceSystem();
#endif
wxDeleteStockLists();
wxImage::CleanUpHandlers(); wxImage::CleanUpHandlers();

View File

@@ -180,7 +180,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
else else
{ {
/* the user pressed on the menu item -> report */ /* the user pressed on the menu item -> report */
item->m_isChecked; /* make consistent again */ item->m_isChecked = item->IsChecked(); /* make consistent again */
} }
} }

View File

@@ -68,13 +68,21 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
EVT_CHAR(wxTextCtrl::OnChar) EVT_CHAR(wxTextCtrl::OnChar)
END_EVENT_TABLE() END_EVENT_TABLE()
#ifndef NO_TEXT_WINDOW_STREAM
wxTextCtrl::wxTextCtrl() : streambuf() wxTextCtrl::wxTextCtrl() : streambuf()
{ {
if (allocate()) setp(base(),ebuf()); if (allocate()) setp(base(),ebuf());
m_modified = FALSE; m_modified = FALSE;
} }
#else
wxTextCtrl::wxTextCtrl()
{
m_modified = FALSE;
}
#endif
#ifndef NO_TEXT_WINDOW_STREAM
wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
int style, const wxValidator& validator, const wxString &name ) : streambuf() 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; m_modified = FALSE;
Create( parent, id, value, pos, size, style, validator, name ); 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, bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
@@ -621,6 +638,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
key_event.Skip(); key_event.Skip();
} }
#ifndef NO_TEXT_WINDOW_STREAM
int wxTextCtrl::overflow( int WXUNUSED(c) ) int wxTextCtrl::overflow( int WXUNUSED(c) )
{ {
int len = pptr() - pbase(); int len = pptr() - pbase();
@@ -697,6 +715,7 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
WriteText(buf); WriteText(buf);
return *this; return *this;
} }
#endif
GtkWidget* wxTextCtrl::GetConnectWidget() GtkWidget* wxTextCtrl::GetConnectWidget()
{ {

View File

@@ -19,7 +19,9 @@
#include "wx/memory.h" #include "wx/memory.h"
#include "wx/font.h" #include "wx/font.h"
#include "wx/settings.h" #include "wx/settings.h"
#ifdef wxUSE_WX_RESOURCES
#include "wx/resource.h" #include "wx/resource.h"
#endif
#include "wx/module.h" #include "wx/module.h"
#include "wx/image.h" #include "wx/image.h"
#include "wx/thread.h" #include "wx/thread.h"
@@ -320,7 +322,6 @@ void wxApp::CommonInit(void)
#endif #endif
*/ */
wxSystemSettings::Init(); wxSystemSettings::Init();
wxTheResourceCache = new wxResourceCache(wxKEY_STRING);
wxTheFontNameDirectory = new wxFontNameDirectory; wxTheFontNameDirectory = new wxFontNameDirectory;
wxTheFontNameDirectory->Initialize(); wxTheFontNameDirectory->Initialize();
@@ -331,7 +332,11 @@ void wxApp::CommonInit(void)
wxInitializeStockLists(); wxInitializeStockLists();
wxInitializeStockObjects(); wxInitializeStockObjects();
#ifdef wxUSE_WX_RESOURCES
wxTheResourceCache = new wxResourceCache(wxKEY_STRING);
wxInitializeResourceSystem(); wxInitializeResourceSystem();
#endif
wxImage::InitStandardHandlers(); wxImage::InitStandardHandlers();
@@ -344,13 +349,15 @@ void wxApp::CommonCleanUp(void)
wxDELETE(wxTheFontNameDirectory); wxDELETE(wxTheFontNameDirectory);
wxDeleteStockObjects(); wxDeleteStockObjects();
#ifdef wxUSE_WX_RESOURCES
wxFlushResources(); wxFlushResources();
wxDELETE(wxTheResourceCache); wxDELETE(wxTheResourceCache);
wxDeleteStockLists();
wxCleanUpResourceSystem(); wxCleanUpResourceSystem();
#endif
wxDeleteStockLists();
wxImage::CleanUpHandlers(); wxImage::CleanUpHandlers();

View File

@@ -180,7 +180,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
else else
{ {
/* the user pressed on the menu item -> report */ /* the user pressed on the menu item -> report */
item->m_isChecked; /* make consistent again */ item->m_isChecked = item->IsChecked(); /* make consistent again */
} }
} }

View File

@@ -68,13 +68,21 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
EVT_CHAR(wxTextCtrl::OnChar) EVT_CHAR(wxTextCtrl::OnChar)
END_EVENT_TABLE() END_EVENT_TABLE()
#ifndef NO_TEXT_WINDOW_STREAM
wxTextCtrl::wxTextCtrl() : streambuf() wxTextCtrl::wxTextCtrl() : streambuf()
{ {
if (allocate()) setp(base(),ebuf()); if (allocate()) setp(base(),ebuf());
m_modified = FALSE; m_modified = FALSE;
} }
#else
wxTextCtrl::wxTextCtrl()
{
m_modified = FALSE;
}
#endif
#ifndef NO_TEXT_WINDOW_STREAM
wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value, wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
int style, const wxValidator& validator, const wxString &name ) : streambuf() 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; m_modified = FALSE;
Create( parent, id, value, pos, size, style, validator, name ); 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, bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
@@ -621,6 +638,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
key_event.Skip(); key_event.Skip();
} }
#ifndef NO_TEXT_WINDOW_STREAM
int wxTextCtrl::overflow( int WXUNUSED(c) ) int wxTextCtrl::overflow( int WXUNUSED(c) )
{ {
int len = pptr() - pbase(); int len = pptr() - pbase();
@@ -697,6 +715,7 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
WriteText(buf); WriteText(buf);
return *this; return *this;
} }
#endif
GtkWidget* wxTextCtrl::GetConnectWidget() GtkWidget* wxTextCtrl::GetConnectWidget()
{ {