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

wxNamingViewer: build with wxWidgets 3.2 #2169

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

saper
Copy link
Contributor

@saper saper commented Nov 27, 2023

The patches attached are needed to build and
run wxNamingViewer with wxWidgets 3.2

For most existing code I could not identify which version
of wxWindows/wxWidgets it could have worked last time,
therefore a generic #ifdef has been used.

If no support for old frameworks is needed,
those could be removed.

Summary by CodeRabbit

  • Style
    • Enhanced dialog window borders to support resizing, offering a more consistent and user-friendly appearance across various screens.
  • Bug Fixes
    • Improved user interactions by refining the responsiveness and error feedback in multiple dialogs.
  • Refactor
    • Streamlined hierarchical displays within tree views for more accurate and reliable navigation.

@mitza-oci
Copy link
Member

Thanks for working on this. Would it be feasible to update one of the GitHub Actions builds to enable wxWidgets?

@saper saper force-pushed the wxwidgets-3-2-support branch from a13fcf5 to d690c4d Compare November 28, 2023 18:42
wxNamingTree.cpp:94:45: error: non-const lvalue reference to type 'wxTreeItemIdValue'
 (aka 'void *') cannot bind to a value of unrelated type 'long'
  wxTreeItemId child = GetFirstChild( item, cookie);
                                            ^~~~~~
LLVM 16 fails to compile this, GetParent()
seem to refer to wxWindow *GetParent() which has no args.
Going back to the source code from 2003,
it seems that it has always should have been
wxCommandEvent and not wxMouseEvent.
To get number of items in the container,
GetCount() should be used.

Hard to tell when Number() has been removed.
@saper
Copy link
Contributor Author

saper commented Nov 28, 2023

Thanks for working on this. Would it be feasible to update one of the GitHub Actions builds to enable wxWidgets?

Sure, tried this 74ba32c but it looks like the build does not even descend into the utils directory as it did for me: https://github.com/DOCGroup/ACE_TAO/actions/runs/7023541947/job/19110306550?pr=2169

@mitza-oci
Copy link
Member

It's running the makefile but not building anything yet.
https://github.com/DOCGroup/ACE_TAO/actions/runs/7023541947/job/19110306550?pr=2169#step:18:4354
One of the earlier steps that writes to platform_macros.GNU needs to add wxWindows=1 to it

@saper saper force-pushed the wxwidgets-3-2-support branch from 74ba32c to 5ec78ec Compare November 29, 2023 02:30
Copy link

coderabbitai bot commented Feb 2, 2025

Walkthrough

The changes introduce a new wxWidgets feature configuration to the GitHub Actions workflow and update several wxWidgets-based dialog implementations. The modifications include conditional compilation directives to adjust window border styles (switching between wxTHICK_FRAME and wxRESIZE_BORDER) based on the wxWidgets ABI version, as well as updates to event handling mechanisms and variable type refinements. Additionally, the changes remove an unused header and enforce string immutability in resource definitions, without altering the core dialog creation logic or the public API declarations.

Changes

File(s) Change Summary
.github/workflows/linux.yml Added new matrix entry for wxWidgets: sets feature: wxwidgets, uses gcc-10/g++-10, and adds package dependencies along with optional macros (wxWindows=1).
TAO/utils/wxNamingViewer/wxAddNameServerDlg.cpp, TAO/utils/wxNamingViewer/wxBindDialog.cpp, TAO/utils/wxNamingViewer/wxBindNewContext.cpp Updated constructors to conditionally select window style (wxTHICK_FRAME vs. wxRESIZE_BORDER) based on the wxABI_VERSION.
TAO/utils/wxNamingViewer/wxNamingTree.cpp Changed type of cookie from long to wxTreeItemIdValue and replaced GetParent(item) with GetItemParent(item) in multiple methods.
TAO/utils/wxNamingViewer/wxNamingViewer.cpp Removed the inclusion of the unnecessary header wx/resource.h.
TAO/utils/wxNamingViewer/wxNamingViewer.wxr Converted dialog variable types from char * to const char * and updated styles from wxTHICK_FRAME to wxRESIZE_BORDER in declarations.
TAO/utils/wxNamingViewer/wxSelectNSDialog.cpp, TAO/utils/wxNamingViewer/wxSelectNSDialog.h Modified event handling: updated event parameter from wxMouseEvent to wxCommandEvent, adjusted list count retrieval (Number() to GetCount()), and refined string conversion in the add method.
TAO/utils/wxNamingViewer/wxViewIORDialog.cpp Revised constructor for conditional window border style and updated the OnApply method signature with a macro (ONLY_ANCIENT_WX_USES) to fallback on wxDialog::EndModal(wxID_APPLY). Also added early error handling in the decodeIOR method.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant D as WxViewIORDialog
    U->>D: Click "Apply" button
    D->>D: Invoke OnApply(event)
    alt Ancient wxWidgets
        D->>D: Call wxDialog::OnApply(event)
    else Modern wxWidgets
        D->>D: Call wxDialog::EndModal(wxID_APPLY)
    end
    D->>D: Decode IOR & handle errors
    D-->>U: Close dialog / Return control
