Move bug reporting to COMMON_CONTROL; add to Help menu

Also make a shorter version of the version info string
and some other shortening edits to the issue template
to fix occasional 500 errors thrown by Cloudflare due
to excessively long URLs

Fixes https://gitlab.com/kicad/code/kicad/-/issues/3953
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4272
This commit is contained in:
Jon Evans 2020-05-24 20:39:15 -04:00
parent c6a6c071cf
commit 695cdbbde8
9 changed files with 271 additions and 240 deletions

View File

@ -24,6 +24,19 @@
// Date for KiCad build version
#include <fctsys.h>
#include <boost/version.hpp>
// kicad_curl.h must be included before wx headers, to avoid
// conflicts for some defines, at least on Windows
// kicad_curl.h can create conflicts for some defines, at least on Windows
// so we are using here 2 proxy functions to know Curl version to avoid
// including kicad_curl.h to know Curl version
extern std::string GetKicadCurlVersion();
extern std::string GetCurlLibVersion();
#if defined( KICAD_USE_OCC ) | defined( KICAD_USE_OCE )
#include <Standard_Version.hxx>
#endif
// The include file version.h is always created even if the repo version cannot be
// determined. In this case KICAD_VERSION_FULL will default to the KICAD_VERSION
@ -57,3 +70,188 @@ wxString GetMajorMinorVersion()
wxString msg = wxString::Format( wxT( "%s" ), wxT( KICAD_MAJOR_MINOR_VERSION ) );
return msg;
}
wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
{
wxString aMsg;
// DO NOT translate information in the msg_version string
wxString eol = aHtml ? "<br>" : "\n";
// Tabs instead of spaces for the plaintext version for shorter string length
wxString indent4 = aHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t";
#define ON "ON" << eol
#define OFF "OFF" << eol
wxString version;
version << GetBuildVersion()
#ifdef DEBUG
<< ", debug"
#else
<< ", release"
#endif
<< " build";
wxPlatformInfo platform;
aMsg << "Application: " << aTitle << eol;
aMsg << "Version: " << version << eol;
aMsg << "Libraries:" << eol;
aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
if( !aBrief )
aMsg << indent4 << GetKicadCurlVersion() << eol;
aMsg << "Platform: " << wxGetOsDescription() << ", "
<< platform.GetArchName() << ", "
<< platform.GetEndiannessName() << ", "
<< platform.GetPortIdName() << eol;
if( !aBrief )
aMsg << "Build Info:" << eol;
if( !aBrief )
aMsg << indent4 << "Build date: " << GetBuildDate() << eol;
aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
aMsg << __WX_BO_UNICODE __WX_BO_STL __WX_BO_WXWIN_COMPAT_2_8 ")";
// Get the GTK+ version where possible.
#ifdef __WXGTK__
int major, minor;
major = wxPlatformInfo().Get().GetToolkitMajorVersion();
minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
aMsg << " GTK+ " << major << "." << minor;
#endif
aMsg << eol;
aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
<< ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
<< ( BOOST_VERSION % 100 ) << eol;
#ifdef KICAD_USE_OCC
aMsg << indent4 << "OCC: " << OCC_VERSION_COMPLETE << eol;
#endif
#ifdef KICAD_USE_OCE
aMsg << indent4 << "OCE: " << OCC_VERSION_COMPLETE << eol;
#endif
aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
aMsg << indent4 << "Compiler: ";
#if defined(__clang__)
aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
#elif defined(__GNUG__)
aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
#elif defined(_MSC_VER)
aMsg << "Visual C++ " << _MSC_VER;
#elif defined(__INTEL_COMPILER)
aMsg << "Intel C++ " << __INTEL_COMPILER;
#else
aMsg << "Other Compiler ";
#endif
#if defined(__GXX_ABI_VERSION)
aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
#else
aMsg << " without C++ ABI";
#endif
aMsg << eol;
// Add build settings config (build options):
aMsg << "Build settings:" << eol;
aMsg << indent4 << "KICAD_SCRIPTING=";
#ifdef KICAD_SCRIPTING
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_MODULES=";
#ifdef KICAD_SCRIPTING_MODULES
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_PYTHON3=";
#ifdef KICAD_SCRIPTING_PYTHON3
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_WXPYTHON=";
#ifdef KICAD_SCRIPTING_WXPYTHON
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_WXPYTHON_PHOENIX=";
#ifdef KICAD_SCRIPTING_WXPYTHON_PHOENIX
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_ACTION_MENU=";
#ifdef KICAD_SCRIPTING_ACTION_MENU
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "BUILD_GITHUB_PLUGIN=";
#ifdef BUILD_GITHUB_PLUGIN
aMsg << ON;
#else
aMsg << OFF;
#endif
#ifdef KICAD_USE_OCE
aMsg << indent4 << "KICAD_USE_OCE=" << ON;
#endif
#ifdef KICAD_USE_OCC
aMsg << indent4 << "KICAD_USE_OCC=" << ON;
#endif
aMsg << indent4 << "KICAD_SPICE=";
#ifdef KICAD_SPICE
aMsg << ON;
#else
aMsg << OFF;
#endif
#ifndef NDEBUG
aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
#ifdef KICAD_STDLIB_DEBUG
aMsg << ON;
#else
aMsg << OFF;
aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
#ifdef KICAD_STDLIB_LIGHT_DEBUG
aMsg << ON;
#else
aMsg << OFF;
#endif
#endif
aMsg << indent4 << "KICAD_SANITIZE=";
#ifdef KICAD_SANITIZE
aMsg << ON;
#else
aMsg << OFF;
#endif
#endif
return aMsg;
}

