[ListBrowser] error: dereferencing pointer to incomplete type [Solved]

30 posts / 0 new
Last post
Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
[ListBrowser] error: dereferencing pointer to incomplete type [Solved]

As the title says, i have this error and I don't know what is wrong, it is more a c error than an amiga error but i don't know how to fix it.. here is my code. I am trying to create a simple window with a two column listbrowser gadget.. May you help me please?

  1. /*****************************************************/
  2. /* */
  3. /* PER COMPILARE: */
  4. /* */
  5. /* gcc -o lb list_browser.c */
  6. /* */
  7. /*****************************************************/
  8.  
  9. #include <stdio.h> // standard inputoutput c library
  10. #include <proto/exec.h> // exec library
  11. #include <proto/dos.h> // dos library
  12. #include <proto/intuition.h> // intuition library
  13. #include <intuition/gui.h>
  14.  
  15. #include <classes/window.h> // Window class per oop boopsi window
  16. #include <gadgets/button.h> // Button gadget per bottoni finestra
  17. #include <gadgets/layout.h> // Layout gadget per disposizione oggetti in finestra
  18. #include <gadgets/listbrowser.h> // ListBrowser gadget per visualizzare elenchi liste
  19.  
  20. struct ClassLibrary *WindowBase; // WindowBase pointer per accedere all'interfaccia della windows class
  21. Class *WindowClass; // Window class pointer per accedere alle funzioni della window class
  22.  
  23. struct ClassLibrary *LayoutBase; // LayoutBase pointer per accedere alla layoutbase
  24. Class *LayoutClass; // LayoutClass pointer per accedere alle funzioni della LayoutClass
  25.  
  26. struct ClassLibrary *ButtonBase; // ButtonBase pointer per accedere alla ButtonClass interface
  27. Class *ButtonClass; // ButtonClass pointer per accedere alle funzioni della Button Class
  28.  
  29. struct ClassLibrary *ListBrowserBase; // ListBrowserBase
  30. Class *ListBrowserClass; // ListBrowserClass
  31. struct ListBrowserIFace *IListBrowser = NULL;
  32.  
  33. struct Library *IntuitionBase = NULL; // IntuitionBase pointer per accedere alla libreria Intuition
  34. struct IntuitionIFace *IIntuition = NULL; // IIntuition pointer per accedere alle funzioni della libreria Intuition tramite la sua interfaccia
  35.  
  36. struct List listbrowser_list;
  37. struct ColumnInfo *column_info = NULL;
  38.  
  39. enum{
  40. OID_FINESTRA,
  41. OID_LAYOUT_1,
  42. OID_LAYOUT_2,
  43. OID_LISTBROWSER,
  44. OID_LAST
  45. };
  46.  
  47. Object *objects[OID_LAST]; // indichiamo la grandezza del nostro puntatore di tipo Object
  48.  
  49. static const char USED minstack[]="$STACK:80000"; // indichiamo il minimo di memoria richiesta per eseguire il nostro programma
  50.  
  51. /* ELEMENTI LISTBROWSER: */
  52.  
  53. uint32 tagdatas[2];
  54.  
  55. int32 tags[] = {
  56. GUIA_ScreenDragging,
  57. GUIA_OffScreenDragging
  58. };
  59.  
  60. STRPTR list_strings[] = {
  61. "GUIA_ScreenDragging",
  62. "GUIA_OffScreenDragging",
  63. NULL
  64. };
  65.  
  66. BOOL make_browserlist(struct List *, char **, uint32 *);
  67.  
  68. /* FINE ELEMENTI LISTBROWSER */
  69.  
  70. int main(){
  71.  
  72.  
  73. IntuitionBase = IExec->OpenLibrary("intuition.library", 52);
  74. if(IntuitionBase == NULL){
  75. IDOS->Printf("Impossibile ottenere IntuitionBase pointer, impossibile aprire la libreria\n");
  76. }else{
  77. IDOS->Printf("\nIntuitionBase pointer ottenuto, libreria aperta correttamente\n");
  78. }
  79. IIntuition = (struct IntuitionIFace *)IExec->GetInterface(IntuitionBase,"main",1,NULL);
  80. if(IIntuition == NULL){
  81. IDOS->Printf("Impossibile ottenere Intuition Interface\n");
  82. return(0);
  83. }else{
  84. IDOS->Printf("Intuition Interface ottenuta correttamente\n");
  85. }
  86.  
  87. WindowBase = IIntuition->OpenClass("window.class", 52, &WindowClass);
  88. if(WindowBase == NULL){
  89. IDOS->Printf("impossibile ottenere WindowBase, impossibile aprire la Window class\n");
  90. return(0);
  91. }else{
  92. IDOS->Printf("WindowBase ottenuta correttamente, window class aperta correttamente\n");
  93. }
  94.  
  95. LayoutBase = IIntuition->OpenClass("gadgets/layout.gadget", 52, &LayoutClass);
  96. if(LayoutBase == NULL){
  97. IDOS->Printf("Impossibile ottenere LayoutBase, impossibile aprire LayoutClass\n");
  98. return(0);
  99. }else{
  100. IDOS->Printf("Layout Base ottenuta correttamente, classe aperta corretamente\n");
  101. }
  102.  
  103. ButtonBase = (struct ClassLibrary *)IIntuition->OpenClass("gadgets/button.gadget", 52, &ButtonClass);
  104. if(ButtonBase == NULL){
  105. IDOS->Printf("Impossibile ottenere ButtonBase, impossibile aprire la ButtonClass\n");
  106. return(0);
  107. }else{
  108. IDOS->Printf("Button Base ottenuta correttamente!\n");
  109. }
  110.  
  111. ListBrowserBase = (struct ClassLibrary *)IIntuition->OpenClass("gadgets/listbrowser.gadget", 52, &ListBrowserClass);
  112. if(ListBrowserBase == NULL){
  113. IDOS->Printf("Impossibile ottenere ListBrowserBase, impossibile aprire la ListBrowserClass\n");
  114. return(0);
  115. }else{
  116. IDOS->Printf("ListBrowserBase ottenuta correttamente!\n");
  117. }
  118.  
  119. IListBrowser = (struct ListBrowserIFace *)IExec->GetInterface((struct Library *)ListBrowserBase,"main",1,NULL);
  120. if(IListBrowser == NULL){
  121. IDOS->Printf("Impossibile ottenere ListBrowser Interface\n");
  122. return(0);
  123. }else{
  124. IDOS->Printf("ListBrowser Interface ottenuta correttamente\n");
  125.  
  126. column_info = IListBrowser->AllocLBColumnInfo(2,
  127. LBCIA_Column, 0,
  128. LBCIA_Title, " GUI Attributes",
  129. LBCIA_Width, 80,
  130. LBCIA_Column, 1,
  131. LBCIA_Title, " BOOL",
  132. LBCIA_Width, 20,
  133. TAG_END);
  134.  
  135. objects[OID_FINESTRA] = IIntuition->NewObject(WindowClass, NULL,
  136. WA_ScreenTitle, "Esempio ListBrowser",
  137. WA_Title, "ListBrowser",
  138. WA_Width, 800,
  139. WA_Height, 600,
  140. WA_DragBar, TRUE,
  141. WA_CloseGadget, TRUE,
  142. WA_SizeGadget, TRUE,
  143. WA_DepthGadget, TRUE,
  144. WA_Activate, TRUE,
  145. WINDOW_IconifyGadget, TRUE,
  146. WINDOW_Position, WPOS_CENTERSCREEN,
  147. WA_NewLookMenus, TRUE,
  148. WA_AutoAdjust, TRUE,
  149. WA_InnerWidth, 100,
  150. WA_InnerHeight, 100,
  151.  
  152. WINDOW_Layout, objects[OID_LAYOUT_1] = IIntuition->NewObject(LayoutClass, NULL,
  153. LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  154. LAYOUT_SpaceOuter, TRUE,
  155. LAYOUT_DeferLayout, TRUE,
  156. TAG_END),
  157.  
  158. LAYOUT_AddChild, objects[OID_LAYOUT_2] = IIntuition->NewObject(LayoutClass, NULL,
  159. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  160. LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL,
  161. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  162. LAYOUT_SpaceOuter, TRUE,
  163. LAYOUT_BevelStyle, BVS_GROUP,
  164. LAYOUT_Label, " ETICHETTA LISTBROWSER ", // IL LISTBROWSER QUI SOTTO
  165. LAYOUT_AddChild, objects[OID_LISTBROWSER] = IIntuition->NewObject(NULL,"listbrowser.gadget",
  166. GA_ID, OID_LISTBROWSER,
  167. GA_RelVerify, TRUE,
  168. GA_TabCycle, TRUE,
  169. LISTBROWSER_AutoFit, TRUE,
  170. LISTBROWSER_Labels, &listbrowser_list,
  171. LISTBROWSER_ColumnInfo, column_info,
  172. LISTBROWSER_ColumnTitles, TRUE,
  173. LISTBROWSER_ShowSelected, TRUE,
  174. LISTBROWSER_Striping, LBS_ROWS,
  175. TAG_END),
  176.  
  177. TAG_END), // FINE_BVS_GROUP
  178. TAG_END), // FINE_ OID_LAYOUT_2
  179. TAG_END); // FINE OID_FINESTRA
  180.  
  181. make_browserlist(&listbrowser_list, list_strings, tagdatas);
  182.  
  183. if(objects[OID_FINESTRA] != NULL)
  184. {
  185. struct Window *window = (struct Window *)IIntuition->IDoMethod(objects[OID_FINESTRA], WM_OPEN, NULL); // APRO FINESTRA
  186. if(window != NULL)
  187. {
  188. uint32 signal = 0;
  189. IIntuition->GetAttr(WINDOW_SigMask,objects[OID_FINESTRA],&signal);
  190. BOOL done = FALSE;
  191.  
  192. while(!done) // FINO A CHE DONE NON DIVENTA TRUE ESEGUI IL CICLO
  193. {
  194. uint32 wait = IExec->Wait(signal|SIGBREAKF_CTRL_C);
  195.  
  196. if(wait & SIGBREAKF_CTRL_C) // SE UNO DEI DUE OPERANDI E' 0 RESTITUISCE ZERO; SE ENTRAMBI SONO 1 RESTITUISCE 1; SE UNO DEI DUE E' ZERO RESTITUISCE ZERO
  197. {
  198. done = TRUE;
  199. break;
  200. }
  201.  
  202. if(wait & signal)
  203. {
  204. uint32 result = WMHI_LASTMSG;
  205. int16 code = 0;
  206.  
  207. while((result = IIntuition->IDoMethod(objects[OID_FINESTRA],WM_HANDLEINPUT,&code)) != WMHI_LASTMSG) // SE NON SONO UGUALI LA CONDIZIONE DIVENTA VERA E QUINDI IL CICLO FINISCE
  208. { // QUINDI SICCOME ORA SONO UGUALI IL CICLO CONTINUA
  209. switch(result & WMHI_CLASSMASK) //CLASSMASK RESTITUISCE LA PARTE BASSA DELLA WORD (L'ID)
  210. {
  211. case WMHI_CLOSEWINDOW:
  212. window = NULL;
  213. done = TRUE;
  214. break;
  215. }
  216. }
  217. }
  218. }
  219. }
  220.  
  221.  
  222.  
  223. IIntuition->DisposeObject(objects[OID_FINESTRA]);
  224. IListBrowser->FreeListBrowserList(&listbrowser_list);
  225. IListBrowser->FreeLBColumnInfo(column_info);
  226.  
  227. if(WindowBase){
  228. IIntuition->CloseClass(WindowBase);
  229. IDOS->Printf("\nChiusa la Window class\n");
  230. }
  231. if(LayoutBase){
  232. IIntuition->CloseClass(LayoutBase);
  233. IDOS->Printf("Chiudo la Layout Class\n");
  234. }
  235. if(ButtonBase){
  236. IIntuition->CloseClass(ButtonBase);
  237. IDOS->Printf("Chiudo la Button Class\n");
  238. }
  239. if(ListBrowserBase){
  240. IExec->DropInterface((struct Interface *)IListBrowser);
  241. IIntuition->CloseClass(ListBrowserBase);
  242. IDOS->Printf("Chiudo la ListBrowser Class\n");
  243. }
  244. if(IntuitionBase){
  245. IExec->DropInterface((struct Interface *)IIntuition);
  246. IDOS->Printf("Esco liberando l'interfaccia Intuition \n");
  247. IExec->CloseLibrary(IntuitionBase);
  248. IDOS->Printf("Chiudo la libreria Intuition \n");
  249. }
  250. if(DOSBase){
  251. IExec->DropInterface((struct Interface *)IDOS);
  252. printf("Interfaccia Dos liberata\n");
  253. IExec->CloseLibrary(DOSBase);
  254. printf("Chiudo DosLibrary\n\n");
  255. }
  256. }
  257. return RETURN_OK;
  258. }
  259. } // FINE MAIN
  260.  
  261. BOOL make_browserlist(struct List *list, char **tagstring, uint32 *bools){
  262. struct Node *node;
  263. uint16 num = 0;
  264. STRPTR truefalse[] = {"TRUE", "FALSE",NULL};
  265.  
  266. IExec->NewList(list);
  267. while (*tagstring)
  268. {
  269. if (node = IListBrowser->AllocListBrowserNode(2,
  270. LBNA_Column, 0,
  271. LBNCA_Text, *tagstring,
  272. LBNA_Column, 1,
  273. LBNCA_Text, truefalse[bools[num]],
  274. TAG_DONE))
  275. {
  276. IExec->AddTail(list, node);
  277. }
  278. else
  279. {
  280. IDOS->Printf(" AllocListBrowserNode() failed\n");
  281. return(FALSE);
  282. }
  283. tagstring++;
  284. num ++;
  285. }
  286. return(TRUE);
  287. }

