Hi,

Am 01.09.2009 um 17:44 schrieb Sir Diddymus:

(defmacro RunQt [args & body]
 `(
   (try
     (QApplication/initialize (into-array [~args]))
     (catch RuntimeException e# (println e#)))
   ~...@body
   (QApplication/exec)))

You have to wrap the try and QApplication/exec call into a `do`:

(do
  (try ....)
  (Qapplication/exec))

(defn -main2 [args]
 (try
   (QApplication/initialize (into-array [args]))
   (catch RuntimeException e (println e)))
 (let [mainWindow (QMainWindow.)]
   (.show mainWindow))
 (QApplication/exec))

`defn` does the `do`-wrapping for you.

You get a NPE, because your macro basically expands to ((try ...) (QApplication/exec)). So the return value of the try is used as "function" which is called on the result of the QApp/exec. Now obviously QApp/initialize returns nil. Hence the exception.

Sincerely
Meikel

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to