View File

@ -24,23 +24,8 @@
#include <config.h>
#include <kicad_curl/kicad_curl_easy.h>
#include <launch_ext.h>
#include <string>
// kicad_curl.h must be included before wx headers, to avoid
// conflicts for some defines, at least on Windows
// kicad_curl.h can create conflicts for some defines, at least on Windows
// so we are using here 2 proxy functions to know Curl version to avoid
// including kicad_curl.h to know Curl version
extern std::string GetKicadCurlVersion();
extern std::string GetCurlLibVersion();
#if defined( KICAD_USE_OCC ) | defined( KICAD_USE_OCE )
#include <Standard_Version.hxx>
#endif
#include <boost/version.hpp>
#include <wx/clipbrd.h>
#include <wx/msgdlg.h>
#include <wx/hyperlink.h>
@ -58,39 +43,11 @@ extern std::string GetCurlLibVersion();
#include <bitmaps.h>
#include <build_version.h>
#include <html_messagebox.h>
#include <tool/tool_manager.h>
#include "dialog_about.h"
/// URL to launch a new issue with pre-populated description
wxString DIALOG_ABOUT::m_bugReportUrl =
"https://gitlab.com/kicad/code/kicad/issues/new?issue[description]=%s";
/// Issue template to use for reporting bugs (this should not be translated)
wxString DIALOG_ABOUT::m_bugReportTemplate =
"<!-- --------Before Creating a New Issue-----------\n"
"* Search the issue tracker to verify the issue has not already been reported.\n"
"* Keep report contents limited to the necessary information required to fix the issue.\n"
"\n"
"---------Add your issue details below----------- -->\n"
"\n"
"# Description\n"
"<!-- What is the current behavior and what is the expected behavior? -->\n"
"<!-- If the issue is visual/graphical, please attach screenshots of the problem. -->\n"
"\n"
"# Steps to reproduce\n"
"<!-- If there are multiple steps to reproduce it or it is a visual issue, then providing a"
"screen recording as an attachment to this report is recommended. -->\n"
"<!-- If this issue is specific to a project, please attach it to this issue. -->\n"
"1.\n"
"1.\n"
"# KiCad Version\n"
"\n"
"```\n"
"%s\n"
"```";
DIALOG_ABOUT::DIALOG_ABOUT( EDA_BASE_FRAME *aParent, ABOUT_APP_INFO& aAppInfo )
: DIALOG_ABOUT_BASE( aParent ), m_info( aAppInfo )
{
@ -155,8 +112,7 @@ void DIALOG_ABOUT::createNotebooks()
createNotebookHtmlPage( m_auiNotebook, _( "About" ), m_picInformation,
m_info.GetDescription() );
wxString version;
buildVersionInfoData( version, true );
wxString version = GetVersionInfoData( m_titleName, true );
createNotebookHtmlPage( m_auiNotebook, _( "Version" ), m_picVersion, version, true );
@ -475,177 +431,6 @@ void DIALOG_ABOUT::onHtmlLinkClicked( wxHtmlLinkEvent& event )
}
void DIALOG_ABOUT::buildVersionInfoData( wxString& aMsg, bool aFormatHtml )
{
// DO NOT translate information in the msg_version string
wxString eol = aFormatHtml ? "<br>" : "\n";
wxString indent4 = aFormatHtml ? "&nbsp;&nbsp;&nbsp;&nbsp;" : " ";
#define ON "ON" << eol
#define OFF "OFF" << eol
wxPlatformInfo platform;
aMsg << "Application: " << m_titleName << eol;
aMsg << "Version: " << m_info.GetBuildVersion() << eol;
aMsg << "Libraries:" << eol;
aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
aMsg << indent4 << GetKicadCurlVersion() << eol;
aMsg << "Platform: " << wxGetOsDescription() << ", "
<< platform.GetArchName() << ", "
<< platform.GetEndiannessName() << ", "
<< platform.GetPortIdName() << eol;
aMsg << "Build Info:" << eol;
aMsg << indent4 << "Build date: " << m_info.GetBuildDate() << eol;
aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " (";
aMsg << __WX_BO_UNICODE __WX_BO_STL __WX_BO_WXWIN_COMPAT_2_8 ")";
// Get the GTK+ version where possible.
#ifdef __WXGTK__
int major, minor;
major = wxPlatformInfo().Get().GetToolkitMajorVersion();
minor = wxPlatformInfo().Get().GetToolkitMinorVersion();
aMsg << " GTK+ " << major << "." << minor;
#endif
aMsg << eol;
aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." )
<< ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
<< ( BOOST_VERSION % 100 ) << eol;
#ifdef KICAD_USE_OCC
aMsg << indent4 << "OpenCASCADE Technology: " << OCC_VERSION_COMPLETE << eol;
#endif
#ifdef KICAD_USE_OCE
aMsg << indent4 << "OpenCASCADE Community Edition: " << OCC_VERSION_COMPLETE << eol;
#endif
aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol;
aMsg << indent4 << "Compiler: ";
#if defined(__clang__)
aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__;
#elif defined(__GNUG__)
aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__;
#elif defined(_MSC_VER)
aMsg << "Visual C++ " << _MSC_VER;
#elif defined(__INTEL_COMPILER)
aMsg << "Intel C++ " << __INTEL_COMPILER;
#else
aMsg << "Other Compiler ";
#endif
#if defined(__GXX_ABI_VERSION)
aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol;
#else
aMsg << " without C++ ABI";
#endif
aMsg << eol;
// Add build settings config (build options):
aMsg << "Build settings:" << eol;
aMsg << indent4 << "KICAD_SCRIPTING=";
#ifdef KICAD_SCRIPTING
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_MODULES=";
#ifdef KICAD_SCRIPTING_MODULES
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_PYTHON3=";
#ifdef KICAD_SCRIPTING_PYTHON3
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_WXPYTHON=";
#ifdef KICAD_SCRIPTING_WXPYTHON
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_WXPYTHON_PHOENIX=";
#ifdef KICAD_SCRIPTING_WXPYTHON_PHOENIX
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SCRIPTING_ACTION_MENU=";
#ifdef KICAD_SCRIPTING_ACTION_MENU
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "BUILD_GITHUB_PLUGIN=";
#ifdef BUILD_GITHUB_PLUGIN
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_USE_OCE=";
#ifdef KICAD_USE_OCE
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_USE_OCC=";
#ifdef KICAD_USE_OCC
aMsg << ON;
#else
aMsg << OFF;
#endif
aMsg << indent4 << "KICAD_SPICE=";
#ifdef KICAD_SPICE
aMsg << ON;
#else
aMsg << OFF;
#endif
#ifndef NDEBUG
aMsg << indent4 << "KICAD_STDLIB_DEBUG=";
#ifdef KICAD_STDLIB_DEBUG
aMsg << ON;
#else
aMsg << OFF;
aMsg << indent4 << "KICAD_STDLIB_LIGHT_DEBUG=";
#ifdef KICAD_STDLIB_LIGHT_DEBUG
aMsg << ON;
#else
aMsg << OFF;
#endif
#endif
aMsg << indent4 << "KICAD_SANITIZE=";
#ifdef KICAD_SANITIZE
aMsg << ON;
#else
aMsg << OFF;
#endif
#endif
}
void DIALOG_ABOUT::onCopyVersionInfo( wxCommandEvent& event )
{
if( !wxTheClipboard->Open() )
@ -655,8 +440,7 @@ void DIALOG_ABOUT::onCopyVersionInfo( wxCommandEvent& event )
return;
}
wxString msg_version;
buildVersionInfoData( msg_version, false );
wxString msg_version = GetVersionInfoData( m_titleName );
wxTheClipboard->SetData( new wxTextDataObject( msg_version ) );
wxTheClipboard->Close();
@ -666,15 +450,6 @@ void DIALOG_ABOUT::onCopyVersionInfo( wxCommandEvent& event )
void DIALOG_ABOUT::onReportBug( wxCommandEvent& event )
{
wxString version;
buildVersionInfoData( version, false );
wxString message;
message.Printf( m_bugReportTemplate, version );
KICAD_CURL_EASY kcurl;
wxString url_string;
url_string.Printf( m_bugReportUrl, kcurl.Escape( message.ToStdString() ) );
LaunchURL( url_string );
if( TOOL_MANAGER* mgr = static_cast<EDA_BASE_FRAME*>( GetParent() )->GetToolManager() )
mgr->RunAction( "common.SuiteControl.reportBug", true );
}