Loading

Poem

I'm a rabbit in a digital wood,
Hopping through code, feeling so good.
New features and fixes, crisp as a carrot,
Conditional frames making my spirit merit.
Bugs flee when my changes come to play –
Happy leaps in code light my day! 🐰🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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 comments (1)
TAO/utils/wxNamingViewer/wxViewIORDialog.cpp (1)

164-164: Fix incorrect assertion variable.

The assertion is checking typeIDText but should be checking profiles since that's the variable that was just assigned.

-  assert( typeIDText);
+  assert( profiles);
🧹 Nitpick comments (5)
TAO/utils/wxNamingViewer/wxViewIORDialog.cpp (1)

222-234: LGTM! Consider adding documentation for the macro.

The macro and event handling changes are well-implemented, providing clean compatibility across wxWidgets versions.

Add a brief comment explaining the purpose of the ONLY_ANCIENT_WX_USES macro:

+// Macro to handle event parameters differently for older wxWidgets versions
+// where event parameters were required to be used
 #if defined(ANCIENT_WX_WINDOWS)
 #define ONLY_ANCIENT_WX_USES(x) (x)
 #else
 #define ONLY_ANCIENT_WX_USES(x) WXUNUSED(x)
 #endif
TAO/utils/wxNamingViewer/wxNamingTree.cpp (2)

159-161: Consider implementing the TODO items for better UX.

The TODO comments indicate missing features that would improve user experience:

  1. Different icons for contexts
  2. Conditional setting of children flag

Would you like me to help implement these features or create issues to track them?


396-421: Consider refactoring duplicated unbind logic.

The unbind logic is duplicated between onContextPopupUnbind and onObjectPopupUnbind. Consider extracting the common code into a shared helper method.

+private:
+  void unbindItem(const wxTreeItemId& item, const wxString& confirmMessage) {
+    if (wxMessageBox(
+        confirmMessage,
+        "Confirm",
+        wxYES_NO | wxICON_QUESTION) != wxYES) {
+      return;
+    }
+    wxTreeItemId parentItem = GetItemParent(item);
+    if (parentItem == 0) {
+      return;
+    }
+    WxNamingObject* object = getTreeObject(item);
+    WxNamingObject* parent = getTreeObject(parentItem);
+    CosNaming::NamingContext_var context = parent->NamingContext();
+    try {
+      context->unbind(object->Name());
+      clearChildren(item);
+      Delete(item);
+    } catch(CORBA::Exception& ex) {
+      wxMessageBox(ex._rep_id(), "CORBA::Exception");
+    }
+  }

 void WxNamingTree::onContextPopupUnbind(wxCommandEvent&) {
-  if (wxMessageBox(
-      "Are you sure you want to unbind this context?",
-      "Confirm",
-      wxYES_NO | wxICON_QUESTION) != wxYES) {
-    return;
-  }
-  wxTreeItemId item = GetSelection();
-  wxTreeItemId parentItem = GetItemParent(item);
-  if (parentItem == 0) {
-    return;
-  }
-  WxNamingObject* object = getTreeObject(item);
-  WxNamingObject* parent = getTreeObject(parentItem);
-  CosNaming::NamingContext_var context = parent->NamingContext();
-  try {
-    context->unbind(object->Name());
-    clearChildren(item);
-    Delete(item);
-  } catch(CORBA::Exception& ex) {
-    wxMessageBox(ex._rep_id(), "CORBA::Exception");
-  }
+  unbindItem(GetSelection(), "Are you sure you want to unbind this context?");
 }

 void WxNamingTree::onObjectPopupUnbind(wxCommandEvent&) {
-  if (wxMessageBox(
-      "Are you sure you want to unbind this object?",
-      "Confirm",
-      wxYES_NO | wxICON_QUESTION) != wxYES) {
-    return;
-  }
-  wxTreeItemId item = GetSelection();
-  wxTreeItemId parentItem = GetItemParent(item);
-  if (parentItem == 0) {
-    return;
-  }
-  WxNamingObject* object = getTreeObject(item);
-  WxNamingObject* parent = getTreeObject(parentItem);
-  CosNaming::NamingContext_var context = parent->NamingContext();
-  try {
-    context->unbind(object->Name());
-    clearChildren(item);
-    Delete(item);
-  } catch(CORBA::Exception& ex) {
-    wxMessageBox(ex._rep_id(), "CORBA::Exception");
-  }
+  unbindItem(GetSelection(), "Are you sure you want to unbind this object?");
 }

