]> git.saurik.com Git - wxWidgets.git/commitdiff
added AddText() function (trivial wrapper around AddFile()), use it in debug rpt...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Apr 2005 16:04:22 +0000 (16:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Apr 2005 16:04:22 +0000 (16:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33452 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/debugrpt.h
src/common/debugrpt.cpp
src/generic/dbgrptg.cpp

index 92bb2287ee41b7de169df69c66b7ce97ecf16c79..0ea56424fffd8f2379bdc031594b3d509c115024 100644 (file)
@@ -54,6 +54,13 @@ public:
     // description is shown to the user in the report summary
     virtual void AddFile(const wxString& name, const wxString& description);
 
+    // convenience function: write the given text to a file with the given name
+    // and then add it to the report (the difference with AddFile() is that the
+    // file will be created by this function and doesn't have to already exist)
+    bool AddText(const wxString& name,
+                 const wxString& text,
+                 const wxString& description);
+
 #if wxUSE_STACKWALKER
     // add an XML file containing the current or exception context and the
     // stack trace
index bec66764237bdf388514570e2f21af96694d879e..194b33788b02206f07f3a1d5bfde9ef7fe957cff 100644 (file)
@@ -258,6 +258,21 @@ void wxDebugReport::AddFile(const wxString& name, const wxString& description)
     m_descriptions.Add(description);
 }
 
+bool
+wxDebugReport::AddText(const wxString& name,
+                       const wxString& text,
+                       const wxString& description)
+{
+    wxFileName fn(GetDirectory(), name);
+    wxFFile file(fn.GetFullPath(), _T("w"));
+    if ( !file.IsOpened() || !file.Write(text) )
+        return false;
+
+    AddFile(name, description);
+
+    return true;
+}
+
 void wxDebugReport::RemoveFile(const wxString& name)
 {
     const int n = m_files.Index(name);
index 31df1b85b59c6715e4128d7a2ff8f5cef5a5ee8f..c749600074c1bed7ed48927d531fceabd0a4903c 100644 (file)
@@ -389,14 +389,8 @@ bool wxDebugReportDialog::TransferDataFromWindow()
     const wxString notes = m_notes->GetValue();
     if ( !notes.empty() )
     {
-        // for now it's fixed, could make it configurable in the future...
-        const wxChar *NOTES_FILE_NAME = _T("notes.txt");
-        wxFileName fn(m_dbgrpt.GetDirectory(), NOTES_FILE_NAME);
-        wxFFile file(fn.GetFullPath(), _T("w"));
-        if ( file.IsOpened() && file.Write(notes) )
-        {
-            m_dbgrpt.AddFile(NOTES_FILE_NAME, _T("user notes"));
-        }
+        // for now filename fixed, could make it configurable in the future...
+        m_dbgrpt.AddText(_T("notes.txt"), notes, _T("user notes"));
     }
 
     return true;