View File

@ -54,9 +54,6 @@ private:
ABOUT_APP_INFO& m_info;
static wxString m_bugReportUrl;
static wxString m_bugReportTemplate;
public:
DIALOG_ABOUT( EDA_BASE_FRAME* aParent, ABOUT_APP_INFO& aAppInfo );
~DIALOG_ABOUT();
@ -64,13 +61,6 @@ public:
private:
void initDialog();
/** build the version info message
* @param aMsg is the result
* @param aFormatHtml = true to use a minimal HTML format
* false to use a plain text
*/
void buildVersionInfoData( wxString& aMsg, bool aFormatHtml );
void onHtmlLinkClicked( wxHtmlLinkEvent& event );
void onCopyVersionInfo( wxCommandEvent& event ) override;

View File

@ -302,6 +302,7 @@ void EDA_BASE_FRAME::AddStandardHelpMenu( wxMenuBar* aMenuBar )
helpMenu->Add( ACTIONS::gettingStarted );
helpMenu->Add( ACTIONS::listHotKeys );
helpMenu->Add( ACTIONS::getInvolved );
helpMenu->Add( ACTIONS::reportBug );
helpMenu->AppendSeparator();
helpMenu->Add( _( "&About KiCad" ), "", wxID_ABOUT, about_xpm );