Also applies to: 344-367

TAO/utils/wxNamingViewer/wxBindDialog.cpp (1)

85-91: LGTM! Border style change is consistent.

The conditional compilation for window styles matches other dialog implementations. Consider extracting the common window style flags into a macro or constant to reduce code duplication across dialog classes.

// Add to a common header file:
#if wxABI_VERSION < 20800
#define WX_DIALOG_BORDER_STYLE (wxTHICK_FRAME)
#else
#define WX_DIALOG_BORDER_STYLE (wxRESIZE_BORDER)
#endif

// Use in dialog constructors:
wxRAISED_BORDER | wxCAPTION | WX_DIALOG_BORDER_STYLE | wxSYSTEM_MENU
TAO/utils/wxNamingViewer/wxSelectNSDialog.cpp (1)

146-150: Consider removing commented-out code.

The old code using Number() is commented out but still present. Since the change to GetCount() is confirmed working, the old code can be safely removed.

-#if 0
-  int count = servers->Number();
-#else
  int count = servers->GetCount();
-#endif
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f11974 and e879111.

📒 Files selected for processing (10)
  • .github/workflows/linux.yml (1 hunks)
  • TAO/utils/wxNamingViewer/wxAddNameServerDlg.cpp (1 hunks)
  • TAO/utils/wxNamingViewer/wxBindDialog.cpp (1 hunks)
  • TAO/utils/wxNamingViewer/wxBindNewContext.cpp (1 hunks)
  • TAO/utils/wxNamingViewer/wxNamingTree.cpp (4 hunks)
  • TAO/utils/wxNamingViewer/wxNamingViewer.cpp (0 hunks)
  • TAO/utils/wxNamingViewer/wxNamingViewer.wxr (5 hunks)
  • TAO/utils/wxNamingViewer/wxSelectNSDialog.cpp (4 hunks)
  • TAO/utils/wxNamingViewer/wxSelectNSDialog.h (1 hunks)
  • TAO/utils/wxNamingViewer/wxViewIORDialog.cpp (2 hunks)
💤 Files with no reviewable changes (1)
  • TAO/utils/wxNamingViewer/wxNamingViewer.cpp
🔇 Additional comments (18)
TAO/utils/wxNamingViewer/wxViewIORDialog.cpp (2)

137-143: LGTM! Good approach for maintaining backward compatibility.

The conditional compilation directive appropriately handles different wxWidgets versions by switching between wxTHICK_FRAME and wxRESIZE_BORDER based on the ABI version.


189-194: LGTM! Good defensive programming.

The early return for nil objects prevents potential issues and properly handles the UI state.

TAO/utils/wxNamingViewer/wxNamingTree.cpp (4)

93-93: LGTM: Correct type for wxWidgets tree item cookie.

The change from long to wxTreeItemIdValue aligns with the wxWidgets API requirements for tree item cookies.


314-314: LGTM: Updated to use preferred wxWidgets API.

The change from GetParent to GetItemParent follows wxWidgets best practices and ensures compatibility with version 3.2.


353-353: LGTM: Consistent use of preferred wxWidgets API.

The change maintains consistency with the updated wxWidgets API usage throughout the codebase.


407-407: LGTM: Consistent use of preferred wxWidgets API.

The change completes the consistent update to the preferred wxWidgets API across all methods.

TAO/utils/wxNamingViewer/wxSelectNSDialog.h (1)

22-22: Verify event handling compatibility with wxListBox.

The change from wxMouseEvent to wxCommandEvent for onLeftDClick aligns with wxWidgets 3.2's event handling, as list controls now emit command events for double-clicks. However, let's verify this is properly connected in the implementation.

