simonkrauter / NiGui

Cross-platform desktop GUI toolkit written in Nim
MIT License
724 stars 49 forks source link

msgbox fails with --gc:arc #114

Closed qqtop closed 3 years ago

qqtop commented 3 years ago
# test.nim
# simplified example to show issue with msgbox if compiled with --gc:arc/orc

import nigui
import nigui/msgbox

app.init()

var window = newWindow()
window.width = 1280 
window.height = 800 

window.onCloseClick = proc(event: CloseClickEvent) =
  case window.msgBox("你想退出吗 ?", " 退出?", " Leave ", " Minimize ", " Abort ")
  of 1: window.dispose()
  of 2: window.minimize()
  else: discard

proc main() = 
   var postflag = false
   if window.msgBox("Post new record ?", "Post ? ", "Yes", "Abort /  取消 ") == 1:
      postflag = true
   else: 
      postflag = false 

   echo postflag

when isMainModule:
  window.show()
  main()
  app.run()

works as expected with nim c -r test.nim fails with nim c --gc:arc -r test.nim

part of the trace:

/home/lxuser/.nimble/pkgs/nigui-0.2.4/nigui/msgbox.nim(81) msgBox
/home/lxuser/.nimble/pkgs/nigui-0.2.4/nigui.nim(1114) sleep
/home/lxuser/.nimble/pkgs/nigui-0.2.4/nigui/private/gtk3/platform_impl.nim(362) processEvents
/home/lxuser/.nimble/pkgs/nigui-0.2.4/nigui/private/gtk3/platform_impl.nim(304) pControlButtonReleaseSignal
/home/lxuser/.nimble/pkgs/nigui-0.2.4/nigui.nim(821) handleClickEvent
/home/lxuser/.nimble/pkgs/nigui-0.2.4/nigui.nim(1883) handleClickEvent
/home/lxuser/.choosenim/toolchains/nim-#devel/lib/system.nim(866) buttonClick
/home/lxuser/.choosenim/toolchains/nim-#devel/lib/system/arc.nim(172) nimDestroyAndDispose
/home/lxuser/.choosenim/toolchains/nim-#devel/lib/system/arc.nim(172) nimDestroyAndDispose

compiling with -d:useMalloc it says malloc(): unsorted double linked list corrupted

ghost commented 3 years ago

works now (probably was broken because of https://github.com/nim-lang/Nim/issues/17003)

simonkrauter commented 3 years ago

As Yardanico wrote, it works with Nim 1.4.4.