Fixed docview crash bug when On... functions return FALSE.

Fixed valgen.cpp to cope with strings in wxChoice/wxComboBox.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7639 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2000-06-24 08:05:21 +00:00
parent 1ac341e016
commit 7aed63fdb7
11 changed files with 727 additions and 668 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@@ -11,6 +11,9 @@ perfect because in this particular case it would be much better to just
\helpref{Wait()}{wxthreadwait} for the worker thread, but if there are several \helpref{Wait()}{wxthreadwait} for the worker thread, but if there are several
worker threads it already makes much more sense). worker threads it already makes much more sense).
Once the thread(s) are signaled, the condition then resets to the not
signaled state, ready to fire again.
\wxheading{Derived from} \wxheading{Derived from}
None. None.
@@ -51,18 +54,16 @@ Signals the object.
\membersection{wxCondition::Wait}\label{wxconditionwait} \membersection{wxCondition::Wait}\label{wxconditionwait}
\func{void}{Wait}{\param{wxMutex\&}{ mutex}} \func{void}{Wait}{\void}
Waits indefinitely. Waits indefinitely.
\func{bool}{Wait}{\param{wxMutex\&}{ mutex}, \param{unsigned long}{ sec}, \param{unsigned long}{ nsec}} \func{bool}{Wait}{\param{unsigned long}{ sec}, \param{unsigned long}{ nsec}}
Waits until a signal is raised or the timeout has elapsed. Waits until a signal is raised or the timeout has elapsed.
\wxheading{Parameters} \wxheading{Parameters}
\docparam{mutex}{wxMutex object.}
\docparam{sec}{Timeout in seconds} \docparam{sec}{Timeout in seconds}
\docparam{nsec}{Timeout nanoseconds component (added to {\it sec}).} \docparam{nsec}{Timeout nanoseconds component (added to {\it sec}).}

View File

