summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-03-07 18:23:05 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-03-10 22:18:23 +0000
commitc88a9436bc7d769d3e4d85053f42b0823439ab4d (patch)
tree5b2dce00feeaa9bae4391654313756b1787224f3
parentbd5ffe86e400855e8538da10d711a422f6c865ee (diff)
downloadswig-c88a9436bc7d769d3e4d85053f42b0823439ab4d.tar.gz
Fix segfault in C# layer handling using declarations
Segfault was actually avoided in previous commit ab23cb29. This commit makes handling more robust in the event of using %ignore just on the derived method, not tested as it is not what one should do with directors, and possibly other cases. Go still segfaults with the new testcase director_using_member_scopes.i. Issue #1441.
-rw-r--r--Examples/test-suite/common.mk1
-rw-r--r--Examples/test-suite/director_using_member_scopes.i32
-rw-r--r--Source/Modules/csharp.cxx4
3 files changed, 35 insertions, 2 deletions
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 685882f80..b5ac56049 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -218,6 +218,7 @@ CPP_TEST_CASES += \
director_thread \
director_unroll \
director_using \
+ director_using_member_scopes \
director_void \
director_wombat \
disown \
diff --git a/Examples/test-suite/director_using_member_scopes.i b/Examples/test-suite/director_using_member_scopes.i
new file mode 100644
index 000000000..02d4dc000
--- /dev/null
+++ b/Examples/test-suite/director_using_member_scopes.i
@@ -0,0 +1,32 @@
+%module(directors="1") director_using_member_scopes
+
+// Similar to using_member_scopes but for directors
+
+#if !defined(SWIGGO)
+
+%feature("director");
+// Python,Java,C# no diffs in generated code when adding in nodirector. Go not happy even without %nodirector.
+// Fully qualifying parameter types in a method declared after the using declaration caused
+// a method being incorrectly added by the using declaration even though the declaration already existed
+
+// Github issue #1441 - segfault in Go and C#
+
+%inline %{
+namespace OgreBites
+{
+ struct NativeWindowType {};
+ class ApplicationContextBase {
+ public:
+ virtual ~ApplicationContextBase() {}
+ virtual void setWindowGrab(NativeWindowType* win, bool grab = true) {}
+ void setWindowGrab(bool grab = true) {}
+ };
+ class ApplicationContextSDL : public ApplicationContextBase {
+ public:
+ using ApplicationContextBase::setWindowGrab;
+ void setWindowGrab(NativeWindowType* win, bool grab) {} // This should not be added again as it exists in base class
+ };
+}
+%}
+
+#endif
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index a94969f31..80ca8a0d0 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -2553,8 +2553,8 @@ public:
Replaceall(imcall, "$imfuncname", intermediary_function_name);
String *excode = NewString("");
Node *directorNode = Getattr(n, "directorNode");
- if (directorNode) {
- UpcallData *udata = Getattr(directorNode, "upcalldata");
+ UpcallData *udata = directorNode ? Getattr(directorNode, "upcalldata") : 0;
+ if (udata) {
String *methid = Getattr(udata, "class_methodidx");
if (!Cmp(return_type, "void"))