Shinmera / qtools

Qtools is a collection of utilities to aid development with CommonQt
https://shinmera.github.io/qtools
zlib License
210 stars 17 forks source link

Windows: The assertion QT::INIT failed. #39

Open phoe opened 5 years ago

phoe commented 5 years ago

On Windows, running a deployed application results in:

$ DEPLOY_DEBUG_BOOT=true ./raptor-splitter.exe
 ==> Performing warm boot.
   -> Runtime directory is C:/Users/Raptor/Downloads/bin/
   -> Resource directory is C:/Users/Raptor/Downloads/bin/
 ==> Running boot hooks.
   -> Loading smoke module QTCORE.
   -> Loading smoke module QTGUI.
 ==> Running Qtools boot hooks.
 ==> Reloading foreign libraries.
 ==> Launching application.
Unhandled SIMPLE-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                    {10002B0523}>:
  The assertion QT::INIT failed.

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {10002B0523}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<SIMPLE-ERROR "~@<The assertion ~S failed~:[.~:; ~
                                           with ~:*~{~S = ~S~^, ~}.~]~:@>" {1003B408D3}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<SIMPLE-ERROR "~@<The assertion ~S failed~:[.~:; ~
                                           with ~:*~{~S = ~S~^, ~}.~]~:@>" {1003B408D3}>)
2: (INVOKE-DEBUGGER #<SIMPLE-ERROR "~@<The assertion ~S failed~:[.~:; ~
                                           with ~:*~{~S = ~S~^, ~}.~]~:@>" {1003B408D3}>)
3: ((FLET "H0" :IN DEPLOY::CALL-ENTRY-PREPARED) #<SIMPLE-ERROR "~@<The assertion ~S failed~:[.~:; ~
                                           with ~:*~{~S = ~S~^, ~}.~]~:@>" {1003B408D3}>)
4: (SB-KERNEL::%SIGNAL #<SIMPLE-ERROR "~@<The assertion ~S failed~:[.~:; ~
                                           with ~:*~{~S = ~S~^, ~}.~]~:@>" {1003B408D3}>)
5: (ERROR #<SIMPLE-ERROR "~@<The assertion ~S failed~:[.~:; ~
                                           with ~:*~{~S = ~S~^, ~}.~]~:@>" {1003B408D3}>)
6: (SB-KERNEL:WITH-SIMPLE-CONDITION-RESTARTS ERROR NIL #<SIMPLE-ERROR "~@<The assertion ~S failed~:[.~:; ~
                                           with ~:*~{~S = ~S~^, ~}.~]~:@>" {1003B408D3}>)
7: (SB-KERNEL:ASSERT-ERROR QT::INIT)
8: (QT::INITIALIZE-SMOKE "qtcore")
9: (QTOOLS:ENSURE-QAPPLICATION :NAME NIL :ARGS NIL :MAIN-THREAD NIL)
10: ((LABELS QTOOLS::MAIN :IN QTOOLS::MAIN-WINDOW-EXEC))
11: (QTOOLS::MAIN-WINDOW-EXEC #<FUNCTION (LAMBDA NIL :IN FURCADIA-POST-SPLITTER:MAIN) {100008D1AB}> :NAME NIL :QAPPLICATION-ARGS NIL :BLOCKING T :MAIN-THREAD NIL :ON-ERROR #<FUNCTION INVOKE-DEBUGGER> :SHOW T :FINALIZE T :BEFORE-EXEC #<FUNCTION (LAMBDA (FURCADIA-POST-SPLITTER::WINDOW) :IN FURCADIA-POST-SPLITTER:MAIN) {100008CEAB}> :AFTER-EXEC NIL)
12: (DEPLOY::CALL-ENTRY-PREPARED #<FUNCTION FURCADIA-POST-SPLITTER:MAIN> #<ASDF/SYSTEM:SYSTEM "furcadia-post-splitter"> #<QTOOLS:QT-PROGRAM-OP >)
13: ((LAMBDA NIL :IN UIOP/IMAGE:RESTORE-IMAGE))
14: (UIOP/IMAGE:CALL-WITH-FATAL-CONDITION-HANDLER #<CLOSURE (LAMBDA NIL :IN UIOP/IMAGE:RESTORE-IMAGE) {1003AC1B7B}>)
15: ((FLET SB-UNIX::BODY :IN SAVE-LISP-AND-DIE))
16: ((FLET "WITHOUT-INTERRUPTS-BODY-14" :IN SAVE-LISP-AND-DIE))
17: ((LABELS SB-IMPL::RESTART-LISP :IN SAVE-LISP-AND-DIE))
18: ("foreign function: #x43207B")
19: ("foreign function: #x4037D8")

unhandled condition in --disable-debugger mode, quitting

A workaround is to use CFFI to manually load the foreign libraries before invoking the Qt application:

(defun main ()
  #+win32
  (dolist (lib '("smokebase.dll" "smokeqtcore.dll" "smokeqtgui.dll"))
    (cffi:load-foreign-library lib))
  (with-main-window (window 'main-window)
    (q+:set-style-sheet qt:*qapplication* *stylesheet*)))
phoe commented 5 years ago

Reproduced on OS X and Linux, too.

Zrzut ekranu z 2019-10-26 20-49-10

Zrzut ekranu z 2019-10-26 20-57-35

The following workaround works well for me:

(defun main ()
  (dolist (lib '("smokebase" "smokeqtcore" "smokeqtgui"))
    (cffi:load-foreign-library (format nil 
                                       #+win32 "~A.dll"
                                       #+darwin "qtlibs!~A.dylib"
                                       #+linux "qtlibs!~A.so"
                                       lib)))
  (with-main-window (window 'main-window)
    (q+:set-style-sheet qt:*qapplication* *stylesheet*)))
phoe commented 4 years ago

Still reproducible on the latest Quicklisp dist.