meerk40t / meerk40t

Hackable Laser software for K40 / GRBL / Fibre Lasers
MIT License
233 stars 62 forks source link

Avoid linetext crash under Linux #2676

Closed jpirnay closed 1 week ago

jpirnay commented 1 week ago

Both the linetext and the regular text tool open the associated property panel after creation. They the try to focus the text entry box and select all text to simplify the text editing process. While this works flawlessly uder Windows and Darwin, this method crashes under Linux. The hypothesis is that wxPython is flawed in this aspect that it will crash if the window / control are not fully established yet. Unfortunately no indicator does expose that unready state. As we can't contain it, we will skip the textselection under Linux. Sorry.

Summary by Sourcery

Bug Fixes:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

The PR fixes a crash that occurs under Linux when attempting to auto-select text in text entry boxes immediately after creation. The fix implements a platform-specific check to skip the text selection functionality on Linux systems, as wxPython appears to have issues when trying to focus and select text in controls that may not be fully initialized.

Class diagram for changes in hersheymanager.py

classDiagram
    class HersheyManager {
        - bool _islinux
        + signal(signalstr, myargs)
    }
    note for HersheyManager "_islinux is used to check the platform and avoid crashes on Linux."

Class diagram for changes in textproperty.py

classDiagram
    class TextPropertyPanel {
        - bool _islinux
        + signal(signal, *args)
    }
    note for TextPropertyPanel "_islinux is used to check the platform and avoid crashes on Linux."

File-Level Changes

Change Details Files
Added Linux platform detection and skip text selection logic
  • Added _islinux flag to store Linux platform detection
  • Modified signal handler to return early on Linux systems without attempting text selection
  • Removed separate select_text method and inlined the functionality
meerk40t/gui/hersheymanager.py
Implemented Linux platform check in text property panel
  • Added _islinux flag for platform detection
  • Added early return for text selection signal on Linux systems
meerk40t/gui/propertypanels/textproperty.py

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).