@@ -246,11 +246,11 @@ void DoodleSegment::Draw(wxDC *dc)
} }
/* /*
* Implementation of drawing command * Implementation of drawing command
*/ */
DrawingCommand::DrawingCommand(const wxString& name, int command, DrawingDocument *ddoc, DoodleSegment *seg): DrawingCommand::DrawingCommand(const wxString& name, int command, DrawingDocument *ddoc, DoodleSegment *seg):
wxCommand(TRUE, name) wxCommand(TRUE, name)
{ {
doc = ddoc; doc = ddoc;
segment = seg; segment = seg;

View File

@@ -21,7 +21,7 @@
// Plots a line from one point to the other // Plots a line from one point to the other
class DoodleLine: public wxObject class DoodleLine: public wxObject
{ {
public: public:
wxInt32 x1; wxInt32 x1;
wxInt32 y1; wxInt32 y1;
wxInt32 x2; wxInt32 x2;
@@ -31,7 +31,7 @@ class DoodleLine: public wxObject
// Contains a list of lines: represents a mouse-down doodle // Contains a list of lines: represents a mouse-down doodle
class DoodleSegment: public wxObject class DoodleSegment: public wxObject
{ {
public: public:
wxList lines; wxList lines;
DoodleSegment(void); DoodleSegment(void);
@@ -52,8 +52,8 @@ class DoodleSegment: public wxObject
class DrawingDocument: public wxDocument class DrawingDocument: public wxDocument
{ {
DECLARE_DYNAMIC_CLASS(DrawingDocument) DECLARE_DYNAMIC_CLASS(DrawingDocument)
private: private:
public: public:
wxList doodleSegments; wxList doodleSegments;
DrawingDocument(void); DrawingDocument(void);
@@ -75,11 +75,11 @@ class DrawingDocument: public wxDocument
class DrawingCommand: public wxCommand class DrawingCommand: public wxCommand
{ {
protected: protected:
DoodleSegment *segment; DoodleSegment *segment;
DrawingDocument *doc; DrawingDocument *doc;
int cmd; int cmd;
public: public:
DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg); DrawingCommand(const wxString& name, int cmd, DrawingDocument *ddoc, DoodleSegment *seg);
~DrawingCommand(void); ~DrawingCommand(void);
@@ -90,12 +90,12 @@ class DrawingCommand: public wxCommand
class TextEditDocument: public wxDocument class TextEditDocument: public wxDocument
{ {
DECLARE_DYNAMIC_CLASS(TextEditDocument) DECLARE_DYNAMIC_CLASS(TextEditDocument)
private: private:
public: public:
/* /*
ostream& SaveObject(ostream& stream); ostream& SaveObject(ostream& stream);
istream& LoadObject(istream& stream); istream& LoadObject(istream& stream);
*/ */
virtual bool OnSaveDocument(const wxString& filename); virtual bool OnSaveDocument(const wxString& filename);
virtual bool OnOpenDocument(const wxString& filename); virtual bool OnOpenDocument(const wxString& filename);
virtual bool IsModified(void) const; virtual bool IsModified(void) const;

View File

@@ -14,10 +14,10 @@
#endif #endif
/* /*
* Purpose: Document/view architecture demo for wxWindows class library * Purpose: Document/view architecture demo for wxWindows class library
* Run with no arguments for multiple top-level windows, -single * Run with no arguments for multiple top-level windows, -single
* for a single window. * for a single window.
*/ */
// For compilers that support precompilation, includes "wx/wx.h". // For compilers that support precompilation, includes "wx/wx.h".
@@ -57,9 +57,9 @@ MyApp::MyApp(void)
bool MyApp::OnInit(void) bool MyApp::OnInit(void)
{ {
//// Find out if we're: //// Find out if we're:
//// SDI : multiple windows and documents but not MDI //// multiple window: multiple windows, each view in a separate frame
//// MDI : multiple windows and documents with containing frame - MSW only) //// single window: one view (within the main frame) and one document at a time, as in Windows Write.
/// single window : (one document at a time, only one frame, as in Windows Write) //// In single window mode, we only allow one document type
if (argc > 1) if (argc > 1)
{ {
if (wxStrcmp(argv[1], _T("-single")) == 0) if (wxStrcmp(argv[1], _T("-single")) == 0)
@@ -157,10 +157,10 @@ int MyApp::OnExit(void)
} }
/* /*
* Centralised code for creating a document frame. * Centralised code for creating a document frame.
* Called from view.cpp, when a view is created, but not used at all * Called from view.cpp, when a view is created, but not used at all
* in 'single window' mode. * in 'single window' mode.
*/ */
wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas) wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas)
{ {
@@ -221,8 +221,8 @@ wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas)
} }
/* /*
* This is the top-level window of the application. * This is the top-level window of the application.
*/ */
IMPLEMENT_CLASS(MyFrame, wxDocParentFrame) IMPLEMENT_CLASS(MyFrame, wxDocParentFrame)
BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame) BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame)
@@ -231,7 +231,7 @@ END_EVENT_TABLE()
MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, const long type): const wxPoint& pos, const wxSize& size, const long type):
wxDocParentFrame(manager, frame, id, title, pos, size, type) wxDocParentFrame(manager, frame, id, title, pos, size, type)
{ {
// This pointer only needed if in single window mode // This pointer only needed if in single window mode
canvas = (MyCanvas *) NULL; canvas = (MyCanvas *) NULL;

View File

@@ -23,14 +23,14 @@ class wxDocManager;
// Define a new application // Define a new application
class MyApp: public wxApp class MyApp: public wxApp
{ {
public: public:
MyApp(void); MyApp(void);
bool OnInit(void); bool OnInit(void);
int OnExit(void); int OnExit(void);
wxFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas); wxFrame *CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas);
protected: protected:
wxDocManager* m_docManager; wxDocManager* m_docManager;
}; };
@@ -41,7 +41,7 @@ class MyCanvas;
class MyFrame: public wxDocParentFrame class MyFrame: public wxDocParentFrame
{ {
DECLARE_CLASS(MyFrame) DECLARE_CLASS(MyFrame)
public: public:
wxMenu *editMenu; wxMenu *editMenu;
// This pointer only needed if in single window mode // This pointer only needed if in single window mode
@@ -53,7 +53,7 @@ class MyFrame: public wxDocParentFrame
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
MyCanvas *CreateCanvas(wxView *view, wxFrame *parent); MyCanvas *CreateCanvas(wxView *view, wxFrame *parent);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
extern MyFrame *GetMainFrame(void); extern MyFrame *GetMainFrame(void);

View File

@@ -202,8 +202,8 @@ bool TextEditView::OnClose(bool deleteWindow)
} }
/* /*
* Window implementations * Window implementations
*/ */
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent) EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent)

View File

@@ -20,19 +20,19 @@
class MyCanvas: public wxScrolledWindow class MyCanvas: public wxScrolledWindow
{ {
public: public:
wxView *view; wxView *view;
MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style); MyCanvas(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
virtual void OnDraw(wxDC& dc); virtual void OnDraw(wxDC& dc);
void OnMouseEvent(wxMouseEvent& event); void OnMouseEvent(wxMouseEvent& event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
class MyTextWindow: public wxTextCtrl class MyTextWindow: public wxTextCtrl
{ {
public: public:
wxView *view; wxView *view;
MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style); MyTextWindow(wxView *v, wxFrame *frame, const wxPoint& pos, const wxSize& size, const long style);
@@ -41,8 +41,8 @@ class MyTextWindow: public wxTextCtrl
class DrawingView: public wxView class DrawingView: public wxView
{ {
DECLARE_DYNAMIC_CLASS(DrawingView) DECLARE_DYNAMIC_CLASS(DrawingView)
private: private:
public: public:
wxFrame *frame; wxFrame *frame;
MyCanvas *canvas; MyCanvas *canvas;
@@ -56,14 +56,14 @@ class DrawingView: public wxView
void OnCut(wxCommandEvent& event); void OnCut(wxCommandEvent& event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
class TextEditView: public wxView class TextEditView: public wxView
{ {
DECLARE_DYNAMIC_CLASS(TextEditView) DECLARE_DYNAMIC_CLASS(TextEditView)
private: private:
public: public:
wxFrame *frame; wxFrame *frame;
MyTextWindow *textsw; MyTextWindow *textsw;

View File

@@ -172,6 +172,8 @@ bool wxDocument::OnCloseDocument()
// deleted. // deleted.
bool wxDocument::DeleteAllViews() bool wxDocument::DeleteAllViews()
{ {
wxDocManager* manager = GetDocumentManager();
wxNode *node = m_documentViews.First(); wxNode *node = m_documentViews.First();
while (node) while (node)
{ {
@@ -184,6 +186,11 @@ bool wxDocument::DeleteAllViews()
delete view; // Deletes node implicitly delete view; // Deletes node implicitly
node = next; node = next;
} }
// If we haven't yet deleted the document (for example
// if there were no views) then delete it.
if (manager->GetDocuments().Member(this))
delete this;
return TRUE; return TRUE;
} }
@@ -655,7 +662,8 @@ wxDocument *wxDocTemplate::CreateDocument(const wxString& path, long flags)
return doc; return doc;
else else
{ {
delete doc; if (GetDocumentManager()->GetDocuments().Member(doc))
doc->DeleteAllViews();
return (wxDocument *) NULL; return (wxDocument *) NULL;
} }
} }
@@ -1096,7 +1104,8 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
newDoc->SetDocumentTemplate(temp); newDoc->SetDocumentTemplate(temp);
if (!newDoc->OnOpenDocument(path2)) if (!newDoc->OnOpenDocument(path2))
{ {
delete newDoc; newDoc->DeleteAllViews();
// delete newDoc; // Implicitly deleted by DeleteAllViews
return (wxDocument *) NULL; return (wxDocument *) NULL;
} }
AddFileToHistory(path2); AddFileToHistory(path2);
@@ -1340,7 +1349,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
0, 0,
wxTheApp->GetTopWindow()); wxTheApp->GetTopWindow());
if (!pathTmp.IsEmpty()) if (!pathTmp.IsEmpty() && wxFileExists(pathTmp))
{ {
m_lastDirectory = wxPathOnly(pathTmp); m_lastDirectory = wxPathOnly(pathTmp);

View File

@@ -219,8 +219,33 @@ bool wxGenericValidator::TransferToWindow(void)
pControl->SetSelection(*m_pInt) ; pControl->SetSelection(*m_pInt) ;
return TRUE; return TRUE;
} }
else if (m_pString)
{
if (pControl->FindString(* m_pString) > -1)
{
pControl->SetStringSelection(* m_pString);
}
return TRUE;
}
} else } else
#endif #endif
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
{
wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
if (m_pInt)
{
pControl->SetSelection(*m_pInt) ;
return TRUE;
}
else if (m_pString)
{
if (pControl->FindString(* m_pString) > -1)
{
pControl->SetStringSelection(* m_pString);
}
return TRUE;
}
} else
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
{ {
wxStaticText* pControl = (wxStaticText*) m_validatorWindow; wxStaticText* pControl = (wxStaticText*) m_validatorWindow;
@@ -395,6 +420,11 @@ bool wxGenericValidator::TransferFromWindow(void)
*m_pString = pControl->GetValue() ; *m_pString = pControl->GetValue() ;
return TRUE; return TRUE;
} }
else if (m_pString)
{
*m_pString = pControl->GetStringSelection();
return TRUE;
}
} else } else
#endif #endif
#if wxUSE_CHOICE #if wxUSE_CHOICE
@@ -406,8 +436,27 @@ bool wxGenericValidator::TransferFromWindow(void)
*m_pInt = pControl->GetSelection() ; *m_pInt = pControl->GetSelection() ;
return TRUE; return TRUE;
} }
else if (m_pString)
{
*m_pString = pControl->GetStringSelection();
return TRUE;
}
} else } else
#endif #endif
if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) )
{
wxComboBox* pControl = (wxComboBox*) m_validatorWindow;
if (m_pInt)
{
*m_pInt = pControl->GetSelection() ;
return TRUE;
}
else if (m_pString)
{
*m_pString = pControl->SetStringSelection(* m_pString);
return TRUE;
}
} else
if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) ) if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) )
{ {
wxStaticText* pControl = (wxStaticText*) m_validatorWindow; wxStaticText* pControl = (wxStaticText*) m_validatorWindow;