Could Not Convert to a bool--why not?  [SOLVED]

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
User avatar
ColleenKobe
Experienced Solver
Experienced Solver
Posts: 88
Joined: Mon Aug 31, 2015 3:47 pm

Could Not Convert to a bool--why not?

Postby ColleenKobe » Tue Jun 26, 2018 5:24 pm

Hi,

I have a very large program written in wxWidgets, C, and C++ for Windows that keeps giving me the execution error message "Could not convert to a bool." See the screen shot below.

Could not convert to bool error.jpg
This message is displayed for about 1.5 seconds, and then it and the window behind it vanish.


The error occurs after execution leaves main.cpp's OnInit. OnInit runs without error. I have traced execution out of OnInit as control returned to init.cpp, line 504, in procedure wxEntryReal. From there, execution hops from file to file, until finally, the error message above is displayed for about 1.5 seconds, and then the whole page vanishes. I was only able to get this screen shot when I stopped execution just before the screen vanished.

Here is the Call Stack when execution stops:

Code: Select all

0  0x66404019  wxDefaultAssertHandler  C:\\wxWidgets\\src\\common\\appbase.cpp  1163
1  0x66404792  wxOnAssert  C:\\wxWidgets\\src\\common\\appbase.cpp  1264
2  0x6648bf75  wxVariant::GetBool  C:\\wxWidgets\\src\\common\\variant.cpp  681
3  0x7095a449  wxDataViewToggleRenderer::SetValue  C:\\wxWidgets\\src\\generic\\datavgen.cpp  1267
4  0x70945770  wxDataViewRendererBase::PrepareForItem  C:\\wxWidgets\\src\\common\\datavcmn.cpp  892
5  0x709e1b29  wxDataViewMaxWidthCalculator::UpdateWithRow  C:\\wxWidgets\\src\\generic\\datavgen.cpp  5469
6  0x709df793  wxMaxWidthCalculatorBase::ComputeBestColumnWidth  C:\\wxWidgets\\include\\wx\\generic\\private\\widthcalc.h  80
7  0x70965273  wxDataViewCtrl::GetBestColumnWidth  C:\\wxWidgets\\src\\generic\\datavgen.cpp  5505
8  0x70959244  wxDataViewColumn::GetWidth  C:\\wxWidgets\\src\\generic\\datavgen.cpp  200
9  0x7095f383  wxDataViewMainWindow::GetEndOfLastCol  C:\\wxWidgets\\src\\generic\\datavgen.cpp  3132
10  0x70963f78  wxDataViewMainWindow::UpdateColumnSizes  C:\\wxWidgets\\src\\generic\\datavgen.cpp  5003
11  0x7095eef7  wxDataViewMainWindow::OnInternalIdle  C:\\wxWidgets\\src\\generic\\datavgen.cpp  3022
12  0x11e7fbcf  wxWindowBase::SendIdleEvents  C:\\wxWidgets\\src\\common\\wincmn.cpp  2828
13  0x11e7fc99  wxWindowBase::SendIdleEvents  C:\\wxWidgets\\src\\common\\wincmn.cpp  2844
14  0x11e7fc99  wxWindowBase::SendIdleEvents  C:\\wxWidgets\\src\\common\\wincmn.cpp  2844
15  0x11dbad85  wxAppBase::ProcessIdle  C:\\wxWidgets\\src\\common\\appcmn.cpp  406
16  0x66429dfb  wxEventLoopBase::ProcessIdle  C:\\wxWidgets\\src\\common\\evtloopcmn.cpp  93
17  0x6642a110  wxEventLoopManual::DoRun  C:\\wxWidgets\\src\\common\\evtloopcmn.cpp  258
18  0x66429cc4  wxEventLoopBase::Run  C:\\wxWidgets\\src\\common\\evtloopcmn.cpp  76
19  0x11fad0e9  wxDialogModalData::RunLoop  C:\\wxWidgets\\src\\msw\\dialog.cpp  62
20  0x11d4fa77  wxDialog::ShowModal  C:\\wxWidgets\\src\\msw\\dialog.cpp  192
21  0x11ea2a8d  wxGenericMessageDialog::ShowModal  C:\\wxWidgets\\src\\generic\\msgdlgg.cpp  275
22  0x11d89474  wxRichMessageDialog::ShowModal  C:\\wxWidgets\\src\\msw\\richmsgdlg.cpp  113
23  0x11dbb030  wxGUIAppTraitsBase::ShowAssertDialog  C:\\wxWidgets\\src\\common\\appcmn.cpp  535
24  0x66404c0e  ShowAssertDialog  C:\\wxWidgets\\src\\common\\appbase.cpp  1386
25  0x66403c22  wxAppConsoleBase::OnAssertFailure  C:\\wxWidgets\\src\\common\\appbase.cpp  869
26  0x66404113  wxDefaultAssertHandler  C:\\wxWidgets\\src\\common\\appbase.cpp  1179
27  0x66404792  wxOnAssert  C:\\wxWidgets\\src\\common\\appbase.cpp  1264
28  0x6648bf75  wxVariant::GetBool  C:\\wxWidgets\\src\\common\\variant.cpp  681
29  0x7095a449  wxDataViewToggleRenderer::SetValue  C:\\wxWidgets\\src\\generic\\datavgen.cpp  1267
30  0x70945770  wxDataViewRendererBase::PrepareForItem  C:\\wxWidgets\\src\\common\\datavcmn.cpp  892
31  0x709e1b29  wxDataViewMaxWidthCalculator::UpdateWithRow  C:\\wxWidgets\\src\\generic\\datavgen.cpp  5469
32  0x709df793  wxMaxWidthCalculatorBase::ComputeBestColumnWidth  C:\\wxWidgets\\include\\wx\\generic\\private\\widthcalc.h  80
33  0x70965273  wxDataViewCtrl::GetBestColumnWidth  C:\\wxWidgets\\src\\generic\\datavgen.cpp  5505
34  0x70959244  wxDataViewColumn::GetWidth  C:\\wxWidgets\\src\\generic\\datavgen.cpp  200
35  0x11d599d7  wxHeaderCtrl::DoInsertItem  C:\\wxWidgets\\src\\msw\\headerctrl.cpp  380
36  0x11d59485  wxHeaderCtrl::DoUpdate  C:\\wxWidgets\\src\\msw\\headerctrl.cpp  295
37  0x709cdb17  wxHeaderCtrlBase::UpdateColumn  C:\\wxWidgets\\include\\wx\\headerctrl.h  94
38  0x709655fa  wxDataViewCtrl::UpdateColWidths  C:\\wxWidgets\\src\\generic\\datavgen.cpp  5593
39  0x70965651  wxDataViewCtrl::OnInternalIdle  C:\\wxWidgets\\src\\generic\\datavgen.cpp  5604
40  0x11e7fbcf  wxWindowBase::SendIdleEvents  C:\\wxWidgets\\src\\common\\wincmn.cpp  2828
41  0x11e7fc99  wxWindowBase::SendIdleEvents  C:\\wxWidgets\\src\\common\\wincmn.cpp  2844
42  0x11dbad85  wxAppBase::ProcessIdle  C:\\wxWidgets\\src\\common\\appcmn.cpp  406
43  0x66429dfb  wxEventLoopBase::ProcessIdle  C:\\wxWidgets\\src\\common\\evtloopcmn.cpp  93
44  0x6642a110  wxEventLoopManual::DoRun  C:\\wxWidgets\\src\\common\\evtloopcmn.cpp  258
45  0x66429cc4  wxEventLoopBase::Run  C:\\wxWidgets\\src\\common\\evtloopcmn.cpp  76
46  0x66402b7d  wxAppConsoleBase::MainLoop  C:\\wxWidgets\\src\\common\\appbase.cpp  380
47  0x66402906  wxAppConsoleBase::OnRun  C:\\wxWidgets\\src\\common\\appbase.cpp  301
48  0x11dbaae6  wxAppBase::OnRun  C:\\wxWidgets\\src\\common\\appcmn.cpp  335
49  0x6644fa63  wxEntryReal  C:\\wxWidgets\\src\\common\\init.cpp  507
50  0x664d04b0  wxEntry  C:\\wxWidgets\\src\\msw\\main.cpp  193
51  0x11cb6e00  wxEntry  C:\\wxWidgets\\src\\msw\\main.cpp  305
52  0x0043967d  WinMain@16  F:\\Prototypes_wxw\\SBIR_Phase_II_A\\Main\\main.cpp  424
53  0x0044e3b4  main

