Show correct save path when using compressed debug report
The compressed report location could be set to a different location from the one shown in the dialog. Closes #17176. Closes https://github.com/wxWidgets/wxWidgets/pull/797
This commit is contained in:
committed by
Vadim Zeitlin
parent
390c45d1d9
commit
59c37cb5eb
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/arrstr.h"
|
#include "wx/arrstr.h"
|
||||||
|
#include "wx/filename.h"
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_XML wxXmlNode;
|
class WXDLLIMPEXP_FWD_XML wxXmlNode;
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ class WXDLLIMPEXP_FWD_XML wxXmlNode;
|
|||||||
|
|
||||||
class WXDLLIMPEXP_QA wxDebugReport
|
class WXDLLIMPEXP_QA wxDebugReport
|
||||||
{
|
{
|
||||||
|
friend class wxDebugReportDialog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// this is used for the functions which may report either the current state
|
// this is used for the functions which may report either the current state
|
||||||
// or the state during the last (fatal) exception
|
// or the state during the last (fatal) exception
|
||||||
@@ -113,6 +116,9 @@ protected:
|
|||||||
// used by Process()
|
// used by Process()
|
||||||
virtual bool DoProcess();
|
virtual bool DoProcess();
|
||||||
|
|
||||||
|
// return the location where the report will be saved
|
||||||
|
virtual wxFileName GetSaveLocation() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// name of the report directory
|
// name of the report directory
|
||||||
wxString m_dir;
|
wxString m_dir;
|
||||||
@@ -148,6 +154,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual bool DoProcess() wxOVERRIDE;
|
virtual bool DoProcess() wxOVERRIDE;
|
||||||
|
|
||||||
|
// return the location where the report will be saved
|
||||||
|
wxFileName GetSaveLocation() const wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// user-specified file directory/base name, use defaults if empty
|
// user-specified file directory/base name, use defaults if empty
|
||||||
wxString m_zipDir,
|
wxString m_zipDir,
|
||||||
|
@@ -594,6 +594,13 @@ bool wxDebugReport::DoProcess()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFileName wxDebugReport::GetSaveLocation() const
|
||||||
|
{
|
||||||
|
wxFileName fn;
|
||||||
|
fn.SetPath(GetDirectory());
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxDebugReport-derived classes
|
// wxDebugReport-derived classes
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -618,6 +625,19 @@ void wxDebugReportCompress::SetCompressedFileBaseName(const wxString& name)
|
|||||||
m_zipName = name;
|
m_zipName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxFileName wxDebugReportCompress::GetSaveLocation() const
|
||||||
|
{
|
||||||
|
// Use de default directoy as a basis for the save location, e.g.
|
||||||
|
// %temp%/someName becomes %temp%/someName.zip.
|
||||||
|
wxFileName fn(GetDirectory());
|
||||||
|
if (!m_zipDir.empty())
|
||||||
|
fn.SetPath(m_zipDir);
|
||||||
|
if (!m_zipName.empty())
|
||||||
|
fn.SetName(m_zipName);
|
||||||
|
fn.SetExt("zip");
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxDebugReportCompress::DoProcess()
|
bool wxDebugReportCompress::DoProcess()
|
||||||
{
|
{
|
||||||
#define HAS_FILE_STREAMS (wxUSE_STREAMS && (wxUSE_FILE || wxUSE_FFILE))
|
#define HAS_FILE_STREAMS (wxUSE_STREAMS && (wxUSE_FILE || wxUSE_FFILE))
|
||||||
@@ -626,19 +646,8 @@ bool wxDebugReportCompress::DoProcess()
|
|||||||
if ( !count )
|
if ( !count )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// create the compressed report file outside of the directory with the
|
|
||||||
// report files as it will be deleted by wxDebugReport dtor but we want to
|
|
||||||
// keep this one: for this we simply treat the directory name as the name
|
|
||||||
// of the file so that its last component becomes our base name
|
|
||||||
wxFileName fn(GetDirectory());
|
|
||||||
if ( !m_zipDir.empty() )
|
|
||||||
fn.SetPath(m_zipDir);
|
|
||||||
if ( !m_zipName.empty() )
|
|
||||||
fn.SetName(m_zipName);
|
|
||||||
fn.SetExt("zip");
|
|
||||||
|
|
||||||
// create the streams
|
// create the streams
|
||||||
const wxString ofullPath = fn.GetFullPath();
|
const wxString ofullPath = GetSaveLocation().GetFullPath();
|
||||||
#if wxUSE_FFILE
|
#if wxUSE_FFILE
|
||||||
wxFFileOutputStream os(ofullPath, wxT("wb"));
|
wxFFileOutputStream os(ofullPath, wxT("wb"));
|
||||||
#elif wxUSE_FILE
|
#elif wxUSE_FILE
|
||||||
|
@@ -306,16 +306,15 @@ wxDebugReportDialog::wxDebugReportDialog(wxDebugReport& dbgrpt)
|
|||||||
{
|
{
|
||||||
// upper part of the dialog: explanatory message
|
// upper part of the dialog: explanatory message
|
||||||
wxString msg;
|
wxString msg;
|
||||||
wxString debugDir = dbgrpt.GetDirectory();
|
|
||||||
|
|
||||||
// The temporary directory can be the short form on Windows;
|
// The temporary directory can be the short form on Windows;
|
||||||
// normalize it for the benefit of users.
|
// normalize it for the benefit of users.
|
||||||
#ifdef __WXMSW__
|
wxFileName debugDirFilename(dbgrpt.GetSaveLocation());
|
||||||
wxFileName debugDirFilename(debugDir, wxEmptyString);
|
|
||||||
debugDirFilename.Normalize(wxPATH_NORM_LONG);
|
debugDirFilename.Normalize(wxPATH_NORM_LONG);
|
||||||
debugDir = debugDirFilename.GetPath();
|
wxString debugDir = debugDirFilename.GetFullPath();
|
||||||
#endif
|
msg << (debugDirFilename.IsDir()
|
||||||
msg << _("A debug report has been generated in the directory\n")
|
? _("A debug report has been generated in the directory\n")
|
||||||
|
: _("The following debug report will be generated\n"))
|
||||||
<< wxT('\n')
|
<< wxT('\n')
|
||||||
<< wxT(" \"") << debugDir << wxT("\"\n")
|
<< wxT(" \"") << debugDir << wxT("\"\n")
|
||||||
<< wxT('\n')
|
<< wxT('\n')
|
||||||
|
Reference in New Issue
Block a user