Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Flet 0.23 crash on Ubuntu 22.04 #3495

Merged
merged 1 commit into from
Jun 19, 2024
Merged

Fix Flet 0.23 crash on Ubuntu 22.04 #3495

merged 1 commit into from
Jun 19, 2024

Conversation

FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Jun 19, 2024

Fix #3490

Summary by Sourcery

This pull request addresses a crash issue in Flet 0.23 on Ubuntu 22.04 by modifying the GTK window initialization. It also enhances the application lifecycle management by adding startup and shutdown methods, and updates the build configuration to handle native assets.

  • Bug Fixes:
    • Fixed a crash in Flet 0.23 on Ubuntu 22.04 by replacing gtk_widget_realize with gtk_widget_show.
  • Enhancements:
    • Added startup and shutdown implementations to the GApplication class in my_application.cc.
  • Build:
    • Updated CMakeLists.txt to copy native assets provided by build.dart from all packages.

Copy link
Contributor

sourcery-ai bot commented Jun 19, 2024

Reviewer's Guide by Sourcery

This pull request addresses issue #3490 by fixing a crash in Flet 0.23 on Ubuntu 22.04. The changes involve modifications to the my_application.cc file to properly handle GTK window initialization and application lifecycle events, and updates to the CMakeLists.txt file to manage native assets and ensure proper installation.

File-Level Changes

Files Changes
client/linux/my_application.cc
client/linux/CMakeLists.txt
The changes in my_application.cc and CMakeLists.txt collectively ensure proper initialization and lifecycle management of the application, as well as correct handling of native assets.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @FeodorFitsner - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -48,7 +48,7 @@ static void my_application_activate(GApplication* application) {
}

gtk_window_set_default_size(window, 1280, 720);
gtk_widget_realize(GTK_WIDGET(window));
gtk_widget_show(GTK_WIDGET(window));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider using gtk_widget_show_all for better visibility.

Using gtk_widget_show_all(GTK_WIDGET(window)) instead of gtk_widget_show(GTK_WIDGET(window)) will ensure that all child widgets are also shown, which might be necessary depending on the window's content.

Suggested change
gtk_widget_show(GTK_WIDGET(window));
gtk_widget_show_all(GTK_WIDGET(window));

@@ -81,6 +81,24 @@ static gboolean my_application_local_command_line(GApplication* application, gch
return TRUE;
}

// Implements GApplication::startup.
static void my_application_startup(GApplication* application) {
//MyApplication* self = MY_APPLICATION(object);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Remove commented-out code if not needed.

If the commented-out code is not necessary, it is better to remove it to keep the codebase clean. If it is needed for future reference, consider adding a comment explaining why it is commented out.

Suggested change
//MyApplication* self = MY_APPLICATION(object);
// If needed for future reference, uncomment and use the following line:
// MyApplication* self = MY_APPLICATION(object);

@@ -122,6 +123,12 @@ foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
COMPONENT Runtime)
endforeach(bundled_library)

# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (documentation): Possible missing slash in directory path.

Should there be a slash after ${PROJECT_BUILD_DIR} in the NATIVE_ASSETS_DIR path?

@FeodorFitsner FeodorFitsner merged commit 5b79075 into main Jun 19, 2024
3 checks passed
@FeodorFitsner FeodorFitsner deleted the linux-crash-fix branch June 19, 2024 19:54
zrr1999 pushed a commit to zrr1999/flet that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flet 0.23 critical erreur when runing application / the application does not want to run ans stop
1 participant