I do not understand any of what wxWidgets is doing once it leaves OnInit.

If it matters, here is my main.cpp. I inserted numbers at the beginning of each line for reference.

Code: Select all

  1. // *****************************************************************************
  2. // *                              m a i n . c p p
  3. // *
  4. // *  Programmer:   Colleen Kobe
  5. // *  Project:      tbd
  6. // *  Date:         July 11, 2017
  7. // *    Revised:    tbd
  8. // *  Description:  This C file contains tbd
  9. // *                memory within the tbd project....
 10. // *
 11. // *  Copyright:    (c) 2017 Infrared Technologies
 12. // *****************************************************************************
 13.
 14. // =============================================================================
 15. //                       External Header Files to Include
 16. // =============================================================================
 17. #include <stdio.h>                      //  1 a
 18. #include <cstddef>                      //  1 c1b   Must precede stddef.h
 19. #include <stddef.h>                     //  1 c2    Must follow cstddef, if cstddef is needed.
 20. #include "gd_bkgd.h"                    //  3 a-1
 21. #include "gd_bts.h"                     //  3 a-2
 22. #include "ut_bts.h"                     //  3 i
 23. #include "H03.h"                        //  4
 24. #include "H0C.h"                        //  4
 25. #include "H0F.h"                        //  4
 26. #include "H30.h"                        //  4
 27. #include "HC0.h"                        //  4
 28. #include "hw_int_usb_3_0.h"             //  4
 29. #include "P04.h"                        //  4
 30. #include "P040n.h"                      //  4
 31. #include "P05.h"                        //  4
 32. #include "P06.h"                        //  4
 33. #include "P07.h"                        //  4
 34. #include "P08.h"                        //  4
 35. #include "threads.h"                    //  4
 36. #include "Eq_Digital_Count_Class.h"     //  5 c-2
 37. #include "Eq_Linear_Class.h"            //  5 d-2
 38. #include "Eq_Polynomial_Class.h"        //  5 e-2
 39. #include "Eq_Thermocouple_Class.h"      //  5 f-2
 40. #include "fio.h"                        //  5 g-2
 41. #include "INI_File_Class.h"             //  5 h-2
 42. #include "MainFrame_Class.h"            //  5 i-2
 43. #include "Wrapper.h"                    //  5 w
 44. #include <wx/wx.h>                      //  5 y
 45. #include <wx/app.h>                     //  6
 46. #include <wx/msgdlg.h>                  //  6
 47.
 48. // class     Eq_Digital_Count_Class;       //  5 c-1
 49. // class     Eq_Linear_Class;              //  5 d-1
 50. // class     Eq_Polynomial_Class;          //  5 e-1
 51. // class     Eq_Thermocouple_Class;        //  5 f-1
 52. // class     fio;                          //  5 g-1
 53. // class     INI_File_Class;               //  5 h-1
 54. // class     MainFrame_Class;              //  5 i-1
 55.
 56. // =============================================================================
 57. //                       Constants Global Within This File
 58. // =============================================================================
 59.
 60. //  tbd
 61.
 62. // =============================================================================
 63. //                         Types Public Within This File
 64. // =============================================================================
 65.
 66. //  tbd
 67.
 68. // =============================================================================
 69. //                         Variables Local to This File
 70. // =============================================================================
 71.
 72. // -----------------------------------------------------------------------------
 73. //  Pointers to Other Classes
 74. // -----------------------------------------------------------------------------
 75. Eq_Digital_Count_Class  * Main_eqDC_Ptr;
 76. Eq_Linear_Class         * Main_eqLi_Ptr;
 77. Eq_Polynomial_Class     * Main_eqPo_Ptr;
 78. Eq_Thermocouple_Class   * Main_eqTc_Ptr;
 79. fio_Class               * Main_fio_Ptr;
 80. INI_File_Class          * Main_INI_Ptr;
 81. MainFrame_Class         * Main_MF_Ptr;
 82. Settings_Class          * Main_SC_Ptr;
 83. Settings_Class          * Main_Wr_Ptr;
 84. ut_gui_Class            * Main_ut_gui_Ptr;
 85.
 86. wxFileDialog            * Main_CSV_File_Ptr;
 87. wxFileDialog            * Main_INI_File_Ptr;
 88. wxFileDialog            * Main_PRM_File_Ptr;
 89.
 90. // =============================================================================
 91. //                        Prototypes (forward references)
 92. //         for local procedures and functions residing inside this file
 93. //  that are ONLY called by procedures and functions residing inside this file
 94. // =============================================================================
 95.
 96. // tbd
 97.
 98. // =============================================================================
 99. //                              Class Declarations