✅ Verification successful

Event handling in wxSelectNSDialog for list controls is correctly updated.

  • The event table binds EVT_LISTBOX_DCLICK on IDC_SERVERS to onLeftDClick.
  • The implementation of onLeftDClick accepts a wxCommandEvent, which is consistent with wxWidgets 3.2 practices.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for event table entries and event handler implementations
echo "Searching for event table entries:"
rg -A 2 "BEGIN_EVENT_TABLE.*WxSelectNSDialog" 

echo "Searching for event handler implementation:"
rg "void.*WxSelectNSDialog::onLeftDClick"

# Search for list control event bindings
echo "Searching for list control event bindings:"
rg "EVT_LISTBOX_DCLICK|EVT_LIST_ITEM_ACTIVATED"

Length of output: 920

TAO/utils/wxNamingViewer/wxBindNewContext.cpp (2)

98-105: LGTM! Border style change is correctly implemented.

The conditional compilation for window styles properly handles compatibility between wxWidgets versions:

  • Uses wxTHICK_FRAME for versions < 2.8.0
  • Uses wxRESIZE_BORDER for newer versions

98-105: LGTM! Window style update is correctly implemented.

The conditional compilation directive for window styles is well-structured and maintains backward compatibility while supporting wxWidgets 3.2.

TAO/utils/wxNamingViewer/wxAddNameServerDlg.cpp (2)

101-107: LGTM! Border style change matches other dialog implementations.

The conditional compilation for window styles is consistent with other dialog classes in the codebase.


101-107: LGTM! Window style update matches the pattern.

The window style changes are consistent with other dialog implementations in the codebase.

TAO/utils/wxNamingViewer/wxNamingViewer.wxr (1)

1-2: LGTM! Consistent dialog style updates.

The dialog styles have been consistently updated to use wxRESIZE_BORDER across all dialogs, which aligns with modern wxWidgets practices.

Also applies to: 29-30, 51-52, 73-74, 95-96

TAO/utils/wxNamingViewer/wxSelectNSDialog.cpp (3)

96-102: LGTM! Proper version-based dialog style handling.

The conditional compilation ensures compatibility with different wxWidgets versions by using the appropriate frame style.


165-165: LGTM! Proper string conversion.

The use of AsChar() ensures proper conversion of wxString to char* for the configuration API.

Also applies to: 168-168


193-193: LGTM! Correct event type for double-click handling.

Changed from wxMouseEvent to wxCommandEvent which is the correct event type for list box double-click events.

.github/workflows/linux.yml (1)

161-168: LGTM! Proper CI configuration for wxWidgets support.

The new feature matrix entry correctly:

  • Uses a compatible compiler (gcc-10)
  • Installs required wxWidgets packages
  • Sets the necessary build flags (wxWindows=1)
TAO/utils/wxNamingViewer/wxBindDialog.cpp (2)

85-91: LGTM! Window style update follows the established pattern.

The window style changes maintain consistency with other dialog implementations while preserving backward compatibility.


85-91: Consider documenting the version-based window style changes.

The consistent use of preprocessor directives for handling wxWidgets version differences is well-implemented across all dialog classes. As mentioned in the PR objectives, if there's no need to support older frameworks, these conditional directives could be removed in the future.

Let's verify if there are any other files in the codebase that might need similar updates:

Also applies to: 101-107, 98-105

✅ Verification successful

Architectural Note on Version-Based Window Style Logic

The codebase consistently employs preprocessor directives in multiple dialog classes to handle wxWidgets version differences. Our verification confirms that the following files use this approach:

  • TAO/utils/wxNamingViewer/wxBindDialog.cpp (lines 85–91)
  • TAO/utils/wxNamingViewer/wxAddNameServerDlg.cpp
  • TAO/utils/wxNamingViewer/wxSelectNSDialog.cpp
  • TAO/utils/wxNamingViewer/wxViewIORDialog.cpp
  • TAO/utils/wxNamingViewer/wxBindNewContext.cpp

This consistent design ensures maintainability and smooth backward compatibility. However, documenting the rationale behind these version-specific style flags (e.g., when using wxTHICK_FRAME versus wxRESIZE_BORDER) would further assist future developers—especially if support for older wxWidgets versions is eventually dropped.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other dialog implementations that might need similar updates
rg -l "wxTHICK_FRAME" --type cpp

Length of output: 259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants