Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 8, 2013 0:04:00 GMT 1
I don't use the demo make script. (see my working gcc command line)
The install and install_dev scripts worked fine for me. Make sure you download the correct set of files your OS.
|
|
|
Post by alexfish on Jan 8, 2013 0:17:20 GMT 1
I don't use the demo make script. (see my working gcc command line) The install and install_dev scripts worked fine for me. Make sure you download the correct set of files your OS. Hi John managed to get everything in place as regards the system, but still get the same error. ' IM example that shows an image.
PRAGMA OPTIONS -I/usr/include/iup PRAGMA OPTIONS -I/usr/include/cd PRAGMA OPTIONS -I/usr/include/im PRAGMA LDFLAGS iup PRAGMA LDFLAGS cd PRAGMA LDFLAGS iupcd PRAGMA LDFLAGS im PRAGMA INCLUDE iup.h PRAGMA INCLUDE cd.h PRAGMA INCLUDE cdiup.h PRAGMA INCLUDE im.h PRAGMA INCLUDE im_image.h File '/home/alexfish/Desktop/keepoff/IUP/view.bac'
Line 112: iup_canvas = IupCanvas("do_nothing")
Cause: conflicting types for 'iup_canvas will now go back and try straight C Ok:: had to do a reinstall :: worked 2nd time C works .. Nice bacon fails .. code fails to show the canvas but shows the file dialog shows.. so assume nearly there . can now start looking at the configs , Canvas does not show so assume missing something like if built then showall or similar , because if try to load wrong type of file , the error shows in the terminal Regards alex Got it showing I think but get error loading file .png ' MAIN
IupOpen(NULL,NULL) iup_canvas = IupCanvas("do_nothing") IupSetAttribute(iup_canvas, IUP_BUTTON_CB, "cbButton") IupSetAttribute(iup_canvas, IUP_ACTION, "cbRepaint") iup_dialog = IupDialog(iup_canvas) IupSetAttribute(iup_dialog, IUP_CLOSE_CB, "cbClose") IupSetAttribute(iup_dialog, IUP_SIZE, "HALFxHALF") IupSetFunction("cbRepaint", (Icallback)cbRepaint) IupSetFunction("cbButton", (Icallback)cbButton) IupSetFunction("cbClose", (Icallback)cbClose) IupMap(iup_dialog) cd_canvas = cdCreateCanvas(CD_IUP, iup_canvas) IupSetAttribute(iup_dialog, "cdCanvas", (STRING)cd_canvas) ' This one IupShow(iup_dialog) IupShow(dlg)
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 8, 2013 1:00:25 GMT 1
Like I said, something dumb I did. I removed the dlg = CreateDialog(); routine in the BaCon version but was still using the return value of the function. I should have been using iup_dialog instead. ' IM example that shows an image.
PRAGMA OPTIONS -I/usr/include/iup PRAGMA OPTIONS -I/usr/include/cd PRAGMA OPTIONS -I/usr/include/im PRAGMA LDFLAGS iup PRAGMA LDFLAGS cd PRAGMA LDFLAGS iupcd PRAGMA LDFLAGS im PRAGMA INCLUDE iup.h PRAGMA INCLUDE cd.h PRAGMA INCLUDE cdiup.h PRAGMA INCLUDE im.h PRAGMA INCLUDE im_image.h
PROTO IupGetAttribute, cdCanvasActivate, cdCanvasClear, imcdCanvasPutImage, cdCanvasFlush, imImageDestroy, imFileImageLoadBitmap PROTO IupSetAttribute, IupStoreAttribute, IupGetFile, IupGetDialog, cdKillCanvas, imImageDestroy, IupMessage PROTO IupOpen, CreateDialog, IupCanvas, IupDialog, IupSetFunction, IupMap, cdCreateCanvas, IupShow, IupMainLoop, IupDestroy, IupClose
DECLARE *iup_dialog, *iup_canvas TYPE Ihandle DECLARE *cd_canvas TYPE cdCanvas DECLARE *image TYPE imImage DECLARE ierror TYPE int
disable_repaint = 0
SUB PrintError(int ierror) SELECT ierror CASE IM_ERR_OPEN IupMessage("IM", "Error Opening File.") CASE IM_ERR_MEM IupMessage("IM", "Insuficient memory.") CASE IM_ERR_ACCESS IupMessage("IM", "Error Accessing File.") CASE IM_ERR_DATA IupMessage("IM", "Image type not Suported.") CASE IM_ERR_FORMAT IupMessage("IM", "Invalid Format."); CASE IM_ERR_COMPRESS IupMessage("IM", "Invalid or unsupported compression.") DEFAULT IupMessage("IM", "Unknown Error.") END SELECT END SUB
FUNCTION cbRepaint(Ihandle* iup_canvas) cd_canvas = (cdCanvas*)IupGetAttribute(iup_canvas, "cdCanvas") image = (imImage*)IupGetAttribute(iup_canvas, "imImage") IF NOT(cd_canvas) OR disable_repaint THEN RETURN IUP_DEFAULT cdCanvasActivate(cd_canvas) cdCanvasClear(cd_canvas) IF NOT(image) THEN RETURN IUP_DEFAULT imcdCanvasPutImage(cd_canvas, image, 0, 0, image->width, image->height, 0, 0, 0, 0) cdCanvasFlush(cd_canvas) RETURN IUP_DEFAULT END FUNCTION
SUB ShowImage(char* file_name, Ihandle* iup_dialog) image = (imImage*)IupGetAttribute(iup_dialog, "imImage") IF image THEN imImageDestroy(image) IupSetAttribute(iup_dialog, "imImage", NULL) image = imFileImageLoadBitmap(file_name, 0, &ierror) IF ierror THEN PrintError(ierror) IF NOT(image) THEN EXIT SUB IupSetAttribute(iup_dialog, "imImage", (STRING)image) IupStoreAttribute(iup_dialog, "TITLE", file_name); cbRepaint(iup_dialog) END SUB
FUNCTION cbButton(Ihandle* iup_canvas, NUMBER but, NUMBER pressed) char file_name[200] = "*.*" IF (but <> IUP_BUTTON1 OR NOT(pressed)) THEN RETURN IUP_DEFAULT disable_repaint = 1 IF IupGetFile(file_name) <> 0 THEN disable_repaint = 0 RETURN IUP_DEFAULT END IF disable_repaint = 0 ShowImage(file_name, IupGetDialog(iup_canvas)) RETURN IUP_DEFAULT END FUNCTION
FUNCTION cbClose(Ihandle* iup_dialog) cd_canvas = (cdCanvas*)IupGetAttribute(iup_dialog, "cdCanvas") image = (imImage*)IupGetAttribute(iup_dialog, "imImage") IF cd_canvas THEN cdKillCanvas(cd_canvas) IF image THEN imImageDestroy(image) IupSetAttribute(iup_dialog, "cdCanvas", NULL) IupSetAttribute(iup_dialog, "imImage", NULL) RETURN IUP_CLOSE END FUNCTION
' MAIN
IupOpen(NULL,NULL) iup_canvas = IupCanvas("do_nothing") IupSetAttribute(iup_canvas, IUP_BUTTON_CB, "cbButton") IupSetAttribute(iup_canvas, IUP_ACTION, "cbRepaint") iup_dialog = IupDialog(iup_canvas) IupSetAttribute(iup_dialog, IUP_CLOSE_CB, "cbClose") IupSetAttribute(iup_dialog, IUP_SIZE, "HALFxHALF") IupSetFunction("cbRepaint", (Icallback)cbRepaint) IupSetFunction("cbButton", (Icallback)cbButton) IupSetFunction("cbClose", (Icallback)cbClose) IupMap(iup_dialog) cd_canvas = cdCreateCanvas(CD_IUP, iup_canvas) IupSetAttribute(iup_dialog, "cdCanvas", (STRING)cd_canvas) IupShow(iup_dialog)
cmdln$ = ARGUMENT$ SPLIT cmdln$ BY " " TO opts$ SIZE cnt IF cnt = 2 THEN ShowImage(opts$[1], iup_dialog) ELSE char file_name[1024] = "*.*" IF IupGetFile(file_name) = 0 THEN ShowImage(file_name, iup_dialog) END IF END IF IupMainLoop() IupDestroy(iup_dialog) IupClose()
|
|
|
Post by alexfish on Jan 8, 2013 1:12:51 GMT 1
yep that works in a fashion
but throws a error on load + file dialog needs to be looked at in regards set up
Regards
Alex
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 8, 2013 1:20:31 GMT 1
Everything works fine here. (including passing a image file on the command line)
|
|
|
Post by alexfish on Jan 8, 2013 1:58:02 GMT 1
Everything works fine here. (including passing a image file on the command line) Yep that works But my Lunatic rocket does not fly to the moon and back Looking good though
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 8, 2013 2:01:25 GMT 1
Just updated the code with the final cleanup.
Enjoy!
|
|
|
Post by alexfish on Jan 8, 2013 2:33:47 GMT 1
Valgrind
==19819== HEAP SUMMARY: ==19819== in use at exit: 2,030,487 bytes in 25,563 blocks ==19819== total heap usage: 1,484,352 allocs, 1,458,789 frees, 150,527,357 bytes allocated ==19819== ==19819== LEAK SUMMARY: ==19819== definitely lost: 2,650 bytes in 43 blocks ==19819== indirectly lost: 8,028 bytes in 420 blocks ==19819== possibly lost: 1,197,211 bytes in 14,136 blocks ==19819== still reachable: 822,598 bytes in 10,964 blocks ==19819== suppressed: 0 bytes in 0 blocks ==19819== Rerun with --leak-check=full to see details of leaked memory ==19819== ==19819== For counts of detected and suppressed errors, rerun with: -v ==19819== ERROR SUMMARY: 16 errors from 6 contexts (suppressed: 190 from 13)
Looks ok
The lost look normal for a gtk app
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 8, 2013 5:34:51 GMT 1
We still have one minor issue left. After a file is selected by clicking on the image, it becomes the only image you can select. (file_name issue) The C version works as it should. If you want to see what might be causing this, it would be great. It doesn't jump out at me at the moment. UpdateI found it. Code above corrected.
|
|
|
Post by alexfish on Jan 8, 2013 19:10:49 GMT 1
MM! Today: seem to be back to this bug ,
Cause: conflicting types for 'iup_canvas'
Have tried all the coding right back from first example , all producing same error just wondering if anyone getting same error although have not don a full compare to the c code , Although you mention changes , this can be to confusing when one is trying help So here is what I am looking at C code works at foot of c code you have IupMainLoop(); IupDestroy(dlg); IupClose(); foot of bacon IupMainLoop() IupDestroy(iup_dialog) IupClose() the gui c code static Ihandle* CreateDialog(void) { Ihandle *iup_dialog; Ihandle *iup_canvas; cdCanvas* cd_canvas;
iup_canvas = IupCanvas("do_nothing"); IupSetAttribute(iup_canvas, IUP_BUTTON_CB, "cbButton"); IupSetAttribute(iup_canvas, IUP_ACTION, "cbRepaint"); iup_dialog = IupDialog(iup_canvas); IupSetAttribute(iup_dialog, IUP_CLOSE_CB, "cbClose"); IupSetAttribute(iup_dialog, IUP_SIZE, "HALFxHALF");
IupSetFunction("cbRepaint", (Icallback)cbRepaint); IupSetFunction("cbButton", (Icallback)cbButton); IupSetFunction("cbClose", (Icallback)cbClose);
IupMap(iup_dialog);
cd_canvas = cdCreateCanvas(CD_IUP, iup_canvas); IupSetAttribute(iup_dialog, "cdCanvas", (char*)cd_canvas);
return iup_dialog; }
Bacon ' MAIN gui IupOpen(NULL,NULL) iup_canvas = IupCanvas("do_nothing") IupSetAttribute(iup_canvas, IUP_BUTTON_CB, "cbButton") IupSetAttribute(iup_canvas, IUP_ACTION, "cbRepaint") iup_dialog = IupDialog(iup_canvas) IupSetAttribute(iup_dialog, IUP_CLOSE_CB, "cbClose") IupSetAttribute(iup_dialog, IUP_SIZE, "HALFxHALF") IupSetFunction("cbRepaint", (Icallback)cbRepaint) IupSetFunction("cbButton", (Icallback)cbButton) IupSetFunction("cbClose", (Icallback)cbClose) IupMap(iup_dialog) cd_canvas = cdCreateCanvas(CD_IUP, iup_canvas) IupSetAttribute(iup_dialog, "cdCanvas", (STRING)cd_canvas) IupShow(iup_dialog)
Finally sussed it Parsing or scripting ERRORS "Spaces" required OK things Now working John can you look at these lines :: re the SPLIT u need esc if [/li][li] does not exist , else will get out of bounds , cmdln$ = ARGUMENT$ SPLIT cmdln$ BY " " TO opts$ SIZE cnt IF LEN(opts$[1]) THEN ShowImage(opts$[1], iup_dialog) ELSE char file_name[1024] = "*.*" IF IupGetFile(file_name) = 0 THEN ShowImage(file_name, iup_dialog) END IF END IF Now got it working , '@ John can you post bz2 file for compare Regards Alex
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 8, 2013 20:49:51 GMT 1
Remember my post when I said I found the dumb thing I did? I removed a function in the C version that it's return was dlg. That's what was causing the dialog not to show for me.
The code on the AllBasic.info site and the BaCon code above is working fine for me without any errors.
[/li][li] does not exist , else will get out of bounds , [/quote]
If you don't pass a image filename on the command line the file select dialog opens to select one. I don't understand the out of bounds comment.
|
|
|
Post by alexfish on Jan 8, 2013 21:11:44 GMT 1
Remember my post when I said I found the dumb thing I did? I removed a function in the C version that it's return was dlg. That's what was causing the dialog not to show for me. The code on the AllBasic.info site and the BaCon code above is working fine for me without any errors. In bacon for opt args [1] can put at head of example OPTION BASE 1 then will have to further resolve the parser in using command line Regards Alex
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 8, 2013 21:23:34 GMT 1
The way I understand how ARGUMENTS$ works is it builds a space delimited string. (like SB) and the programmer normally SPLITs the string by the space delimiter. Without setting the OPTION BASE, (default 0) the executable name = opts$[0] and the image filename is opts$[1].
Am I missing something?
Update
I see what you are saying about the bounds checking. Strange it doesn't error like this every time.
jrs@laptop:~/BaCon/B29$ ./im_view ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause. jrs@laptop:~/BaCon/B29$
Fix
cmdln$ = ARGUMENT$ SPLIT cmdln$ BY " " TO opts$ SIZE cnt IF cnt = 2 THEN ShowImage(opts$[1], iup_dialog) ELSE char file_name[1024] = "*.*" IF IupGetFile(file_name) = 0 THEN ShowImage(file_name, iup_dialog) END IF END IF
|
|
|
Post by alexfish on Jan 9, 2013 0:26:09 GMT 1
Put this code in and can forget about the OPTION BASE
Normally I would put this into a Function where OPTION BASES can be defined or left as is, there may be a time when need to set different option bases
cmdln$ = ARGUMENT$ SPLIT cmdln$ BY " " TO opts$ SIZE cnt IF cnt = 2 THEN IF LEN(opts$[1]) THEN ShowImage(opts$[1], iup_dialog) ELSE char file_name[1024] = "*.*" IF IupGetFile(file_name) = 0 THEN ShowImage(file_name, iup_dialog) END IF END IF END IF
BR
Alex
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 9, 2013 0:28:33 GMT 1
Too funny !!!
We posted the same fix in unison.
|
|