100. // =============================================================================
101.
102. // +---------------------------------------------------------------------------+
103. // |                               M a i n A p p                               |
104. // |                                                                           |
105. // |  Description:  This is the constructor for IRT SBIR Phase II.             |
106. // +---------------------------------------------------------------------------+
107. class MainApp : public wxApp
108. {
109. public:
110.     MainApp ()
111. {
112.     int i = 0;
113.     wxMessageBox ("We are in MainApp's constructor.", "Initialize", wxICON_INFORMATION);
114.
115.     i = i + 1;
116. }   // MainApp
117.
118. // +---------------------------------------------------------------------------+
119. // |                              ~ M a i n A p p                              |
120. // |                                                                           |
121. // |  Description:  This is the destructor for IRT SBIR Phase II.              |
122. // +---------------------------------------------------------------------------+
123.     virtual ~MainApp ()
124. {
125.     wxMessageBox ("We are in MainApp's destructor.", "Terminate", wxICON_INFORMATION);
126.
127.     Main_Terminate();
128.
129. }   // ~MainApp
130.
131. // -----------------------------------------------------------------------------
132. //                         Main_Terminate
133. //
134. //    Description:  This procedure is called only once, on program exit.
135. // -----------------------------------------------------------------------------
136.
137. void Main_Terminate ()
138. {
139.
140.     Int16   rc_from_H03_Terminate;
141.     Int16   rc_from_H0C_Terminate;
142.     Int16   rc_from_H0F_Terminate;
143.     Int16   rc_from_H30_Terminate;
144.     Int16   rc_from_HC0_Terminate;
145.
146.     Int16   rc_from_P04_Terminate;
147.     Int16   rc_from_P05_Terminate;
148.     Int16   rc_from_P08_Terminate;
149.
150.     Int16   rc_Total;
151.
152. //     wxMessageBox ("We are in MainApp's Main_Terminate.", "Terminate", wxICON_INFORMATION);
153.
154.     rc_from_H03_Terminate   = H03_Terminate ();
155.     rc_from_H0C_Terminate   = H0C_Terminate ();
156.     rc_from_H0F_Terminate   = H0F_Terminate ();
157.     rc_from_H30_Terminate   = H30_Terminate ();
158.     rc_from_HC0_Terminate   = HC0_Terminate ();
159.
160.     rc_from_P04_Terminate   = P04_Terminate ();
161.     rc_from_P05_Terminate   = P05_Terminate ();
162.     P06_Terminate ();
163.     P07_Terminate ();
164.     rc_from_P08_Terminate   = P08_Terminate ();
165.
166.     rc_Total    = rc_from_H03_Terminate   +
167.                   rc_from_H0C_Terminate   +
168.                   rc_from_H0F_Terminate   +
169.                   rc_from_H30_Terminate   +
170.                   rc_from_HC0_Terminate   +
171.
172.                   rc_from_P04_Terminate   +
173.                   rc_from_P05_Terminate   +
174.                   rc_from_P08_Terminate;
175.
176.
177.     printf  ("Main_Terminate total errors: %d.\n\n", rc_Total);
178.
179.
180.     // -------------------------------------------------------------------------
181.     //  Regarding the class pointers we "new"ed during initialization.  During
182.     //  initialization, we sent each class the addresses of the others.
183.     //
184.     //  xx_Set_CSV_File_Ptr, xx_Set_INI_File_Ptr, and xx_fio_Set_ut_gui_Ptr will
185.     //  all be set to nullptr in their respective destructor procedures.  So we
186.     //  do not set their values to nullptr here.
187.     // -------------------------------------------------------------------------
188.
189.     // -------------------------------------------------------------------------
190.     //  Set 'em all to nullptr so that they don't hurt anything.
191.     // -------------------------------------------------------------------------
192.     Main_eqDC_Ptr       = nullptr;
193.     Main_eqLi_Ptr       = nullptr;
194.     Main_eqPo_Ptr       = nullptr;
195.     Main_eqTc_Ptr       = nullptr;
196.     Main_fio_Ptr        = nullptr;
197.     Main_INI_Ptr        = nullptr;
198.     Main_MF_Ptr         = nullptr;
199.     Main_SC_Ptr         = nullptr;
200.     Main_Wr_Ptr         = nullptr;
201.     Main_ut_gui_Ptr     = nullptr;
202.
203.     Main_CSV_File_Ptr   = nullptr;
204.     Main_INI_File_Ptr   = nullptr;
205.     Main_PRM_File_Ptr   = nullptr;
206.
207.     // -------------------------------------------------------------------------
208.     //  We created the pointers in OnInit.  We destroy them here.
209.     // -------------------------------------------------------------------------
210.     delete Main_eqDC_Ptr;
211.     delete Main_eqLi_Ptr;
212.     delete Main_eqPo_Ptr;
213.     delete Main_eqTc_Ptr;
214.     delete Main_MF_Ptr;
215.     delete Main_SC_Ptr;
216.     delete Main_Wr_Ptr;
217.     delete Main_ut_gui_Ptr;
218.
219.     delete Main_CSV_File_Ptr;
220.     delete Main_INI_File_Ptr;
221.     delete Main_PRM_File_Ptr;
222.
223. }   // Main_Terminate
224.
225. // -----------------------------------------------------------------------------
226. //                                  O n I n i t
227. //
228. //    Description:  This procedure is called only once, on initial program
229. //                  entry.
230. // -----------------------------------------------------------------------------
231.
232. virtual bool OnInit ()
233. {
234.     Int16   rc  = 0;
235.     bool    rc_bool = false;
236.
237.     wxWindow * eqDC_parent  = nullptr;
238.     wxWindow * eqLi_parent  = nullptr;
239.     wxWindow * eqPo_parent  = nullptr;
240.     wxWindow * eqTc_parent  = nullptr;
241.     wxWindow * MF_parent    = nullptr;
242.     wxWindow * SC_parent    = nullptr;
243.
244.     // Add the common image handlers
245.     wxImage::AddHandler ( new wxPNGHandler );
246.     wxImage::AddHandler ( new wxJPEGHandler );
247.
248.     // -------------------------------------------------------------------------
249.     //  Create one copy of all classes used globally.  When the program exits,
250.     //  we delete these pointers in OnExit.
251.     // -------------------------------------------------------------------------
252.     Main_eqDC_Ptr       = new Eq_Digital_Count_Class    (eqDC_parent);
253.     Main_eqLi_Ptr       = new Eq_Linear_Class           (eqLi_parent);
254.     Main_eqPo_Ptr       = new Eq_Polynomial_Class       (eqPo_parent);
255.     Main_eqTc_Ptr       = new Eq_Thermocouple_Class     (eqTc_parent);
256.     Main_fio_Ptr        = new fio_Class                 ();
257.     Main_INI_Ptr        = new INI_File_Class            ();
258.     Main_MF_Ptr         = new MainFrame_Class           (MF_parent);
259.     Main_SC_Ptr         = new Settings_Class            (SC_parent);
260.     Main_Wr_Ptr         = new Settings_Class            (SC_parent);
261.     Main_ut_gui_Ptr     = new ut_gui_Class              ();
262.
263.     Main_CSV_File_Ptr   = new wxFileDialog  (NULL);
264.     Main_INI_File_Ptr   = new wxFileDialog  (NULL);
265.     Main_PRM_File_Ptr   = new wxFileDialog  (NULL);
266.
267.     // -------------------------------------------------------------------------
268.     //  Up here, very early, first thing:  set the global destination for output
269.     //  statements.  This is the only place to set ut_bts_STDOUT.
270.     //
271.     //  Here are your choices:
272.     // -------------------------------------------------------------------------
273. #define ut_bts_TO_DEBUG_FILE  0
274. #define ut_bts_TO_DEBUGVIEW   1
275. #define ut_bts_TO_DOS         2
276. #define ut_bts_TO_MESSAGEBOX  3
277.
278.     // -------------------------------------------------------------------------
279. //     Main_ut_bts_Ptr->Set_ut_bts_STDOUT ((UInt16) ut_bts_TO_DEBUG_FILE);
280.     ut_bts_Create_and_Open_Debug_Filename ();
281.     Set_ut_bts_STDOUT ((UInt16) ut_bts_TO_DEBUG_FILE);
282.
283.     // -------------------------------------------------------------------------
284.     // Send each class the addresses of the others.  All classes will reference
285.     // each other.
286.     // -------------------------------------------------------------------------
287.
288.     // ====================================================
289.     // Initialize this one all-important file.
290.     // ====================================================
291.     rc = gd_bts_Initialize   ();
292.     rc = gd_bkgd_Initialize  ();
293.
294.     // ====================================================
295.     //       Define the Local Ptrs in MainFrame_Class (mf).
296.     // ====================================================
297.     Main_MF_Ptr->mf_Set_fio_Ptr         (Main_fio_Ptr);
298.     Main_MF_Ptr->mf_Set_MF_Ptr          (Main_MF_Ptr);
299.     Main_MF_Ptr->mf_Set_SC_Ptr          (Main_SC_Ptr);
300.     Main_MF_Ptr->mf_Set_ut_gui_Ptr      (Main_ut_gui_Ptr);
301.     Main_MF_Ptr->mf_Set_Wr_Ptr          (Main_Wr_Ptr);
302.
303.     // ====================================================
304.     //    Define the Local Ptrs in Settings_Class (SC).
305.     // ====================================================
306.     Main_SC_Ptr->sc_Set_eqDC_Ptr        (Main_eqDC_Ptr);
307.     Main_SC_Ptr->sc_Set_eqLi_Ptr        (Main_eqLi_Ptr);
308.     Main_SC_Ptr->sc_Set_eqPo_Ptr        (Main_eqPo_Ptr);
309.     Main_SC_Ptr->sc_Set_eqTc_Ptr        (Main_eqTc_Ptr);
310.     Main_SC_Ptr->sc_Set_fio_Ptr         (Main_fio_Ptr);
311.     Main_SC_Ptr->sc_Set_INI_Ptr         (Main_INI_Ptr);
312.     Main_SC_Ptr->sc_Set_MF_Ptr          (Main_MF_Ptr);
313.     Main_SC_Ptr->sc_Set_SC_Ptr          (Main_SC_Ptr);
314.     Main_SC_Ptr->sc_Set_ut_gui_Ptr      (Main_ut_gui_Ptr);
315.     Main_SC_Ptr->sc_Set_Wr_Ptr          (Main_Wr_Ptr);
316.
317.     // ====================================================
318.     //     Define the Local Ptrs in INI_File_Class (ini).
319.     // ====================================================
320.     Main_INI_Ptr->ini_Set_eqDC_Ptr      (Main_eqDC_Ptr);
321.     Main_INI_Ptr->ini_Set_eqLi_Ptr      (Main_eqLi_Ptr);
322.     Main_INI_Ptr->ini_Set_eqPo_Ptr      (Main_eqPo_Ptr);
323.     Main_INI_Ptr->ini_Set_eqTc_Ptr      (Main_eqTc_Ptr);
324.     Main_INI_Ptr->ini_Set_INI_Ptr       (Main_INI_Ptr);
325.     Main_INI_Ptr->ini_Set_MF_Ptr        (Main_MF_Ptr);
326.     Main_INI_Ptr->ini_Set_SC_Ptr        (Main_SC_Ptr);
327.     Main_INI_Ptr->ini_Set_ut_gui_Ptr    (Main_ut_gui_Ptr);
328.
329.     // ====================================================
330.     //       Define the Local Ptrs in File I/O (fio).
331.     // ====================================================
332.     Main_fio_Ptr->fio_Set_fio_Ptr       (Main_fio_Ptr);
333.     Main_fio_Ptr->fio_Set_ut_gui_Ptr    (Main_ut_gui_Ptr);
334.
335.     // ====================================================
336.     //   Define the Local Ptrs in Equation Digital_Count (eqDC).
337.     // ====================================================
338.     Main_eqDC_Ptr->eqd_Set_eqDC_Ptr     (Main_eqDC_Ptr);
339.     Main_eqDC_Ptr->eqd_Set_SC_Ptr       (Main_SC_Ptr);
340.     Main_eqDC_Ptr->eqd_Set_ut_gui_Ptr   (Main_ut_gui_Ptr);
341.
342.     // ====================================================
343.     //   Define the Local Ptrs in Equation Linear (eqLi).
344.     // ====================================================
345.     Main_eqLi_Ptr->eql_Set_eqLi_Ptr     (Main_eqLi_Ptr);
346.     Main_eqLi_Ptr->eql_Set_SC_Ptr       (Main_SC_Ptr);
347.     Main_eqLi_Ptr->eql_Set_ut_gui_Ptr   (Main_ut_gui_Ptr);
348.
349.     // ====================================================
350.     // Define the Local Ptrs in Equation Polynomial (eqPo).
351.     // ====================================================
352.     Main_eqPo_Ptr->eqp_Set_eqPo_Ptr     (Main_eqPo_Ptr);
353.     Main_eqPo_Ptr->eqp_Set_SC_Ptr       (Main_SC_Ptr);
354.     Main_eqPo_Ptr->eqp_Set_ut_gui_Ptr   (Main_ut_gui_Ptr);
355.
356.     // ====================================================
357.     //   Define the Local Ptrs in Equation Thermocouple (eqTc).
358.     // ====================================================
359.     Main_eqTc_Ptr->eqt_Set_eqTc_Ptr     (Main_eqTc_Ptr);
360.     Main_eqTc_Ptr->eqt_Set_SC_Ptr       (Main_SC_Ptr);
361.     Main_eqTc_Ptr->eqt_Set_ut_gui_Ptr   (Main_ut_gui_Ptr);
362.
363.     // ====================================================
364.     //    Define the Local Ptrs in GUI Utility (ut_gui).
365.     // ====================================================
366.     Main_ut_gui_Ptr->ut_gui_Set_ut_gui_Ptr  (Main_ut_gui_Ptr);
367. //     Main_ut_gui_Ptr->ut_gui_Set_SC_Ptr      (Main_SC_Ptr);
368. //     Main_ut_gui_Ptr->ut_gui_Set_Wr_Ptr      (Main_Wr_Ptr);
369.
370.     // -------------------------------------------------------------------------
371.     // Call the initialization procedure of the classes that have one.
372.     // -------------------------------------------------------------------------
373.     Main_MF_Ptr->mf_Initialize          ();                                     // MainFrame_Class must be second.
374.     Main_SC_Ptr->sc_Initialize          (gd_bkgd_INITIALIZE_WITH_SAMPLE_DATA);   // Settings_Class is next.
375.     Main_ut_gui_Ptr->ut_gui_Initialize  ();                                     // GUI Utilities is last.
376.
377.     // Call the initialization procedures in the irt_bts.dll.
378.
379.     rc = 0;
380.     rc += H03_Initialize    ();
381.     rc += H0C_Initialize    ();
382.     rc += H0F_Initialize    ();
383.     rc += H30_Initialize    ();
384.     rc += HC0_Initialize    ();
385.     rc += hw_Initialize     ();
386.     rc += P04_Initialize    ();
387.     rc += P05_Initialize    ();
388.     P06_Initialize();
389.     P07_Initialize();
390.     rc += P08_Initialize    ();
391.     rc += P040n_Initialize  ();
392.     rc += thrd_Initialize   ();
393.     rc += ut_bts_Initialize ();
394.
395.     // -------------------------------------------------------------------------
396.     //  Set an initial group of filenames.  These are just initial values;
397.     //  there's nothing magic about the names.  Change them to something else if
398.     //  you want to.  They just needed to be something other than nulls.
399.     // -------------------------------------------------------------------------
400.     Main_PRM_File_Ptr->SetDirectory ("C:\\temp\\");
401.     Main_PRM_File_Ptr->SetFilename  ("default.cfa");
402.
403.     Main_CSV_File_Ptr->SetDirectory ("C:\\temp\\");
404.     Main_CSV_File_Ptr->SetFilename  ("default.csv");
405.
406.     Main_INI_File_Ptr->SetDirectory ("C:\\temp\\");
407.     Main_INI_File_Ptr->SetFilename  ("default.ini");
408.
409.     // Finally, set MainFrame_Class as the top page.
410.     SetTopWindow    (Main_MF_Ptr);
411.
412.     if (GetTopWindow ()->Show () == true)
413.         rc_bool = true;
414.     else
415.         rc_bool = false;
416.
417.     return (rc_bool);
418.
419. }   // OnInit
420.
421. };
422.
423. DECLARE_APP(MainApp)
424. IMPLEMENT_APP(MainApp)
425.