View File

@ -605,6 +605,12 @@ TOOL_ACTION ACTIONS::getInvolved( "common.SuiteControl.getInvolved",
_( "Open \"Contribute to KiCad\" in a web browser" ),
info_xpm );
TOOL_ACTION ACTIONS::reportBug( "common.SuiteControl.reportBug",
AS_GLOBAL, 0, "",
_( "Report Bug" ),
_( "Report a problem with KiCad" ),
drc_xpm );
// System-wide selection Events

View File

@ -23,6 +23,7 @@
*/
#include <bitmaps.h>
#include <build_version.h>
#include <tool/actions.h>
#include <tool/tool_manager.h>
#include <eda_draw_frame.h>
@ -35,12 +36,39 @@
#include <id.h>
#include <project.h>
#include <kiface_i.h>
#include <kicad_curl/kicad_curl_easy.h>
#include <dialog_configure_paths.h>
#include <eda_doc.h>
#define URL_GET_INVOLVED "http://kicad-pcb.org/contribute/"
/// URL to launch a new issue with pre-populated description
wxString COMMON_CONTROL::m_bugReportUrl =
"https://gitlab.com/kicad/code/kicad/issues/new?issue[description]=%s";
/// Issue template to use for reporting bugs (this should not be translated)
wxString COMMON_CONTROL::m_bugReportTemplate =
"<!-- Before Creating a New Issue:\n"
"* Search the issue tracker to verify the issue has not already been reported.\n"
"* Only report one problem per issue. -->\n"
"\n"
"# Description\n"
"<!-- What is the current behavior and what is the expected behavior? -->\n"
"<!-- Please attach screenshots if they will help explain the problem. -->\n"
"\n"
"# Steps to reproduce\n"
"<!-- Please include a screen recording if it will help explain how to reproduce. -->\n"
"<!-- If this issue is specific to a project, please attach it. -->\n"
"1.\n"
"2.\n"
"# KiCad Version\n"
"\n"
"```\n"
"%s\n"
"```";
void COMMON_CONTROL::Reset( RESET_REASON aReason )
{
m_frame = getEditFrame<EDA_BASE_FRAME>();
@ -197,6 +225,23 @@ int COMMON_CONTROL::GetInvolved( const TOOL_EVENT& aEvent )
}
int COMMON_CONTROL::ReportBug( const TOOL_EVENT& aEvent )
{
wxString version = GetVersionInfoData( m_frame->GetAboutTitle(), false, true );
wxString message;
message.Printf( m_bugReportTemplate, version );
KICAD_CURL_EASY kcurl;
wxString url_string;
url_string.Printf( m_bugReportUrl, kcurl.Escape( message.ToStdString() ) );
wxLaunchDefaultBrowser( url_string );
return 0;
}
void COMMON_CONTROL::setTransitions()
{
Go( &COMMON_CONTROL::ConfigurePaths, ACTIONS::configurePaths.MakeEvent() );
@ -211,6 +256,7 @@ void COMMON_CONTROL::setTransitions()
Go( &COMMON_CONTROL::ShowHelp, ACTIONS::help.MakeEvent() );
Go( &COMMON_CONTROL::ListHotKeys, ACTIONS::listHotKeys.MakeEvent() );
Go( &COMMON_CONTROL::GetInvolved, ACTIONS::getInvolved.MakeEvent() );
Go( &COMMON_CONTROL::ReportBug, ACTIONS::reportBug.MakeEvent() );
}

