Qbasicnews.com

Full Version: BUG Report “color.bas” Iup Library example
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi:

The callback function for the button is never called.

According to the IUP help file, IupOpen() must be called before any other Iup function.

Moving IupOpen() up a bit, and removing the “end 1” from function ok_cb will fix the problem.

“end 1” looks like stray debug code that was forgotten.

Have fun

Garvan
Thanks, it works now. I did a direct translation from http://www.tecgraf.puc-rio.br/iup/en/exa...iupcolor.c, i guess they never tested it.. ow..
The bad thing about IUP is that the app crashes sometimes.
Take this example and you will see that when you press the button sometimes the messegebox appears, and sometimes it just crashes.
Code:
' iup example
' static lib used

option explicit

#INCLUDE "win32/kernel32.bi"
#INCLUDE "win32/user32.bi"
#INCLUDE "win32/gdi32.bi"
#INCLUDE "win32/commctrl32.bi"
#INCLUDE "win32/commdlg32.bi"
#INCLUDE "win32/shellapi.bi"
#INCLUDE "win32/ole32.bi"
#INCLUDE "win32/advapi32.bi"
#INCLUDE "win32/crt.bi"

#inclib "coldname"

#include once "iup/iup.bi"

#define NULL 0

''
function ok_cb cdecl (Ihandle) as integer
  IupMessage("IupMessage Example", "Press the button")
  
  return IUP_DEFAULT
end function

''''''''''
'' main ''
''      ''
''''''''''
IF IupOpen() = IUP_ERROR THEN

  IupMessage("ERROR", "Not able to init IUP")

ELSE

  dim as Ihandle ptr ok_button
  dim as Ihandle ptr main_dlg

  ok_button = IupButton("Apply","ok_act")

  main_dlg = IupDialog _
      ( Iuphbox _
                ( _
                 IupFill(), _
                      ok_button _
               , IupFill() _
          , NULL) _
      )

  IupSetFunction("ok_act", @ok_cb)

  IupShowXY(main_dlg, IUP_CENTER, IUP_CENTER)

  IupMainLoop()
  IupClose()

End IF

end 0
weird...

BTW: tested on WinXP pro with P4-3GHz-HT
I think the callbacks have no arguments, the handle must be looked up by name using IupGetHandle("") etc.. removing the handle param no crashes happened.
Quote:I think the callbacks have no arguments, the handle must be looked up by name using IupGetHandle("") etc.. removing the handle param no crashes happened.
Tried this already in all possible variants - it crashes 50% of the time.

Maybe it's the SP2 of XP? :barf:

But suppose it's iup Cry

Regarding handles:
if you look at some example code, some callbacks have 3 param...
True, there's a handle, just traced it on a debugger, the stack is cleaned after the callback is called.

Weird enough, both ways worked without crashing (same XP pro SP2 here), but i used the DLL version, i don't have the IUP static lib.
Hi:

Your sample crashes here also with a static lib. I did not notice this problem before with my own code.

I converted the code to C and linked with the same static lib, and it did not crash!!!

Have fun

Garvan

WinXP Home, SP2.
It sounds like a cdecl bug in fb...
There's nothing wrong with the calling convention, FB is pushing the same arguments in the same order as gcc does, and the stack is poped the same way (gcc aligns call stacks to paragraph-boundaries, but that changes nothing). Complex libs like GTK and Wx also use cdecl callbacks, and they always worked.

The problem seems to be while building IUP as a static lib, running the same example would generate no expections in XP, but when using a debugger, it will be filled with these error messages: "Invalid Address specified to RtlFreeHeap( 003F0000, 0014C9E8 )", and the ntdll.DbgBreakPoint will be called all the time. The callback is never reached. The address 0014C9E8 points to the IUPWIN_NOT_WM_SIZE static string, i've no idea why it's being free'ed.

Or IUP needs some kind of static initialization that the gcc crt may do or else i've no idea.. only static objects would need that, dunno..
Vic,
it would be nice to distinguish the lib's better when using #inclib.
If #inclib "iup" is set, libiup.dll.a (for the dll) is used, even if there is libiup.a (for the static lib).

Would like to propose the need to use #inclib "iup.dll" for using libiup.dll.a (as example).

If this would be in place it should be possible to use *.a files for static lib's and dll's simultaneously.
And with the use of a compiler switch #ifndef and #define to compile either way.

Hope you take this in consideration Big Grin

Thanks
Pages: 1 2