I have two questions.

1. Under what circumstances would a value not be convertible into a boolean? Wouldn't a value just be 0 or 1, based on the final bit in the word?

2. The title bar in the error message says, "wxWidgets Debug Alert." Is there any way I can turn that off? And if so, how? Maybe whatever I'm doing wrong will be clearer if I can see what error that message is preventing.

IDE Configuration:

Windows 10, 64-bit computer
CodeLite 12.0.3
wxWidgets 3.1.1
MinGW on https://sourceforge.net/projects/mingw/ (I don't see a version number)

I just compiled wxWidgets this morning (2018-06-26) using the following file:

Code: Select all

rem   Build-wxW.bat
rem   June 25, 2018
rem   Colleen Kobe
rem
rem   This batch file builds wxWidgets version 3.0.4 using MinGW 8.1.0.  It
rem   builds a DLL under \lib\gcc_dll.  The resultant setup.h file can be
rem   found under \lib\gcc_dll\mswu\wx
rem
rem   I got the directions from
rem   https://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW
rem
rem   although I added the builds for a debug version myself.
rem
rem   You should only need to do this once, after downloading either wxWidgets
rem   or MinGW.
rem ----------------------------------------------------------------------------

C:
cd    C:\wxWidgets\build\msw

rem   Make sure the make file program is in the system path.
path=C:\MinGW\bin;%path%

