From 053bd6665065150df5716c2d05bd7403924b83fd Mon Sep 17 00:00:00 2001 From: david-beinder Date: Wed, 9 Jun 2021 03:02:10 +0200 Subject: [PATCH] Fix localization of OS unsupported message, disallow bug reports from W7 --- common/build_version.cpp | 4 +++- common/common.cpp | 19 ++++++++++++++++++ common/dialog_about/AboutDialog_main.cpp | 4 +++- common/pgm_base.cpp | 4 ++++ common/tool/common_control.cpp | 3 +++ include/common.h | 8 ++++++++ libs/kiplatform/gtk/app.cpp | 7 +++++++ libs/kiplatform/include/kiplatform/app.h | 8 ++++++++ libs/kiplatform/msw/app.cpp | 25 ++++++++++++------------ libs/kiplatform/osx/app.mm | 7 +++++++ 10 files changed, 75 insertions(+), 14 deletions(-) diff --git a/common/build_version.cpp b/common/build_version.cpp index 9d0af51637..e8c3128d2e 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -26,6 +26,7 @@ #include #include #include +#include // kicad_curl.h must be included before wx headers, to avoid // conflicts for some defines, at least on Windows @@ -87,7 +88,8 @@ wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief ) #define OFF "OFF" << eol wxString version; - version << GetBuildVersion() + version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? "(UNSUPPORTED)" + : GetBuildVersion() ) #ifdef DEBUG << ", debug" #else diff --git a/common/common.cpp b/common/common.cpp index 62e4d23ff3..1f4526d71a 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -24,6 +24,7 @@ */ #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -604,3 +606,20 @@ long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec ) return timestamp; } + +bool WarnUserIfOperatingSystemUnsupported() +{ + if( !KIPLATFORM::APP::IsOperatingSystemUnsupported() ) + return false; + + wxMessageDialog dialog( NULL, _( "This operating system is not supported " + "by KiCad and its dependencies." ), + _( "Unsupported Operating System" ), + wxOK | wxICON_EXCLAMATION ); + + dialog.SetExtendedMessage( _( "Any issues with KiCad on this system cannot " + "be reported to the official bugtracker." ) ); + dialog.ShowModal(); + + return true; +} diff --git a/common/dialog_about/AboutDialog_main.cpp b/common/dialog_about/AboutDialog_main.cpp index b0e3d64f63..0dd7532b7d 100644 --- a/common/dialog_about/AboutDialog_main.cpp +++ b/common/dialog_about/AboutDialog_main.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -67,7 +68,8 @@ static void buildKicadAboutBanner( EDA_BASE_FRAME* aParent, ABOUT_APP_INFO& aInf /* KiCad build version */ wxString version; - version << GetBuildVersion() + version << ( KIPLATFORM::APP::IsOperatingSystemUnsupported() ? "(UNSUPPORTED)" + : GetBuildVersion() ) #ifdef DEBUG << ", debug" #else diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 68dbeabe5b..fd49724e5b 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -282,6 +283,9 @@ bool PGM_BASE::InitPgm( bool aHeadless ) // (if the value contains some non ASCII7 chars, the env var is not initialized) SetLanguage( tmp, true ); + // Now that translations are available, inform the user if the OS is unsupported + WarnUserIfOperatingSystemUnsupported(); + loadCommonSettings(); ReadPdfBrowserInfos(); // needs GetCommonSettings() diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index 348c232314..235b3522e8 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -288,6 +288,9 @@ int COMMON_CONTROL::Donate( const TOOL_EVENT& aEvent ) int COMMON_CONTROL::ReportBug( const TOOL_EVENT& aEvent ) { + if( WarnUserIfOperatingSystemUnsupported() ) + return 0; + wxString version = GetVersionInfoData( m_frame->GetAboutTitle(), false, true ); wxString message; diff --git a/include/common.h b/include/common.h index e59d449caf..3e03f69fd6 100644 --- a/include/common.h +++ b/include/common.h @@ -111,4 +111,12 @@ const wxString ResolveUriByEnvVars( const wxString& aUri, PROJECT* aProject ); long long TimestampDir( const wxString& aDirPath, const wxString& aFilespec ); +/** + * Checks if the operating system is explicitly unsupported and displays a disclaimer message box + * + * @return true if the operating system is unsupported + */ +bool WarnUserIfOperatingSystemUnsupported(); + + #endif // INCLUDE__COMMON_H_ diff --git a/libs/kiplatform/gtk/app.cpp b/libs/kiplatform/gtk/app.cpp index da4f6e138b..67c24353ed 100644 --- a/libs/kiplatform/gtk/app.cpp +++ b/libs/kiplatform/gtk/app.cpp @@ -48,6 +48,13 @@ bool KIPLATFORM::APP::Init() } +bool KIPLATFORM::APP::IsOperatingSystemUnsupported() +{ + // Not implemented on this platform + return false; +} + + bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine ) { // Not implemented on this platform diff --git a/libs/kiplatform/include/kiplatform/app.h b/libs/kiplatform/include/kiplatform/app.h index 2edff8f69d..987961f713 100644 --- a/libs/kiplatform/include/kiplatform/app.h +++ b/libs/kiplatform/include/kiplatform/app.h @@ -36,6 +36,14 @@ namespace KIPLATFORM */ bool Init(); + /** + * Checks if the Operating System is explicitly unsupported and we want to prevent + * users from sending bug reports and show them a disclaimer on startup. + * + * @return true if unsupported + */ + bool IsOperatingSystemUnsupported(); + /** * Registers the application for restart with the OS with the given command line string to pass as args * diff --git a/libs/kiplatform/msw/app.cpp b/libs/kiplatform/msw/app.cpp index 2623e81907..a877a9011d 100644 --- a/libs/kiplatform/msw/app.cpp +++ b/libs/kiplatform/msw/app.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -39,21 +38,23 @@ bool KIPLATFORM::APP::Init() _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF ); #endif + return true; +} + + +bool KIPLATFORM::APP::IsOperatingSystemUnsupported() +{ #if defined( PYTHON_VERSION_MAJOR ) && ( ( PYTHON_VERSION_MAJOR == 3 && PYTHON_VERSION_MINOR >= 8 ) \ || PYTHON_VERSION_MAJOR > 3 ) // Python 3.8 switched to Windows 8+ API, we do not support Windows 7 and will not - // attempt to hack around it. Gracefully inform the user and refuse to start (because - // python will crash us if we continue). - if( !IsWindows8OrGreater() ) - { - wxMessageBox( _( "Windows 7 and older is no longer supported by KiCad and its " - "dependencies." ), _( "Unsupported Operating System" ), - wxOK | wxICON_ERROR ); - return false; - } + // attempt to hack around it. A normal user will never get here because the Python DLL + // is missing dependencies - and because it is not dynamically loaded, KiCad will not even + // start without patching Python or its WinAPI dependency. This is just to create a nag dialog + // for those who run patched Python and prevent them from submitting bug reports. + return !IsWindows8OrGreater(); +#else + return false; #endif - - return true; } diff --git a/libs/kiplatform/osx/app.mm b/libs/kiplatform/osx/app.mm index c8e2ee73f8..8feb4794bd 100644 --- a/libs/kiplatform/osx/app.mm +++ b/libs/kiplatform/osx/app.mm @@ -30,6 +30,13 @@ bool KIPLATFORM::APP::Init() } +bool KIPLATFORM::APP::IsOperatingSystemUnsupported() +{ + // Not implemented on this platform + return false; +} + + bool KIPLATFORM::APP::RegisterApplicationRestart( const wxString& aCommandLine ) { // Not implemented on this platform