GCC error:

  1. list_browser.c: In function 'main':
  2. list_browser.c:126: error: dereferencing pointer to incomplete type
  3. list_browser.c:224: error: dereferencing pointer to incomplete type
  4. list_browser.c:225: error: dereferencing pointer to incomplete type
  5. list_browser.c: In function 'make_browserlist':
  6. list_browser.c:269: error: dereferencing pointer to incomplete type
broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: [ListBrowser] error: dereferencing pointer to incomplete...

struct ListBrowserIFace is not declared at any point in your code, hence the "incomplete type".

add

  1. #include <proto/listbrowser.h>
Rigo
Rigo's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2011-01-24 21:55
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Add "#include <proto/listbrowser.h>" somewhere at the top, that should fix it

Simon

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Thanks for the reply Rigo. I did as you told me and now i have the following error:

  1. 3.Dev:Test_dir> gcc -o lb5 list_browser.c
  2. list_browser.c:30: error: conflicting types for 'ListBrowserBase'
  3. /SDK/include/include_h/proto/listbrowser.h:29: error: previous declaration of 'ListBrowserBase' was here
Rigo
Rigo's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2011-01-24 21:55
Re: [ListBrowser] error: dereferencing pointer to incomplete...

I'm guessing ListBrowserBase needs to be a "struct Library *" not ClassLibrary.

If you really need it as a ClassLibrary, then perhaps "#define __NOGLOBALIFACE__" might help.

Simon

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Honestly I don't know.. I am learning and, as far as I have understood, ListBrowser gadget is a class so I opened it as a Class and then I got its interface to use its functions.. But i do not know as all the examples i have seen use the -lauto switch during compiling time so, in all the examples, there is no manual opening of the libraries..

As soon as I go back to home i try to use #define __ NOGLOBALIFACE__ and see what happens..

Thanks,

Davide

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@Nube

Your new error ("previous declaration of 'ListBrowserBase' was here") stems from the fact that after including "proto/listbrowser.h", your code now contains two conflicting declarations of ListBrowserBase: one in the said include file (where the base is declared as a pointer to struct Library) and the other in your code (where the base is declared as a pointer to struct ClassLibrary).