rem   Display the system variables for future reference.

set

rem  Note: when I compiled with the UNICODE=1 option, later, when I tried to
rem  compile my programs, I got a ton of errors in the built-in windef.h and
rem  other standard header files.  No thanks.  No UNICODE for me.
rem
rem  111111111111111111111111111111111111111111111111111111111111111111111111111
rem   Clean up the release build.
rem don't want unicodel imingw32-make -f makefile.gcc SHARED=1 UNICODE=0 BUILD=release clean
mingw32-make -f makefile.gcc SHARED=1 BUILD=release clean

rem  222222222222222222222222222222222222222222222222222222222222222222222222222
rem   Then, compile the library.
rem  mingw32-make -f makefile.gcc SHARED=1 UNICODE=0 BUILD=release
mingw32-make -f makefile.gcc SHARED=1 BUILD=release

rem  333333333333333333333333333333333333333333333333333333333333333333333333333
rem   Clean up the debug build.
rem   mingw32-make -f makefile.gcc SHARED=1 UNICODE=0 BUILD=debug clean
mingw32-make -f makefile.gcc SHARED=1 BUILD=debug clean

rem  444444444444444444444444444444444444444444444444444444444444444444444444444
rem   Then, compile the library.
rem mingw32-make -f makefile.gcc SHARED=1 UNICODE=0 BUILD=debug
mingw32-make -f makefile.gcc SHARED=1 BUILD=debug

