From 7c15f9098cf9b1457fac5a2fba0adb625132e65c Mon Sep 17 00:00:00 2001 From: Light Date: Mon, 6 Nov 2023 20:51:03 +1100 Subject: [PATCH] Add extra check for GPU device info for null pointer (#3032) * add check for GPU device info * add changelog note * change return to continue * Small refactor --------- Co-authored-by: Lea Anthony --- v3/internal/doctor/doctor.go | 19 ++++++++++--------- website/src/pages/changelog.mdx | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/v3/internal/doctor/doctor.go b/v3/internal/doctor/doctor.go index 0d66f33f..c46fd902 100644 --- a/v3/internal/doctor/doctor.go +++ b/v3/internal/doctor/doctor.go @@ -2,17 +2,18 @@ package doctor import ( "fmt" + "path/filepath" + "runtime" + "runtime/debug" + "slices" + "strconv" + "github.com/go-git/go-git/v5" "github.com/jaypipes/ghw" "github.com/pterm/pterm" "github.com/samber/lo" "github.com/wailsapp/wails/v3/internal/operatingsystem" "github.com/wailsapp/wails/v3/internal/version" - "path/filepath" - "runtime" - "runtime/debug" - "slices" - "strconv" ) func Run() (err error) { @@ -155,12 +156,12 @@ func Run() (err error) { // Probe GPU gpu, _ := ghw.GPU(ghw.WithDisableWarnings()) if gpu != nil { - prefix := "GPU" for idx, card := range gpu.GraphicsCards { - if len(gpu.GraphicsCards) > 1 { - prefix = "GPU " + strconv.Itoa(idx+1) + " " + details := "Unknown" + prefix := "GPU " + strconv.Itoa(idx+1) + if card.DeviceInfo != nil { + details = fmt.Sprintf("%s (%s) - Driver: %s ", card.DeviceInfo.Product.Name, card.DeviceInfo.Vendor.Name, card.DeviceInfo.Driver) } - details := fmt.Sprintf("%s (%s) - Driver: %s", card.DeviceInfo.Product.Name, card.DeviceInfo.Vendor.Name, card.DeviceInfo.Driver) systemTabledata = append(systemTabledata, []string{prefix, details}) } } else { diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index d49cf6d3..76ae0e3a 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 #### Fixed - Fixed typo on docs/reference/options page. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2887) +- Fixed bug for linux in doctor in the event user doesn't have proper drivers installed. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/3032) ## v2.6.0 - 2023-09-06