View File

@ -61,4 +61,14 @@ wxString GetMajorMinorVersion();
*/
wxString GetBuildDate();
/**
* Create a version info string for bug reports and the about dialog
* @param aTitle is the application title to include at the top of the report
* @param aBrief = true to condense information for the bug report URL
* @param aHtml = true to use a minimal HTML format, false for plan text
* @return the version info string
*/
wxString GetVersionInfoData( const wxString& aTitle, bool aHtml = false, bool aBrief = false );
#endif // KICAD_BUILD_VERSION_H

View File

@ -170,6 +170,7 @@ public:
static TOOL_ACTION help;
static TOOL_ACTION listHotKeys;
static TOOL_ACTION getInvolved;
static TOOL_ACTION reportBug;
/**
* Function TranslateLegacyId()

View File

@ -55,6 +55,7 @@ public:
int ShowHelp( const TOOL_EVENT& aEvent );
int ListHotKeys( const TOOL_EVENT& aEvent );
int GetInvolved( const TOOL_EVENT& aEvent );
int ReportBug( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions() override;
@ -62,6 +63,9 @@ public:
private:
///> Pointer to the currently used edit frame.
EDA_BASE_FRAME* m_frame;
static wxString m_bugReportUrl;
static wxString m_bugReportTemplate;
};
#endif