echo **************************************************************************
echo Done!


One last data point: my coding was going great, up until Wednesday, June 6. There were many Microsoft updates that morning, but I didn't realize that they could possibly have been the source of my problems until later. I'm not saying they are. I'm saying they could be.

I have tried using the most recent "stable" version for CodeLite, wxWidgets, and MinGW, but the problem is always there. So I upgraded to the latest-and-greatest of each.

Thoughts? Suggestions? I've struggled with this problem and variations of it for three weeks now. If it's not one problem, it's another. I have tried at least 24 "fixes" that worked for others but haven't worked for me. My last resort is to start completely over from scratch: creating a workspace and four projects, adding file after file, rebuilding as I go, until I get to the point where the errors crop up again. But that's very hard, too, because everything is so intertwined. :-(

Thanks.
Colleen

Manolo
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 589
Joined: Mon Apr 30, 2012 11:07 pm

Re: Could Not Convert to a bool--why not?  [SOLVED]

Postby Manolo » Tue Jun 26, 2018 5:54 pm

Your stack tells that the issue comes from wxDataViewToggleRenderer. Likely some setter/getter is not used properly.

Compare your code with the dataview sample. Or post that related code here if anything else fails :wink:
wxDVC is hard. Be patient and persistent and you'll get the cause of your issue.

