View Issue Details

IDProjectCategoryView StatusLast Update
0002362NoesisGUIC++ SDKpublic2022-11-07 17:13
Reporternikobarli Assigned Tosfernandez  
PrioritynormalSeverityminor 
Status assignedResolutionopen 
Product Version3.1.3 
Target Version3.1.7 
Summary0002362: Please remove NS_ASSERT from Activate/DeactivateWindow inside TSF.cpp
Description

We have several scenarios where the order of Activate/DeactivateWindow is not strictly

Activate wnd1
Deactivate wnd1
Activate wnd2
Deactivate wnd2
Activate wnd3

But

Activate wnd1
Activate wnd2 <- NS_ASSERT thrown inside ActivateWindow
Deactivate wnd2
Deactivate wnd1 <- NS_ASSERT thrown inside DeactivateWindow
Activate wnd3

instead. This especially often happens when wnd2 is a blocking modal dialog (i.e. called with DoModal).

I think the NS_ASSERT is only serving as a warning that a not-typical sequence happened but doesn't have any harm. So I prefer the code to emit WARNING log instead of NS_ASSERT.

I attached the patch in this issue. Could you please apply it in the next release.

Attached Files
TSF.patch (1,111 bytes)   
Index: TSF.cpp
===================================================================
--- TSF.cpp	(revision 160861)
+++ TSF.cpp	(revision 160862)
@@ -1206,7 +1206,9 @@
 void TSF::ActivateWindow(void* hWnd)
 {
     NS_LOG_TRACE("ActivateWindow(hWnd=%p)", hWnd);
-    NS_ASSERT(gCurrentWindow == 0 || gCurrentWindow == hWnd);
+    if (!(gCurrentWindow == 0 || gCurrentWindow == hWnd)) { 
+        NS_LOG_WARNING("TSF::ActivateWindow: failed assertion (gCurrentWindow == 0 || gCurrentWindow == hWnd), gCurrentWindow = 0x%x, hWnd = 0x%x ", gCurrentWindow, hWnd); 
+    }
     gCurrentWindow = (HWND)hWnd;
 
     // NOTE: When hWnd is activated, the associated Noesis View automatically restores keyboard
@@ -1220,7 +1222,9 @@
 void TSF::DeactivateWindow(void* hWnd)
 {
     NS_LOG_TRACE("DeactivateWindow(hWnd=%p)", hWnd);
-    NS_ASSERT(gCurrentWindow == hWnd);
+    if (!(gCurrentWindow == hWnd)) { 
+        NS_LOG_WARNING("TSF::DeactivateWindow: failed assertion (gCurrentWindow == hWnd), gCurrentWindow = 0x%x, hWnd = 0x%x ", gCurrentWindow, hWnd); 
+    }
     gCurrentWindow = 0;
 }
 
TSF.patch (1,111 bytes)   
PlatformAny

Activities

Issue History

Date Modified Username Field Change
2022-06-23 08:31 nikobarli New Issue
2022-06-23 08:31 nikobarli File Added: TSF.patch
2022-06-23 11:23 jsantos Assigned To => sfernandez
2022-06-23 11:23 jsantos Status new => assigned
2022-06-23 11:23 jsantos Target Version => 3.1.5
2022-06-24 17:21 sfernandez Target Version 3.1.5 => 3.1.6
2022-11-07 17:13 sfernandez Target Version 3.1.6 => 3.1.7