View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0003350 | NoesisGUI | C++ SDK | public | 2024-05-29 06:20 | 2024-06-05 18:05 |
| Reporter | nikobarli | Assigned To | jsantos | ||
| Priority | normal | Severity | block | ||
| Status | resolved | Resolution | fixed | ||
| Product Version | 3.2.3 | ||||
| Target Version | 3.2.4 | Fixed in Version | 3.2.4 | ||
| Summary | 0003350: Crash when calling Keyboard::Focus() inside DataContextChanged handler | ||||
| Description | We are now upgrading Noesis to version 3.2.3 and we found some scenarios that caused crashes. Please find a simple patch to reproduce this issue using your Buttons sample project. The same patch doesn't cause crash when applied to version 3.1.3 we used before, and the two DataContextChanged handlers are correctly called. | ||||
| Steps To Reproduce | Please apply the patch and run Sample Button project. | ||||
| Attached Files | crash.patch (2,376 bytes)
Index: Native/Src/Packages/Samples/Buttons/Src/MainWindow.xaml.cpp
===================================================================
--- Native/Src/Packages/Samples/Buttons/Src/MainWindow.xaml.cpp (revision 172871)
+++ Native/Src/Packages/Samples/Buttons/Src/MainWindow.xaml.cpp (working copy)
@@ -8,6 +8,7 @@
#include "ViewModel.h"
#include <NsGui/IntegrationAPI.h>
+#include <NsGui/Keyboard.h>
#include <NsGui/Uri.h>
#include <NsCore/ReflectionImplementEmpty.h>
@@ -20,6 +21,8 @@
MainWindow::MainWindow()
{
Initialized() += MakeDelegate(this, &MainWindow::OnInitialized);
+ DataContextChanged() += MakeDelegate(this, &MainWindow::DelegateFunc1);
+ DataContextChanged() += MakeDelegate(this, &MainWindow::DelegateFunc2);
InitializeComponent();
}
@@ -36,6 +39,19 @@
}
////////////////////////////////////////////////////////////////////////////////////////////////////
+void MainWindow::DelegateFunc1(BaseComponent*, const DependencyPropertyChangedEventArgs&)
+{
+ // As a result of calling the following method, DelegateImpl<Ret (Args...)>::MultiDelegate::~MultiDelegate() is called
+ GetKeyboard()->Focus(this);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+void MainWindow::DelegateFunc2(BaseComponent*, const DependencyPropertyChangedEventArgs&)
+{
+ // DelegateImpl<Ret (Args...)>::MultiDelegate::mInvoker is destroyed before this delegate is called
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
NS_BEGIN_COLD_REGION
NS_IMPLEMENT_REFLECTION_(Buttons::MainWindow, "Buttons.MainWindow")
Index: Native/Src/Packages/Samples/Buttons/Src/MainWindow.xaml.h
===================================================================
--- Native/Src/Packages/Samples/Buttons/Src/MainWindow.xaml.h (revision 172871)
+++ Native/Src/Packages/Samples/Buttons/Src/MainWindow.xaml.h (working copy)
@@ -26,6 +26,9 @@
void InitializeComponent();
void OnInitialized(BaseComponent*, const Noesis::EventArgs&);
+ void DelegateFunc1(BaseComponent*, const Noesis::DependencyPropertyChangedEventArgs&);
+ void DelegateFunc2(BaseComponent*, const Noesis::DependencyPropertyChangedEventArgs&);
+
private:
NS_DECLARE_REFLECTION(MainWindow, Window)
};
| ||||
| Platform | Windows | ||||
|
The following patch should fix this issue
Index: Delegate.inl --- Delegate.inl (revision 14042)
|
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2024-05-29 06:20 | nikobarli | New Issue | |
| 2024-05-29 06:20 | nikobarli | File Added: crash.patch | |
| 2024-05-29 15:12 | jsantos | Assigned To | => sfernandez |
| 2024-05-29 15:12 | jsantos | Status | new => assigned |
| 2024-05-29 15:13 | jsantos | Target Version | => 3.2.4 |
| 2024-06-04 13:25 | sfernandez | Assigned To | sfernandez => jsantos |
| 2024-06-05 18:05 | jsantos | Note Added: 0009661 | |
| 2024-06-05 18:05 | jsantos | Status | assigned => resolved |
| 2024-06-05 18:05 | jsantos | Resolution | open => fixed |
| 2024-06-05 18:05 | jsantos | Fixed in Version | => 3.2.4 |