User avatar
doublemax
Moderator
Moderator
Posts: 12681
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Could Not Convert to a bool--why not?

Postby doublemax » Tue Jun 26, 2018 6:57 pm

Under what circumstances would a value not be convertible into a boolean? Wouldn't a value just be 0 or 1, based on the final bit in the word?
This is not a "normal" conversion like a cast at C++ level. wxDataViewCtrl uses wxAny, a type that can contain any value (like bool, int, string). It can be converted to bool, if it contains a bool, int, long, double or if it's a string and it contains one of the values "0", "1", "yes", "no", "true", "false". In all other cases the conversion will fail and you get that assert.

2. The title bar in the error message says, "wxWidgets Debug Alert." Is there any way I can turn that off? And if so, how? Maybe whatever I'm doing wrong will be clearer if I can see what error that message is preventing.
On the contrary, in most cases this assert will tell you exactly where the problem is.

However, in this case it's very strange that the whole call stack is inside wxWidgets code and not in your code. I can only assume that you have an incomplete wxDataViewCtrl instance somewhere. But the code you posted has no wxDataViewCtrl at all, so check the places where you use one.
Use the source, Luke!

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1707
Joined: Sun Jan 03, 2010 5:45 pm

Re: Could Not Convert to a bool--why not?

Postby PB » Tue Jun 26, 2018 7:13 pm

doublemax wrote:wxDataViewCtrl uses wxAny, a type that can contain any value (like bool, int, string).

