-
Notifications
You must be signed in to change notification settings - Fork 12
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 crashes #232
Fix crashes #232
Conversation
WalkthroughThe changes involve updates to various application components, primarily focusing on the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant OsreEdApp
participant PlatformOperations
User->>OsreEdApp: Press 'O' key
OsreEdApp->>PlatformOperations: Trigger file open dialog
PlatformOperations-->>OsreEdApp: Return selected file URI
OsreEdApp->>OsreEdApp: Validate URI
OsreEdApp->>OsreEdApp: Load asset
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
src/Editor/src/OsreEdApp.cpp (1)
157-163
: Approve the new asset import feature with suggestions for improvement.The new asset import feature looks good and adds a valuable functionality to the application. The use of the file open dialog and the
loadAsset
method to handle the asset import process is a clean and effective approach.However, consider the following suggestions for improvement:
- Add error handling for the asset import process to gracefully handle any potential errors or exceptions that may occur during the import.
- Consider moving the asset import logic to a separate method for better code organization and readability. This will help keep the
onUpdate
method focused on its primary responsibility of updating the application state every frame.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- samples/00_HelloWorld/HelloWorld.cpp (1 hunks)
- samples/01_ModelLoading/ModelLoading.cpp (1 hunks)
- samples/03_Instancing/Instancing.cpp (1 hunks)
- samples/04_terrain/TerrainRendering.cpp (1 hunks)
- src/Editor/src/OsreEdApp.cpp (2 hunks)
- src/Editor/src/main.cpp (2 hunks)
- src/Engine/App/AppBase.cpp (1 hunks)
- src/Engine/App/AppBase.h (2 hunks)
Additional comments not posted (12)
src/Editor/src/main.cpp (3)
37-37
: LGTM!Commenting out the inclusion of
PlatformOperations.h
aligns with the removal of the code segment responsible for opening a file dialog to select an asset for import. This change suggests a shift away from using platform-specific operations for file dialogs, as mentioned in the AI-generated summary.
55-55
: LGTM!The modifications to the
initWindow
function call, including the additional parameters for window mode and type, suggest a more flexible window configuration. The changes involve replacing boolean parameters with enumerated types, enhancing clarity and type safety, as mentioned in the AI-generated summary and the alterations to the declarations of exported or public entities.
63-65
: LGTM!The streamlined main loop, focusing on event handling, updating, and requesting the next frame, enhances the clarity and efficiency of the main application loop. The removal of the code segment responsible for opening a file dialog to select an asset for import indicates a shift towards a more event-driven architecture, where the application continuously processes events and updates without the previous asset loading mechanism, as mentioned in the AI-generated summary.
samples/03_Instancing/Instancing.cpp (1)
119-119
: LGTM!The change from boolean parameters to enumerated types (
WindowMode::Windowed
andWindowType::Root
) in theinitWindow
function call is a good practice. It enhances code clarity, readability, and maintainability by using descriptive enumerations instead of generic boolean flags. This change makes the function call more self-explanatory and less error-prone, while preserving the overall functionality of the application.samples/00_HelloWorld/HelloWorld.cpp (1)
108-110
: LGTM!The added conditional check enhances the robustness of the key handling logic by preventing unnecessary updates when an unknown key is detected. The code segment is implemented correctly and follows the existing code style.
src/Editor/src/OsreEdApp.cpp (1)
164-166
: LGTM!The adjustment to the key handling logic is a good improvement. It ensures that the keyboard transformation controller is only updated when a valid key is detected, preventing unnecessary updates and potentially improving performance.
samples/01_ModelLoading/ModelLoading.cpp (1)
188-188
: LGTM!The change from boolean parameters to enumerated types (
WindowMode::Windowed
andWindowType::Root
) for specifying the window mode and type is a good refactoring that enhances code clarity, type safety, and maintainability. Using enumerated types provides a clear and explicit way to define the window configuration, eliminating potential ambiguity and reducing the chances of passing incorrect boolean values. This change aligns with best practices for self-documenting code.samples/04_terrain/TerrainRendering.cpp (1)
208-208
: LGTM!The change from boolean flags to enumerated types
WindowMode::Windowed
andWindowType::Root
for specifying the window properties in theinitWindow
function call is a good refactoring. It enhances code clarity, readability, and maintainability by providing a more explicit and self-documenting way to set the window mode and type.The use of enumerated types also improves type safety by restricting the possible values to a predefined set, reducing the chances of passing invalid or unintended values.
Overall, this change aligns with good coding practices and enhances the quality of the codebase without altering the functionality of the application.
src/Engine/App/AppBase.cpp (1)
85-94
: LGTM! The changes improve code clarity and extensibility.Replacing the boolean parameters
fullscreen
andchildWindow
with enumsWindowMode
andWindowType
offers several benefits:
- It enhances code readability by using more descriptive names for the window behavior, making the function's purpose clearer at a glance.
- It improves type safety and extensibility by restricting the possible values to a predefined set of options, reducing the chances of passing invalid arguments and allowing for easier future modifications if additional window modes or types need to be introduced.
The updated logic correctly reflects the new parameter types by comparing the
mode
againstWindowMode::Fullscreen
and thetype
againstWindowType::Child
, maintaining the original behavior while improving the semantic clarity of the code.Great job on this refactoring!
src/Engine/App/AppBase.h (3)
106-111
: LGTM!The new
WindowMode
enum class is a great addition. It provides a type-safe way to represent different window modes, enhancing code clarity and reducing potential errors. The enum values are well-chosen and follow the naming convention. TheInvalid
andCount
values are useful for error handling and bounds checking.
113-118
: LGTM!The new
WindowType
enum class is a great addition. It provides a type-safe way to represent different window types, enhancing code clarity and reducing potential errors. The enum values are well-chosen and follow the naming convention. TheInvalid
andCount
values are useful for error handling and bounds checking.
160-160
: Verify the impact of the changes.The changes to the
initWindow
method signature, replacing the boolean parameters with the newWindowMode
andWindowType
enums, are a good improvement. They enhance the clarity and extensibility of the window initialization process by using enumerated types instead of boolean flags, which improves code readability and reduces potential errors related to parameter interpretation.However, please ensure that the method implementation and all its usages are updated to handle the new parameters correctly. You can use the following script to verify the impact:
Verification successful
Verification successful: Changes to
initWindow
method signature are correctly implemented.The
initWindow
method declaration has been updated to useWindowMode
andWindowType
enums, and all usages in the codebase have been updated to match the new signature. No old usages with boolean parameters were found. The changes enhance code readability and maintainability.
- Method declaration updated in
src/Engine/App/AppBase.h
.- Usage updated in
src/Editor/src/main.cpp
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of the changes to the `initWindow` method signature. # Test 1: Search for the method declaration. Expect: Only the new signature. rg --type cpp -A 5 $'bool\s+initWindow\s*\(\s*ui32\s+x\s*,\s*ui32\s+y\s*,\s*ui32\s+width\s*,\s*ui32\s+height\s*,\s*const\s+String\s*&\s*title\s*,\s*WindowMode\s+mode\s*,\s*WindowType\s+type\s*,\s*RenderBackendType\s+renderer\s*\)' # Test 2: Search for the method usages. Expect: All usages updated to match the new signature. rg --type cpp -A 5 $'initWindow\s*\(\s*\w+\s*,\s*\w+\s*,\s*\w+\s*,\s*\w+\s*,\s*[\w"]+\s*,\s*[\w:]+\s*,\s*[\w:]+\s*,\s*[\w:]+\s*\)'Length of output: 696
Script:
#!/bin/bash # Description: Broaden the search for the `initWindow` method declaration and check for old usages. # Search for any `initWindow` method declaration to verify if it has been updated. rg --type cpp -A 5 'bool\s+initWindow\s*\(' # Search for any old usages of the `initWindow` method signature with boolean parameters. rg --type cpp -A 5 $'initWindow\s*\(\s*\w+\s*,\s*\w+\s*,\s*\w+\s*,\s*\w+\s*,\s*[\w"]+\s*,\s*(true|false)\s*,\s*(true|false)\s*,\s*[\w:]+\s*\)'Length of output: 673
Summary by CodeRabbit
New Features
Bug Fixes
Refactor