The ListBrowser Gadget is a BOOPSI class, so its base in fact points to struct ClassLibrary. The SDK include file ("proto/listbrowser.h") declares the base as struct Library * not because there's an error there but for compatibility reasons: older ReAction code opened gadget classes via OpenLibrary(), which returns a pointer to struct Library. Of course in new code you are expected to use - like you do - OpenClass(), which returns a pointer to struct ClassLibrary. But as the first member of this structure is in fact an embedded struct Library, both declarations are fine (as long as you don't mix them up).

So remove the struct ClassLibrary *ListBrowserBase; declaration in line 29 and the error should be gone.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Hi Trixie thanks for the reply and the hint :-)

i tried to remove the line as you told me and now when i try to compile it I have the following error:

  1. 5.Dev:Test_dir> gcc -o lb5 list_browser.c
  2. list_browser.c: In function 'main':
  3. list_browser.c:112: warning: assignment from incompatible pointer type
  4. list_browser.c:242: warning: passing argument 2 of 'IIntuition->CloseClass' from incompatible pointer type
  5. /tmp/ccYxrGhF.o: In function `main':
  6. list_browser.c:(.text+0x3ca): undefined reference to `ListBrowserBase'
  7. list_browser.c:(.text+0x3ce): undefined reference to `ListBrowserBase'
  8. list_browser.c:(.text+0x3d2): undefined reference to `ListBrowserBase'
  9. list_browser.c:(.text+0x3d6): undefined reference to `ListBrowserBase'
  10. list_browser.c:(.text+0x456): undefined reference to `ListBrowserBase'
  11. /tmp/ccYxrGhF.o:list_browser.c:(.text+0x45a): more undefined references to `ListBrowserBase' follow

What should i do now?

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@Nube

In that case, do this:

- Put back the deleted ListBrowserBase declaration you had in line 29 but change it to
struct Library *ListBrowserBase;

- In your original line 111 change the class opening call to
ListBrowserBase = (struct Library *) IIntuition->OpenClass("gadgets/listbrowser.gadget", 52, &ListBrowserClass);

- In your original line 241 change the class closing call to
IIntuition->CloseClass((struct ClassLibrary *) ListBrowserBase);

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...
Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...
Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Thanks Trixie, now it compiles but the program doesn't work.. I have a gr at the startup..
here is the update version of my code:

  1. *****************************************************/
  2. /* */
  3. /* PER COMPILARE: */
  4. /* */
  5. /* gcc -o lb list_browser.c */
  6. /* */
  7. /*****************************************************/
  8.  
  9. #include <stdio.h> // standard inputoutput c library
  10. #include <proto/exec.h> // exec library
  11. #include <proto/dos.h> // dos library
  12. #include <proto/intuition.h> // intuition library
  13. #include <proto/listbrowser.h>
  14. #include <intuition/gui.h>
  15.  
  16. #include <classes/window.h> // Window class per oop boopsi window
  17. #include <gadgets/button.h> // Button gadget per bottoni finestra
  18. #include <gadgets/layout.h> // Layout gadget per disposizione oggetti in finestra
  19. #include <gadgets/listbrowser.h> // ListBrowser gadget per visualizzare elenchi liste
  20.  
  21. struct ClassLibrary *WindowBase; // WindowBase pointer per accedere all'interfaccia della windows class
  22. Class *WindowClass; // Window class pointer per accedere alle funzioni della window class
  23.  
  24. struct ClassLibrary *LayoutBase; // LayoutBase pointer per accedere alla layoutbase
  25. Class *LayoutClass; // LayoutClass pointer per accedere alle funzioni della LayoutClass
  26.  
  27. struct ClassLibrary *ButtonBase; // ButtonBase pointer per accedere alla ButtonClass interface
  28. Class *ButtonClass; // ButtonClass pointer per accedere alle funzioni della Button Class
  29.  
  30. //struct ClassLibrary *ListBrowserBase; // ListBrowserBase
  31. struct Library *ListBrowserBase;
  32. Class *ListBrowserClass; // ListBrowserClass
  33. struct ListBrowserIFace *IListBrowser = NULL;
  34.  
  35. struct Library *IntuitionBase = NULL; // IntuitionBase pointer per accedere alla libreria Intuition
  36. struct IntuitionIFace *IIntuition = NULL; // IIntuition pointer per accedere alle funzioni della libreria Intuition tramite la sua interfaccia
  37.  
  38. struct List listbrowser_list;
  39. struct ColumnInfo *column_info = NULL;
  40.  
  41. enum{
  42. OID_FINESTRA,
  43. OID_LAYOUT_1,
  44. OID_LAYOUT_2,
  45. OID_LISTBROWSER,
  46. OID_LAST
  47. };
  48.  
  49. Object *objects[OID_LAST]; // indichiamo la grandezza del nostro puntatore di tipo Object
  50.  
  51. static const char USED minstack[]="$STACK:80000"; // indichiamo il minimo di memoria richiesta per eseguire il nostro programma
  52.  
  53. /* ELEMENTI LISTBROWSER: */
  54.  
  55. uint32 tagdatas[2];
  56.  
  57. int32 tags[] = {
  58. GUIA_ScreenDragging,
  59. GUIA_OffScreenDragging
  60. };
  61.  
  62. STRPTR list_strings[] = {
  63. "GUIA_ScreenDragging",
  64. "GUIA_OffScreenDragging",
  65. NULL
  66. };
  67.  
  68. BOOL make_browserlist(struct List *, char **, uint32 *);
  69.  
  70. /* FINE ELEMENTI LISTBROWSER */
  71.  
  72. int main(){
  73.  
  74.  
  75. IntuitionBase = IExec->OpenLibrary("intuition.library", 52);
  76. if(IntuitionBase == NULL){
  77. IDOS->Printf("Impossibile ottenere IntuitionBase pointer, impossibile aprire la libreria\n");
  78. }else{
  79. IDOS->Printf("\nIntuitionBase pointer ottenuto, libreria aperta correttamente\n");
  80. }
  81. IIntuition = (struct IntuitionIFace *)IExec->GetInterface(IntuitionBase,"main",1,NULL);
  82. if(IIntuition == NULL){
  83. IDOS->Printf("Impossibile ottenere Intuition Interface\n");
  84. return(0);
  85. }else{
  86. IDOS->Printf("Intuition Interface ottenuta correttamente\n");
  87. }
  88.  
  89. WindowBase = IIntuition->OpenClass("window.class", 52, &WindowClass);
  90. if(WindowBase == NULL){
  91. IDOS->Printf("impossibile ottenere WindowBase, impossibile aprire la Window class\n");
  92. return(0);
  93. }else{
  94. IDOS->Printf("WindowBase ottenuta correttamente, window class aperta correttamente\n");
  95. }
  96.  
  97. LayoutBase = IIntuition->OpenClass("gadgets/layout.gadget", 52, &LayoutClass);
  98. if(LayoutBase == NULL){
  99. IDOS->Printf("Impossibile ottenere LayoutBase, impossibile aprire LayoutClass\n");
  100. return(0);
  101. }else{
  102. IDOS->Printf("Layout Base ottenuta correttamente, classe aperta corretamente\n");
  103. }
  104.  
  105. ButtonBase = (struct ClassLibrary *)IIntuition->OpenClass("gadgets/button.gadget", 52, &ButtonClass);
  106. if(ButtonBase == NULL){
  107. IDOS->Printf("Impossibile ottenere ButtonBase, impossibile aprire la ButtonClass\n");
  108. return(0);
  109. }else{
  110. IDOS->Printf("Button Base ottenuta correttamente!\n");
  111. }
  112.  
  113. ListBrowserBase = (struct Library *)IIntuition->OpenClass("gadgets/listbrowser.gadget", 52, &ListBrowserClass);
  114. if(ListBrowserBase == NULL){
  115. IDOS->Printf("Impossibile ottenere ListBrowserBase, impossibile aprire la ListBrowserClass\n");
  116. return(0);
  117. }else{
  118. IDOS->Printf("ListBrowserBase ottenuta correttamente!\n");
  119. }
  120.  
  121. IListBrowser = (struct ListBrowserIFace *)IExec->GetInterface((struct Library *)ListBrowserBase,"main",1,NULL);
  122. if(IListBrowser == NULL){
  123. IDOS->Printf("Impossibile ottenere ListBrowser Interface\n");
  124. return(0);
  125. }else{
  126. IDOS->Printf("ListBrowser Interface ottenuta correttamente\n");
  127.  
  128. column_info = IListBrowser->AllocLBColumnInfo(2,
  129. LBCIA_Column, 0,
  130. LBCIA_Title, " GUI Attributes",
  131. LBCIA_Width, 80,
  132. LBCIA_Column, 1,
  133. LBCIA_Title, " BOOL",
  134. LBCIA_Width, 20,
  135. TAG_END);
  136.  
  137. objects[OID_FINESTRA] = IIntuition->NewObject(WindowClass, NULL,
  138. WA_ScreenTitle, "Esempio ListBrowser",
  139. WA_Title, "ListBrowser",
  140. WA_Width, 800,
  141. WA_Height, 600,
  142. WA_DragBar, TRUE,
  143. WA_CloseGadget, TRUE,
  144. WA_SizeGadget, TRUE,
  145. WA_DepthGadget, TRUE,
  146. WA_Activate, TRUE,
  147. WINDOW_IconifyGadget, TRUE,
  148. WINDOW_Position, WPOS_CENTERSCREEN,
  149. WA_NewLookMenus, TRUE,
  150. WA_AutoAdjust, TRUE,
  151. WA_InnerWidth, 100,
  152. WA_InnerHeight, 100,
  153.  
  154. WINDOW_Layout, objects[OID_LAYOUT_1] = IIntuition->NewObject(LayoutClass, NULL,
  155. LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  156. LAYOUT_SpaceOuter, TRUE,
  157. LAYOUT_DeferLayout, TRUE,
  158. TAG_END),
  159.  
  160. LAYOUT_AddChild, objects[OID_LAYOUT_2] = IIntuition->NewObject(LayoutClass, NULL,
  161. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  162. LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL,
  163. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  164. LAYOUT_SpaceOuter, TRUE,
  165. LAYOUT_BevelStyle, BVS_GROUP,
  166. LAYOUT_Label, " ETICHETTA LISTBROWSER ", // IL LISTBROWSER QUI SOTTO
  167. LAYOUT_AddChild, objects[OID_LISTBROWSER] = IIntuition->NewObject(NULL,"listbrowser.gadget",
  168. GA_ID, OID_LISTBROWSER,
  169. GA_RelVerify, TRUE,
  170. GA_TabCycle, TRUE,
  171. LISTBROWSER_AutoFit, TRUE,
  172. LISTBROWSER_Labels, &listbrowser_list,
  173. LISTBROWSER_ColumnInfo, column_info,
  174. LISTBROWSER_ColumnTitles, TRUE,
  175. LISTBROWSER_ShowSelected, TRUE,
  176. LISTBROWSER_Striping, LBS_ROWS,
  177. TAG_END),
  178.  
  179. TAG_END), // FINE_BVS_GROUP
  180. TAG_END), // FINE_ OID_LAYOUT_2
  181. TAG_END); // FINE OID_FINESTRA
  182.  
  183. make_browserlist(&listbrowser_list, list_strings, tagdatas);
  184.  
  185. if(objects[OID_FINESTRA] != NULL)
  186. {
  187. struct Window *window = (struct Window *)IIntuition->IDoMethod(objects[OID_FINESTRA], WM_OPEN, NULL); // APRO FINESTRA
  188. if(window != NULL)
  189. {
  190. uint32 signal = 0;
  191. IIntuition->GetAttr(WINDOW_SigMask,objects[OID_FINESTRA],&signal);
  192. BOOL done = FALSE;
  193.  
  194. while(!done) // FINO A CHE DONE NON DIVENTA TRUE ESEGUI IL CICLO
  195. {
  196. uint32 wait = IExec->Wait(signal|SIGBREAKF_CTRL_C);
  197.  
  198. if(wait & SIGBREAKF_CTRL_C) // SE UNO DEI DUE OPERANDI E' 0 RESTITUISCE ZERO; SE ENTRAMBI SONO 1 RESTITUISCE 1; SE UNO DEI DUE E' ZERO RESTITUISCE ZERO
  199. {
  200. done = TRUE;
  201. break;
  202. }
  203.  
  204. if(wait & signal)
  205. {
  206. uint32 result = WMHI_LASTMSG;
  207. int16 code = 0;
  208.  
  209. while((result = IIntuition->IDoMethod(objects[OID_FINESTRA],WM_HANDLEINPUT,&code)) != WMHI_LASTMSG) // SE NON SONO UGUALI LA CONDIZIONE DIVENTA VERA E QUINDI IL CICLO FINISCE
  210. { // QUINDI SICCOME ORA SONO UGUALI IL CICLO CONTINUA
  211. switch(result & WMHI_CLASSMASK) //CLASSMASK RESTITUISCE LA PARTE BASSA DELLA WORD (L'ID)
  212. {
  213. case WMHI_CLOSEWINDOW:
  214. window = NULL;
  215. done = TRUE;
  216. break;
  217. }
  218. }
  219. }
  220. }
  221. }
  222.  
  223.  
  224.  
  225. IIntuition->DisposeObject(objects[OID_FINESTRA]);
  226. IListBrowser->FreeListBrowserList(&listbrowser_list);
  227. IListBrowser->FreeLBColumnInfo(column_info);
  228.  
  229. if(WindowBase){
  230. IIntuition->CloseClass(WindowBase);
  231. IDOS->Printf("\nChiusa la Window class\n");
  232. }
  233. if(LayoutBase){
  234. IIntuition->CloseClass(LayoutBase);
  235. IDOS->Printf("Chiudo la Layout Class\n");
  236. }
  237. if(ButtonBase){
  238. IIntuition->CloseClass(ButtonBase);
  239. IDOS->Printf("Chiudo la Button Class\n");
  240. }
  241. if(ListBrowserBase){
  242. IExec->DropInterface((struct Interface *)IListBrowser);
  243. IIntuition->CloseClass((struct ClassLibrary *)ListBrowserBase);
  244. IDOS->Printf("Chiudo la ListBrowser Class\n");
  245. }
  246. if(IntuitionBase){
  247. IExec->DropInterface((struct Interface *)IIntuition);
  248. IDOS->Printf("Esco liberando l'interfaccia Intuition \n");
  249. IExec->CloseLibrary(IntuitionBase);
  250. IDOS->Printf("Chiudo la libreria Intuition \n");
  251. }
  252. if(DOSBase){
  253. IExec->DropInterface((struct Interface *)IDOS);
  254. printf("Interfaccia Dos liberata\n");
  255. IExec->CloseLibrary(DOSBase);
  256. printf("Chiudo DosLibrary\n\n");
  257. }
  258. }
  259. return RETURN_OK;
  260. }
  261. } // FINE MAIN
  262.  
  263. BOOL make_browserlist(struct List *list, char **tagstring, uint32 *bools){
  264. struct Node *node;
  265. uint16 num = 0;
  266. STRPTR truefalse[] = {"TRUE", "FALSE",NULL};
  267.  
  268. IExec->NewList(list);
  269. while (*tagstring)
  270. {
  271. if (node = IListBrowser->AllocListBrowserNode(2,
  272. LBNA_Column, 0,
  273. LBNCA_Text, *tagstring,
  274. LBNA_Column, 1,
  275. LBNCA_Text, truefalse[bools[num]],
  276. TAG_DONE))
  277. {
  278. IExec->AddTail(list, node);
  279. }
  280. else
  281. {
  282. IDOS->Printf(" AllocListBrowserNode() failed\n");
  283. return(FALSE);
  284. }
  285. tagstring++;
  286. num ++;
  287. }
  288. return(TRUE);
  289. }

I think i missing something to have a listbrowser in my code..

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

no wait... the program opened after i pressed "ignore" in the gr popup window.. it took about 5 to 7 minutes but it is an empty window without listbrowser inside.. definitly i am missing something... the funny thing is that amiga os didn't freeze and the program opened..

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...
Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

When i try to post the crash log i have an internal server error...
another thing, why my avatar is gone?

xenic
xenic's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-07 04:52
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@Nube
I compiled your code and determined that the crash is due to giving an uninitialized list to Intuition. You should probably be using ASOT_LIST instead of the old Exec->Newlist. Here are the changes I made to prevent the crash.

Changed line 36 to "struct List *listbrowser_list;" so it's a pointer.

Removed line 266.

Changed line 170 to "LISTBROWSER_Labels, listbrowser_list," //removed the &

Added "IExec->FreeSysObject(ASOT_LIST, listbrowser_list);" below line 224.

Added the following lines right above line 135:
if (!(listbrowser_list = (struct List *)IExec->AllocSysObject(ASOT_LIST, NULL)))
{
return 0;
}

The program stopped crashing but just opens an empty window. Maybe someone else can find more corrections that need to be made.

X1000 - OS 4.1FE

broadblues
broadblues's picture
Offline
Last seen: 4 years 9 months ago
Joined: 2012-05-02 21:48
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Maybe someone else can find more corrections that need to be made.

That ones easy :-)

The code builds the list *after* attaching it to the Listbrowser. You must never do that.

For the simple case move the call to make_browserlist() at line 183 before the NewObject() call at line 137;

For the general case of updating the list whilst the program is running the process is roughly

Remove the list from the listbrowser (SetAttrs(lb,LISTBRWOSER_Labels, ~0,TAG_DONE);

Make required changes to list

Re add to listbrowswer

SetGadgetAttrs(lb,window,NULL,LISTBROWSER_Lables,list,TAG_DONE);
Possibly use RefreshSetGadgetAttrs().

Note don;t use SetGadgetAttrs() when removing. THis prevent an flicker in the window while the list is removed. DO replace the is list as quickly as possible.

xenic
xenic's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-07 04:52
Re: [ListBrowser] error: dereferencing pointer to incomplete...

I moved make_browserlist() but I still get an empty window. Maybe there's another error. Heres the code I compiled (with changes):

  1. /*****************************************************/
  2. /* */
  3. /* PER COMPILARE: */
  4. /* */
  5. /* gcc -gstabs -o lb list_browser.c */
  6. /* */
  7. /*****************************************************/
  8.  
  9. #include <stdio.h> // standard inputoutput c library
  10. #include <proto/exec.h> // exec library
  11. #include <proto/dos.h> // dos library
  12. #include <proto/intuition.h> // intuition library
  13. #include <proto/listbrowser.h>
  14. #include <intuition/gui.h>
  15.  
  16. #include <classes/window.h> // Window class per oop boopsi window
  17. #include <gadgets/button.h> // Button gadget per bottoni finestra
  18. #include <gadgets/layout.h> // Layout gadget per disposizione oggetti in finestra
  19. #include <gadgets/listbrowser.h> // ListBrowser gadget per visualizzare elenchi liste
  20.  
  21. struct ClassLibrary *WindowBase; // WindowBase pointer per accedere all'interfaccia della windows class
  22. Class *WindowClass; // Window class pointer per accedere alle funzioni della window class
  23.  
  24. struct ClassLibrary *LayoutBase; // LayoutBase pointer per accedere alla layoutbase
  25. Class *LayoutClass; // LayoutClass pointer per accedere alle funzioni della LayoutClass
  26.  
  27. struct ClassLibrary *ButtonBase; // ButtonBase pointer per accedere alla ButtonClass interface
  28. Class *ButtonClass; // ButtonClass pointer per accedere alle funzioni della Button Class
  29.  
  30. //struct ClassLibrary *ListBrowserBase; // ListBrowserBase
  31. struct Library *ListBrowserBase;
  32. Class *ListBrowserClass; // ListBrowserClass
  33. struct ListBrowserIFace *IListBrowser = NULL;
  34.  
  35. struct Library *IntuitionBase = NULL; // IntuitionBase pointer per accedere alla libreria Intuition
  36. struct IntuitionIFace *IIntuition = NULL; // IIntuition pointer per accedere alle funzioni della libreria Intuition tramite la sua interfaccia
  37.  
  38. struct List *listbrowser_list;
  39. struct ColumnInfo *column_info = NULL;
  40.  
  41. enum{
  42. OID_FINESTRA,
  43. OID_LAYOUT_1,
  44. OID_LAYOUT_2,
  45. OID_LISTBROWSER,
  46. OID_LAST
  47. };
  48.  
  49. Object *objects[OID_LAST]; // indichiamo la grandezza del nostro puntatore di tipo Object
  50.  
  51. static const char USED minstack[]="$STACK:80000"; // indichiamo il minimo di memoria richiesta per eseguire il nostro programma
  52.  
  53. /* ELEMENTI LISTBROWSER: */
  54.  
  55. uint32 tagdatas[2];
  56.  
  57. int32 tags[] = {
  58. GUIA_ScreenDragging,
  59. GUIA_OffScreenDragging
  60. };
  61.  
  62. STRPTR list_strings[] = {
  63. "GUIA_ScreenDragging",
  64. "GUIA_OffScreenDragging",
  65. NULL
  66. };
  67.  
  68. BOOL make_browserlist(struct List *, char **, uint32 *);
  69.  
  70. /* FINE ELEMENTI LISTBROWSER */
  71.  
  72. int main(){
  73.  
  74.  
  75. IntuitionBase = IExec->OpenLibrary("intuition.library", 52);
  76. if(IntuitionBase == NULL){
  77. IDOS->Printf("Impossibile ottenere IntuitionBase pointer, impossibile aprire la libreria\n");
  78. }else{
  79. IDOS->Printf("\nIntuitionBase pointer ottenuto, libreria aperta correttamente\n");
  80. }
  81. IIntuition = (struct IntuitionIFace *)IExec->GetInterface(IntuitionBase,"main",1,NULL);
  82. if(IIntuition == NULL){
  83. IDOS->Printf("Impossibile ottenere Intuition Interface\n");
  84. return(0);
  85. }else{
  86. IDOS->Printf("Intuition Interface ottenuta correttamente\n");
  87. }
  88.  
  89. WindowBase = IIntuition->OpenClass("window.class", 52, &WindowClass);
  90. if(WindowBase == NULL){
  91. IDOS->Printf("impossibile ottenere WindowBase, impossibile aprire la Window class\n");
  92. return(0);
  93. }else{
  94. IDOS->Printf("WindowBase ottenuta correttamente, window class aperta correttamente\n");
  95. }
  96.  
  97. LayoutBase = IIntuition->OpenClass("gadgets/layout.gadget", 52, &LayoutClass);
  98. if(LayoutBase == NULL){
  99. IDOS->Printf("Impossibile ottenere LayoutBase, impossibile aprire LayoutClass\n");
  100. return(0);
  101. }else{
  102. IDOS->Printf("Layout Base ottenuta correttamente, classe aperta corretamente\n");
  103. }
  104.  
  105. ButtonBase = (struct ClassLibrary *)IIntuition->OpenClass("gadgets/button.gadget", 52, &ButtonClass);
  106. if(ButtonBase == NULL){
  107. IDOS->Printf("Impossibile ottenere ButtonBase, impossibile aprire la ButtonClass\n");
  108. return(0);
  109. }else{
  110. IDOS->Printf("Button Base ottenuta correttamente!\n");
  111. }
  112.  
  113. ListBrowserBase = (struct Library *)IIntuition->OpenClass("gadgets/listbrowser.gadget", 52, &ListBrowserClass);
  114. if(ListBrowserBase == NULL){
  115. IDOS->Printf("Impossibile ottenere ListBrowserBase, impossibile aprire la ListBrowserClass\n");
  116. return(0);
  117. }else{
  118. IDOS->Printf("ListBrowserBase ottenuta correttamente!\n");
  119. }
  120.  
  121. IListBrowser = (struct ListBrowserIFace *)IExec->GetInterface((struct Library *)ListBrowserBase,"main",1,NULL);
  122. if(IListBrowser == NULL){
  123. IDOS->Printf("Impossibile ottenere ListBrowser Interface\n");
  124. return(0);
  125. }else{
  126. IDOS->Printf("ListBrowser Interface ottenuta correttamente\n");
  127.  
  128. column_info = IListBrowser->AllocLBColumnInfo(2,
  129. LBCIA_Column, 0,
  130. LBCIA_Title, " GUI Attributes",
  131. LBCIA_Width, 80,
  132. LBCIA_Column, 1,
  133. LBCIA_Title, " BOOL",
  134. LBCIA_Width, 20,
  135. TAG_END);
  136.  
  137. if (!(listbrowser_list = (struct List *)IExec->AllocSysObject(ASOT_LIST, NULL)))
  138. {
  139. return 0;
  140. }
  141.  
  142. make_browserlist(listbrowser_list, list_strings, tagdatas);
  143.  
  144. objects[OID_FINESTRA] = IIntuition->NewObject(WindowClass, NULL,
  145. WA_ScreenTitle, "Esempio ListBrowser",
  146. WA_Title, "ListBrowser",
  147. WA_Width, 800,
  148. WA_Height, 600,
  149. WA_DragBar, TRUE,
  150. WA_CloseGadget, TRUE,
  151. WA_SizeGadget, TRUE,
  152. WA_DepthGadget, TRUE,
  153. WA_Activate, TRUE,
  154. WINDOW_IconifyGadget, TRUE,
  155. WINDOW_Position, WPOS_CENTERSCREEN,
  156. WA_NewLookMenus, TRUE,
  157. WA_AutoAdjust, TRUE,
  158. // WA_InnerWidth, 100,
  159. // WA_InnerHeight, 100,
  160.  
  161. WINDOW_Layout, objects[OID_LAYOUT_1] = IIntuition->NewObject(LayoutClass, NULL,
  162. LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  163. LAYOUT_SpaceOuter, TRUE,
  164. LAYOUT_DeferLayout, TRUE,
  165. TAG_END),
  166.  
  167. LAYOUT_AddChild, objects[OID_LAYOUT_2] = IIntuition->NewObject(LayoutClass, NULL,
  168. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  169. LAYOUT_AddChild, IIntuition->NewObject(LayoutClass, NULL,
  170. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  171. LAYOUT_SpaceOuter, TRUE,
  172. LAYOUT_BevelStyle, BVS_GROUP,
  173. LAYOUT_Label, " ETICHETTA LISTBROWSER ", // IL LISTBROWSER QUI SOTTO
  174. LAYOUT_AddChild, objects[OID_LISTBROWSER] = IIntuition->NewObject(NULL,"listbrowser.gadget",
  175. GA_ID, OID_LISTBROWSER,
  176. GA_RelVerify, TRUE,
  177. GA_TabCycle, TRUE,
  178. LISTBROWSER_AutoFit, TRUE,
  179. LISTBROWSER_Labels, listbrowser_list,
  180. LISTBROWSER_ColumnInfo, column_info,
  181. LISTBROWSER_ColumnTitles, TRUE,
  182. LISTBROWSER_ShowSelected, TRUE,
  183. LISTBROWSER_Striping, LBS_ROWS,
  184. TAG_END),
  185.  
  186. TAG_END), // FINE_BVS_GROUP
  187. TAG_END), // FINE_ OID_LAYOUT_2
  188. TAG_END); // FINE OID_FINESTRA
  189.  
  190. if(objects[OID_FINESTRA] != NULL)
  191. {
  192. struct Window *window = (struct Window *)IIntuition->IDoMethod(objects[OID_FINESTRA], WM_OPEN, NULL); // APRO FINESTRA
  193. if(window != NULL)
  194. {
  195. uint32 signal = 0;
  196. IIntuition->GetAttr(WINDOW_SigMask,objects[OID_FINESTRA],&signal);
  197. BOOL done = FALSE;
  198.  
  199. while(!done) // FINO A CHE DONE NON DIVENTA TRUE ESEGUI IL CICLO
  200. {
  201. uint32 wait = IExec->Wait(signal|SIGBREAKF_CTRL_C);
  202.  
  203. if(wait & SIGBREAKF_CTRL_C) // SE UNO DEI DUE OPERANDI E' 0 RESTITUISCE ZERO; SE ENTRAMBI SONO 1 RESTITUISCE 1; SE UNO DEI DUE E' ZERO RESTITUISCE ZERO
  204. {
  205. done = TRUE;
  206. break;
  207. }
  208.  
  209. if(wait & signal)
  210. {
  211. uint32 result = WMHI_LASTMSG;
  212. int16 code = 0;
  213.  
  214. while((result = IIntuition->IDoMethod(objects[OID_FINESTRA],WM_HANDLEINPUT,&code)) != WMHI_LASTMSG) // SE NON SONO UGUALI LA CONDIZIONE DIVENTA VERA E QUINDI IL CICLO FINISCE
  215. { // QUINDI SICCOME ORA SONO UGUALI IL CICLO CONTINUA
  216. switch(result & WMHI_CLASSMASK) //CLASSMASK RESTITUISCE LA PARTE BASSA DELLA WORD (L'ID)
  217. {
  218. case WMHI_CLOSEWINDOW:
  219. window = NULL;
  220. done = TRUE;
  221. break;
  222. }
  223. }
  224. }
  225. }
  226. }
  227.  
  228.  
  229.  
  230. IIntuition->DisposeObject(objects[OID_FINESTRA]);
  231. IListBrowser->FreeListBrowserList(listbrowser_list);
  232. IExec->FreeSysObject(ASOT_LIST, listbrowser_list);
  233.  
  234. IListBrowser->FreeLBColumnInfo(column_info);
  235.  
  236. if(WindowBase){
  237. IIntuition->CloseClass(WindowBase);
  238. IDOS->Printf("\nChiusa la Window class\n");
  239. }
  240. if(LayoutBase){
  241. IIntuition->CloseClass(LayoutBase);
  242. IDOS->Printf("Chiudo la Layout Class\n");
  243. }
  244. if(ButtonBase){
  245. IIntuition->CloseClass(ButtonBase);
  246. IDOS->Printf("Chiudo la Button Class\n");
  247. }
  248. if(ListBrowserBase){
  249. IExec->DropInterface((struct Interface *)IListBrowser);
  250. IIntuition->CloseClass((struct ClassLibrary *)ListBrowserBase);
  251. IDOS->Printf("Chiudo la ListBrowser Class\n");
  252. }
  253. if(IntuitionBase){
  254. IExec->DropInterface((struct Interface *)IIntuition);
  255. IDOS->Printf("Esco liberando l'interfaccia Intuition \n");
  256. IExec->CloseLibrary(IntuitionBase);
  257. IDOS->Printf("Chiudo la libreria Intuition \n");
  258. }
  259. if(DOSBase){
  260. IExec->DropInterface((struct Interface *)IDOS);
  261. printf("Interfaccia Dos liberata\n");
  262. IExec->CloseLibrary(DOSBase);
  263. printf("Chiudo DosLibrary\n\n");
  264. }
  265. }
  266. return RETURN_OK;
  267. }
  268. } // FINE MAIN
  269.  
  270. BOOL make_browserlist(struct List *list, char **tagstring, uint32 *bools){
  271. struct Node *node;
  272. uint16 num = 0;
  273. STRPTR truefalse[] = {"TRUE", "FALSE",NULL};
  274.  
  275. // IExec->NewList(list);
  276. while (*tagstring)
  277. {
  278. if (node = IListBrowser->AllocListBrowserNode(2,
  279. LBNA_Column, 0,
  280. LBNCA_Text, *tagstring,
  281. LBNA_Column, 1,
  282. LBNCA_Text, truefalse[bools[num]],
  283. TAG_DONE))
  284. {
  285. IExec->AddTail(list, node);
  286. }
  287. else
  288. {
  289. IDOS->Printf(" AllocListBrowserNode() failed\n");
  290. return(FALSE);
  291. }
  292. tagstring++;
  293. num ++;
  294. }
  295. return(TRUE);
  296. }

X1000 - OS 4.1FE

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Thanks to all for the help, really appreciated. It is not easy to learn amiga os coding from scratch and as you can see most of the examples included in the sdk are outdated and it is not easy to understand how to proceed.. By the way I will continue investigating on how to create/insert a listbrowser gadget in my code :-)

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@Nube

Your code crashed because you were passing an unitialized listbrowser list to your NewObject() call. Note in your original code that the make_browserlist() function is called in line 181 after you have created the listbrowser object! This cannot possibly work - the list must be initialized before you pass it to NewObject() via LISTBROWSER_Labels.

Edit: Sorry, didn't realize Andy already beat me to it :-)

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

jabirulo
jabirulo's picture
Offline
Last seen: 2 weeks 6 days ago
Joined: 2013-05-30 00:53
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Hi, you have a TAG_END in GUI too "early" (closing/finishing the window contents/lyout):

  1. ...
  2. WINDOW_Layout, objects[OID_LAYOUT_1] = IIntuition->NewObject(LayoutClass, NULL,
  3. LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
  4. LAYOUT_SpaceOuter, TRUE,
  5. LAYOUT_DeferLayout, TRUE,
  6. //TAG_END), /* FINE OID_LAYOUT_1 "WRONG" */
  7. ...

and put it at the end of GUI creation:

  1. ...
  2. TAG_END), // FINE_ OID_LAYOUT_2
  3. TAG_END), /* FINE OID_LAYOUT_1*/
  4. TAG_END); // FINE OID_FINESTRA
  5. ...

there is a PDF/guide to ReAction GUI code in os4depot (http://www.os4depot.net/share/document/development/reactionguide.lha)

And enable "IExec->NewList(list);" in make_browserlist() code.

And maybe move the Disposing() out of the "if(objects[OID_FINESTRA] != NULL)" , to make sure objects are disposing even if windows object couldn't be created.

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@Nube

And enable "IExec->NewList(list);" in make_browserlist() code.

No, don't. The list initialization is handled by IExec->AllocSysObject(ASOT_LIST, NULL) in line 137, so no need for NewList() here.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Thanks to all, I will find the solution and post it here! :-)

xenic
xenic's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-07 04:52
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@jabirulo
Good catch. The program compiles & works now. As Trixie pointed out, The IExec->NewList() function was replaced with the ASOT_LIST allocation (which also initializes the list). I should have removed it instead of commenting it out.

X1000 - OS 4.1FE

OldFart
OldFart's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2010-11-30 14:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@Nube

And may I join the party and chime in as well?

My eye fell on this part:

  1. if(DOSBase){
  2. IExec->DropInterface((struct Interface *)IDOS);
  3. printf("Interfaccia Dos liberata\n");
  4. IExec->CloseLibrary(DOSBase);
  5. printf("Chiudo DosLibrary\n\n");
  6. }

But DOS library is nowhere opened explicitly in your code. What's more: DOS library is one of those libraries which is ALLWAYS open and, hence, should not be closed manually/explicitly.

Furthermore, you do some allocations like IListBrowser->AllocLBColumnInfo(), but you do not test for success/failure. Not wrong per sé, but it's better to check every possible step in the process.

My 0.02 euro...

Ok, I'm off again.

OldFart

jabirulo
jabirulo's picture
Offline
Last seen: 2 weeks 6 days ago
Joined: 2013-05-30 00:53
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@trixie

No, don't. The list initialization is handled by IExec->AllocSysObject(ASOT_LIST, NULL) in line 137, so no need for NewList() here.

Ok thx didn't know.
Just courosity, any benefits (saves memory, "faster",..) to use ASOT_LIST instead of NewList()?
TIA

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
Re: [ListBrowser] error: dereferencing pointer to incomplete...

AllocSysObject allocates new memory and returns a pointer to it. This memory needs to be freed before you leave the program.

NewList takes a pointer to an already allocated block of memory.

If your struct List is part of another struct you would use NewList. For example in a hierarchical data type where nodes can have child-lists.

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

At the end I was able to create a little demo that use one column listbrowser gadget inside a window. it is a very basic example but enough for me to understand how to create a list and how to use a listbrowser gadget. Here the working example:

  1. #include <stdio.h> // standard inputoutput c library
  2. #include <proto/exec.h> // exec library
  3. #include <proto/dos.h> // dos library
  4. #include <proto/intuition.h> // intuition library
  5. #include <proto/listbrowser.h> // listbrowser library
  6.  
  7. #include <classes/window.h> // Window class per oop boopsi window
  8. #include <gadgets/button.h> // Button gadget per bottoni finestra
  9. #include <gadgets/layout.h> // Layout gadget per disposizione oggetti in finestra
  10. #include <gadgets/listbrowser.h> // ListBrowser gadget per visualizzare elenchi liste
  11.  
  12. struct ClassLibrary *WindowBase; // WindowBase pointer per accedere all'interfaccia della windows class
  13. Class *WindowClass; // Window class pointer per accedere alle funzioni della window class
  14.  
  15. struct ClassLibrary *LayoutBase; // LayoutBase pointer per accedere alla layoutbase
  16. Class *LayoutClass; // LayoutClass pointer per accedere alle funzioni della LayoutClass
  17.  
  18. struct ClassLibrary *ButtonBase; // ButtonBase pointer per accedere alla ButtonClass interface
  19. Class *ButtonClass; // ButtonClass pointer per accedere alle funzioni della Button Class
  20.  
  21. //struct ClassLibrary *ListBrowserBase; // ListBrowserBase
  22. struct Library *ListBrowserBase;
  23. Class *ListBrowserClass; // ListBrowserClass
  24. struct ListBrowserIFace *IListBrowser = NULL;
  25.  
  26. struct Library *IntuitionBase = NULL; // IntuitionBase pointer per accedere alla libreria Intuition
  27. struct IntuitionIFace *IIntuition = NULL; // IIntuition pointer per accedere alle funzioni della libreria Intuition tramite la sua interfaccia
  28.  
  29. /* STRUTTURE NECESSARIE PER LISTBROWSER */
  30.  
  31. struct List *listbrowser_list;
  32. struct ColumnInfo *column_info = NULL;
  33. struct Node *node = NULL;
  34.  
  35. /*=====================================*/
  36.  
  37. enum{
  38. OID_FINESTRA,
  39. OID_LISTBROWSER,
  40. OID_LAST
  41. };
  42.  
  43. Object *objects[OID_LAST]; // indichiamo la grandezza del nostro puntatore di tipo Object
  44.  
  45. static const char USED minstack[]="$STACK:80000"; // indichiamo il minimo di memoria richiesta per eseguire il nostro programma
  46.  
  47. /* ELEMENTI LISTBROWSER: */
  48.  
  49. STRPTR nodetexts[] = {
  50. "Eins",
  51. "Zwei",
  52. "Drei",
  53. "JaJaJa!",
  54. "Wunderbar!",
  55. NULL
  56. };
  57.  
  58.  
  59. /* FINE ELEMENTI LISTBROWSER */
  60.  
  61. int main(){
  62. int i;
  63.  
  64. IntuitionBase = IExec->OpenLibrary("intuition.library", 52);
  65. if(IntuitionBase == NULL){
  66. IDOS->Printf("Impossibile ottenere IntuitionBase pointer, impossibile aprire la libreria\n");
  67. }else{
  68. IDOS->Printf("\nIntuitionBase pointer ottenuto, libreria aperta correttamente\n");
  69. }
  70. IIntuition = (struct IntuitionIFace *)IExec->GetInterface(IntuitionBase,"main",1,NULL);
  71. if(IIntuition == NULL){
  72. IDOS->Printf("Impossibile ottenere Intuition Interface\n");
  73. return(0);
  74. }else{
  75. IDOS->Printf("Intuition Interface ottenuta correttamente\n");
  76. }
  77.  
  78. WindowBase = IIntuition->OpenClass("window.class", 52, &WindowClass);
  79. if(WindowBase == NULL){
  80. IDOS->Printf("impossibile ottenere WindowBase, impossibile aprire la Window class\n");
  81. return(0);
  82. }else{
  83. IDOS->Printf("WindowBase ottenuta correttamente, window class aperta correttamente\n");
  84. }
  85.  
  86. LayoutBase = IIntuition->OpenClass("gadgets/layout.gadget", 52, &LayoutClass);
  87. if(LayoutBase == NULL){
  88. IDOS->Printf("Impossibile ottenere LayoutBase, impossibile aprire LayoutClass\n");
  89. return(0);
  90. }else{
  91. IDOS->Printf("Layout Base ottenuta correttamente, classe aperta corretamente\n");
  92. }
  93.  
  94. ButtonBase = (struct ClassLibrary *)IIntuition->OpenClass("gadgets/button.gadget", 52, &ButtonClass);
  95. if(ButtonBase == NULL){
  96. IDOS->Printf("Impossibile ottenere ButtonBase, impossibile aprire la ButtonClass\n");
  97. return(0);
  98. }else{
  99. IDOS->Printf("Button Base ottenuta correttamente!\n");
  100. }
  101.  
  102. ListBrowserBase = (struct Library *)IIntuition->OpenClass("gadgets/listbrowser.gadget", 52, &ListBrowserClass);
  103. if(ListBrowserBase == NULL){
  104. IDOS->Printf("Impossibile ottenere ListBrowserBase, impossibile aprire la ListBrowserClass\n");
  105. return(0);
  106. }else{
  107. IDOS->Printf("ListBrowserBase ottenuta correttamente!\n");
  108. }
  109.  
  110. IListBrowser = (struct ListBrowserIFace *)IExec->GetInterface((struct Library *)ListBrowserBase,"main",1,NULL);
  111. if(IListBrowser == NULL){
  112. IDOS->Printf("Impossibile ottenere ListBrowser Interface\n");
  113. return(0);
  114. }else{
  115. IDOS->Printf("ListBrowser Interface ottenuta correttamente\n");
  116.  
  117. column_info = IListBrowser->AllocLBColumnInfo(1,
  118. LBCIA_Column, 0,
  119. LBCIA_Title, "ListBrowser Example",
  120. TAG_END);
  121.  
  122. IExec->NewList((struct List *)&listbrowser_list);
  123. for(i=0;nodetexts<em>;i++){
  124. node=IListBrowser->AllocListBrowserNode(1,
  125. //LBNA_Flags, LBFLG_CUSTOMPENS,
  126. LBNA_Column, 0,
  127. LBNCA_Text, nodetexts<em>,
  128. //LBNCA_FGPen, TEXTPEN,
  129. TAG_END);
  130. IExec->AddTail((struct List *)&listbrowser_list,node);
  131. }
  132.  
  133. objects[OID_FINESTRA] = IIntuition->NewObject(NULL, "window.class",
  134. WA_Activate, TRUE,
  135. WA_DepthGadget,TRUE,
  136. WA_DragBar, TRUE,
  137. WA_CloseGadget,TRUE,
  138. WA_SizeGadget, TRUE,
  139. WA_Width, 200,
  140. WA_Height, 200,
  141. WA_Title, "ListBrowser Test Window",
  142. WINDOW_Layout, IIntuition->NewObject(NULL, "layout.gadget",
  143. LAYOUT_AddChild, objects[OID_LISTBROWSER] = IIntuition->NewObject(NULL, "listbrowser.gadget",
  144. LISTBROWSER_ColumnInfo, column_info,
  145. LISTBROWSER_Labels, &listbrowser_list,
  146. LISTBROWSER_MultiSelect, FALSE,
  147. TAG_END),
  148. TAG_END),
  149. TAG_END);
  150.  
  151.  
  152. if(objects[OID_FINESTRA] != NULL)
  153. {
  154. struct Window *window = (struct Window *)IIntuition->IDoMethod(objects[OID_FINESTRA], WM_OPEN, NULL); // APRO FINESTRA
  155. if(window != NULL)
  156. {
  157. uint32 signal = 0;
  158. IIntuition->GetAttr(WINDOW_SigMask,objects[OID_FINESTRA],&signal);
  159. BOOL done = FALSE;
  160.  
  161. while(!done) // FINO A CHE DONE NON DIVENTA TRUE ESEGUI IL CICLO
  162. {
  163. uint32 wait = IExec->Wait(signal|SIGBREAKF_CTRL_C);
  164.  
  165. if(wait & SIGBREAKF_CTRL_C) // SE UNO DEI DUE OPERANDI E' 0 RESTITUISCE ZERO; SE ENTRAMBI SONO 1 RESTITUISCE 1; SE UNO DEI DUE E' ZERO RESTITUISCE ZERO
  166. {
  167. done = TRUE;
  168. break;
  169. }
  170.  
  171. if(wait & signal)
  172. {
  173. uint32 result = WMHI_LASTMSG;
  174. int16 code = 0;
  175.  
  176. while((result = IIntuition->IDoMethod(objects[OID_FINESTRA],WM_HANDLEINPUT,&code)) != WMHI_LASTMSG) // SE NON SONO UGUALI LA CONDIZIONE DIVENTA VERA E QUINDI IL CICLO FINISCE
  177. { // QUINDI SICCOME ORA SONO UGUALI IL CICLO CONTINUA
  178. switch(result & WMHI_CLASSMASK) //CLASSMASK RESTITUISCE LA PARTE BASSA DELLA WORD (L'ID)
  179. {
  180. case WMHI_CLOSEWINDOW:
  181. window = NULL;
  182. done = TRUE;
  183. break;
  184. }
  185. }
  186. }
  187. }
  188. }
  189.  
  190.  
  191.  
  192. IIntuition->DisposeObject(objects[OID_FINESTRA]);
  193. IListBrowser->FreeListBrowserList((struct List *)&listbrowser_list);
  194. IListBrowser->FreeLBColumnInfo(column_info);
  195.  
  196. if(WindowBase){
  197. IIntuition->CloseClass(WindowBase);
  198. IDOS->Printf("\nChiusa la Window class\n");
  199. }
  200. if(LayoutBase){
  201. IIntuition->CloseClass(LayoutBase);
  202. IDOS->Printf("Chiudo la Layout Class\n");
  203. }
  204. if(ButtonBase){
  205. IIntuition->CloseClass(ButtonBase);
  206. IDOS->Printf("Chiudo la Button Class\n");
  207. }
  208. if(ListBrowserBase){
  209. IExec->DropInterface((struct Interface *)IListBrowser);
  210. IIntuition->CloseClass((struct ClassLibrary *)ListBrowserBase);
  211. IDOS->Printf("Chiudo la ListBrowser Class\n");
  212. }
  213. if(IntuitionBase){
  214. IExec->DropInterface((struct Interface *)IIntuition);
  215. IDOS->Printf("Esco liberando l'interfaccia Intuition \n");
  216. IExec->CloseLibrary(IntuitionBase);
  217. IDOS->Printf("Chiudo la libreria Intuition \n");
  218. }
  219. if(DOSBase){
  220. IExec->DropInterface((struct Interface *)IDOS);
  221. printf("Interfaccia Dos liberata\n");
  222. IExec->CloseLibrary(DOSBase);
  223. printf("Chiudo DosLibrary\n\n");
  224. }
  225. }
  226. return RETURN_OK;
  227. }
  228. } // FINE MAIN

trixie
trixie's picture
Offline
Last seen: 6 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: [ListBrowser] error: dereferencing pointer to incomplete...

@Nube

Change line 49 to this:

  1. CONST_STRPTR nodetexts[] = {
  2. "Eins",
  3. "Zwei",
  4. "Drei",
  5. "JaJaJa!",
  6. "Wunderbar!",
  7. NULL
  8. };

to avoid a warning when compiling with the -Wwrite-strings flag. I recommend using this along with -Wall -Werror as your standard compile flags in all your projects.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Nube
Nube's picture
Offline
Last seen: 5 years 6 months ago
Joined: 2012-09-10 02:09
Re: [ListBrowser] error: dereferencing pointer to incomplete...

Thanks for the information trixie! i'll do it!

Log in or register to post comments