I admit I never used the class but from the assert message, stack trace, and the docs I would say wxDataViewCtrl actually uses wxVariant:
docs.wxwidgets.org wrote:All data transfer from the control to the model and the user code is done through wxVariant which can be extended to support more data formats as necessary. Accordingly, all type information uses the strings returned from wxVariant::GetType.


I do agree that from the stack trace it seems you are somehow wronlgy creating wxDataViewCtrl instance.

TBH, to me, the code posted seems as if it were run through an obfuscator so I could not find (didn't really try hard) anything there.

However I believe I discovered a bunch of bugs (unrelated to the issue ITT) in function Main_Terminate(). As I do not understand what the code does, I have no idea whether they are harmless or not.
First you set a group of pointers you new()ed to null

Code: Select all

189.     // -------------------------------------------------------------------------
190.     //  Set 'em all to nullptr so that they don't hurt anything.
191.     // -------------------------------------------------------------------------
192.     Main_eqDC_Ptr       = nullptr;
193.     Main_eqLi_Ptr       = nullptr;
194.     Main_eqPo_Ptr       = nullptr;
195.     Main_eqTc_Ptr       = nullptr;
196.     Main_fio_Ptr        = nullptr;
197.     Main_INI_Ptr        = nullptr;
198.     Main_MF_Ptr         = nullptr;
199.     Main_SC_Ptr         = nullptr;
200.     Main_Wr_Ptr         = nullptr;
201.     Main_ut_gui_Ptr     = nullptr;
202.
203.     Main_CSV_File_Ptr   = nullptr;
204.     Main_INI_File_Ptr   = nullptr;
205.     Main_PRM_File_Ptr   = nullptr;

but then you have

Code: Select all

207.     // -------------------------------------------------------------------------
208.     //  We created the pointers in OnInit.  We destroy them here.
209.     // -------------------------------------------------------------------------
210.     delete Main_eqDC_Ptr;
211.     delete Main_eqLi_Ptr;
212.     delete Main_eqPo_Ptr;
213.     delete Main_eqTc_Ptr;
214.     delete Main_MF_Ptr;
215.     delete Main_SC_Ptr;
216.     delete Main_Wr_Ptr;
217.     delete Main_ut_gui_Ptr;
218.
219.     delete Main_CSV_File_Ptr;
220.     delete Main_INI_File_Ptr;
221.     delete Main_PRM_File_Ptr;

This does not make sense to me, if you set the pointers to nullptr, then deleting them does nothing and it means the destructors for those objects are not getting called? But perhaps they are deleted from somewhere else and all the quoted code above is just useless (just as e.g. all those assignments to the rc variable in the OnInit()) but not actually harmful.

User avatar
ColleenKobe
Experienced Solver
Experienced Solver
Posts: 88
Joined: Mon Aug 31, 2015 3:47 pm

Re: Could Not Convert to a bool--why not?

Postby ColleenKobe » Tue Jun 26, 2018 7:45 pm

@Manolo and doublemax,

O M G!!!

LIFE IS GOOD AGAIN!

You were both right--I had two boolean values that were supposed to be displayed in wxDataViewListCtrl checkboxes, but I was sending in UInt16s. I changed their values to be explicitly booleans, and now everything works again. I don't know why they used to work, but I don't care. They work now and I'm a little bit wiser. :-D

Thank you so much for pointing me in the right direction!

// -----------------------------------------------------------------------------

@PB--I agree with you, I don't know why I had to do all that either. I was copying an example I saw on the Internet. You are also right, I was getting memory leaks when I closed the program and I didn't know where or why. So thank you for catching this!

The goal here is to do proper memory housekeeping, to release the memory at the end of the program so it can be used later. The only place I create and delete pointers is here in main.cpp.

So, is the proper thing to do is delete lines 192-201, which set the pointers to nulls? And leave the "delete pointer" lines 210-217 in?

Colleen

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1707
Joined: Sun Jan 03, 2010 5:45 pm

Re: Could Not Convert to a bool--why not?

Postby PB » Tue Jun 26, 2018 7:59 pm

Regarding the pointers, I believe that generally the best way is to use smart pointers instead of deleting raw ones manually, which is both tedious and error-prone.

If for some reason you cannot, you need to delete them by yourself and then you should do what you suggested, i.e., remove the code which sets the pointers to null.

BTW, AFAIK, the main problem with not deleting those pointers is not that the memory is leaked, the memory allocated on the heap is reclaimed by Windows when the process shuts down. The problem is that the destructors for those instances are not getting called and they may contain code which needs to be executed.

User avatar
ColleenKobe
Experienced Solver
Experienced Solver
Posts: 88
Joined: Mon Aug 31, 2015 3:47 pm

Re: Could Not Convert to a bool--why not?

Postby ColleenKobe » Wed Jun 27, 2018 12:06 pm

@PB--thank you for the suggestion about smart pointers. I had never heard of them, so they will be a new tool in my software toolbox.

Regarding not executing destructor code--that's a good point. I'll go over what I have for now, destructor-wise, and verify I'm not missing executing something there.

Many thanks again.
Colleen


Return to “C++ Development”

Who is online

Users browsing this forum: Bing [Bot] and 16 guests