From 695cdbbde85e9e3af74638d3f23fdb25063d35ca Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 24 May 2020 20:39:15 -0400 Subject: [PATCH] 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 --- common/build_version.cpp | 198 ++++++++++++++++++++++ common/dialog_about/dialog_about.cpp | 235 +-------------------------- common/dialog_about/dialog_about.h | 10 -- common/eda_base_frame.cpp | 1 + common/tool/actions.cpp | 6 + common/tool/common_control.cpp | 46 ++++++ include/build_version.h | 10 ++ include/tool/actions.h | 1 + include/tool/common_control.h | 4 + 9 files changed, 271 insertions(+), 240 deletions(-) diff --git a/common/build_version.cpp b/common/build_version.cpp index 954dc4118f..95916b01df 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -24,6 +24,19 @@ // Date for KiCad build version #include +#include + +// 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 +#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 ? "
" : "\n"; + + // Tabs instead of spaces for the plaintext version for shorter string length + wxString indent4 = aHtml ? "    " : "\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; +} \ No newline at end of file diff --git a/common/dialog_about/dialog_about.cpp b/common/dialog_about/dialog_about.cpp index ed9e394a23..525d67a162 100644 --- a/common/dialog_about/dialog_about.cpp +++ b/common/dialog_about/dialog_about.cpp @@ -24,23 +24,8 @@ #include -#include -#include #include -// 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 -#endif - -#include #include #include #include @@ -58,39 +43,11 @@ extern std::string GetCurlLibVersion(); #include #include #include +#include #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 = - "\n" - "\n" - "# Description\n" - "\n" - "\n" - "\n" - "# Steps to reproduce\n" - "\n" - "\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 ? "
" : "\n"; - wxString indent4 = aFormatHtml ? "    " : " "; - - #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( GetParent() )->GetToolManager() ) + mgr->RunAction( "common.SuiteControl.reportBug", true ); } diff --git a/common/dialog_about/dialog_about.h b/common/dialog_about/dialog_about.h index 267de914e5..d6a0df12cb 100644 --- a/common/dialog_about/dialog_about.h +++ b/common/dialog_about/dialog_about.h @@ -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; diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 807c6faaa2..68931fcbc1 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -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 ); diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index 8ef7e97c2e..a4779c172c 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -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 diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index 62085c7e3f..b687b79ec1 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -35,12 +36,39 @@ #include #include #include +#include #include #include #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 = + "\n" + "\n" + "# Description\n" + "\n" + "\n" + "\n" + "# Steps to reproduce\n" + "\n" + "\n" + "1.\n" + "2.\n" + "# KiCad Version\n" + "\n" + "```\n" + "%s\n" + "```"; + + void COMMON_CONTROL::Reset( RESET_REASON aReason ) { m_frame = getEditFrame(); @@ -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() ); } diff --git a/include/build_version.h b/include/build_version.h index 1481deef5d..0daeb44389 100644 --- a/include/build_version.h +++ b/include/build_version.h @@ -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 diff --git a/include/tool/actions.h b/include/tool/actions.h index 12410f1ce5..d287fc7b9d 100644 --- a/include/tool/actions.h +++ b/include/tool/actions.h @@ -170,6 +170,7 @@ public: static TOOL_ACTION help; static TOOL_ACTION listHotKeys; static TOOL_ACTION getInvolved; + static TOOL_ACTION reportBug; /** * Function TranslateLegacyId() diff --git a/include/tool/common_control.h b/include/tool/common_control.h index 59e87bc61b..b1e82bcf28 100644 --- a/include/tool/common_control.h +++ b/include/tool/common_control.h @@ -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