Re: [wxhaskell-users] Windows 7 GetCommandLine call interference

2015-04-04 Thread Michael Jones
I finally solved the compile problem. Running "cabal clean” in the original 
tree fixed it. I have no idea how it mucked with the sandbox, but it did. After 
I did the clean, even more things failed, but after recreating the sandbox it 
worked. I had tried to recreate the sandbox before and it did not help. It 
required both a clean of the source tree and a recreation of the sandbox.


On Apr 4, 2015, at 5:04 PM, Michael Jones  wrote:

> Henk-Jan,
> 
> I think you are right about Windows, but it does pass them on Linux, and this 
> does make my app work on Ubuntu. It is not the RTS args that are the problem, 
> it is the args for the application that come after. Windows has the further 
> problem of bypassing the passed args completely. My take was that once 
> Windows has a way to stop the Win32 call, it still has the problem this 
> solved.
> 
> BTW,
> 
> I compiled up wxWidgets 3.0.2 on Ubuntu so I could try to hack it a bit, and 
> then compile the git head of wxHaskell as referenced in a sandbox, and 
> compiled by ghc 7.8.4 and get this link error:
> 
> .../.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/wxc-0.92.0.0/libwxc.so: 
> undefined reference to `wxDateTime::SetHour(unsigned 
> short)@WXU_UNOFFICIAL_3.0’
> 
> I can’t find any references WXU_UNOFFICIAL_3.0 in any code, and the @WXU… is 
> unfamiliar to me.
> 
> I ran ./configure for wxHaskell and it finds 3.0.2. Yet the problem persists. 
> My assumption is I can run ./configure in the source tree and then reference 
> that tree in a sandbox. 
> 
> I remembered that when I installed wxWidgets with apt-get it had names with 
> “unofficial” in them. When I removed it I used apt-get purge to get rid of 
> any configurations. Is there something that might have been left behind by 
> the apt-get version?
> 
> Mike
> 
> 
> 
> 
> On Apr 4, 2015, at 4:55 PM, Henk-Jan van Tuyl  wrote:
> 
>> On Sat, 04 Apr 2015 21:19:43 +0200, Michael Jones  wrote:
>> 
>>> I have made a solution to the args problem. To review, if the latest code 
>>> on github is used on Ubuntu, and if agreements are passed on the command 
>>> line of the application, wxHaskell does a “getArgs” and passes them on, and 
>>> then there is an error on the command line. On Windows with the most recent 
>>> wxWidgets code, it pops a similar dialog.
>>> 
>>> To get around the problem, I created startExt, runExt, and argsOnInitExt so 
>>> that I can pass a [String]. This allows me to filter out agreements not 
>>> destined for wx.
>>> 
>>> I have attached a patch below to show what I did.
>>> 
>>> Perhaps one of the developers can give this some consideration. I can 
>>> certainly post the patch in the bug tracker if desired, just tell me where 
>>> it is. I am not sure if the one on source forge is in use or not, as the 
>>> last date is Aug 2014.
>> 
>> The bug tracker on SourceForge is still in use, it has been quiet for a 
>> while in wxHaskell world.
>> 
>> The patch is not the solution, I wish it were that simple. GHC's run time 
>> system filters out the RTS parameters, this can be demonstrated with the 
>> following program (Arguments.hs):
>> 
>>> import System.Environment
>>> 
>>> main = getArgs >>= print
>> 
>> The command
>> Arguments x +RTS -RTS y
>> results in:
>> ["x","y"]
>> 
>> wxWidgets (at least on Windows) does not use the arguments that are passed 
>> with wxcAppInitializeC, but reads directly from the argument buffer.
>> 
>> Regards,
>> Henk-Jan van Tuyl
>> 
>> 
>> -- 
>> Folding@home
>> What if you could share your unused computer power to help find a cure? In 
>> just 5 minutes you can join the world's biggest networked computer and get 
>> us closer sooner. Watch the video.
>> http://folding.stanford.edu/
>> 
>> 
>> http://Van.Tuyl.eu/
>> http://members.chello.nl/hjgtuyl/tourdemonad.html
>> Haskell programming
>> --
> 
> 
> 
> --
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the 
> conversation now. http://goparallel.sourceforge.net/
> ___
> wxhaskell-users mailing list
> wxhaskell-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wxhaskell-users



--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
wxhaskell-users mailing list
wxhaskell-use

Re: [wxhaskell-users] Windows 7 GetCommandLine call interference

2015-04-04 Thread Michael Jones
Henk-Jan,

I think you are right about Windows, but it does pass them on Linux, and this 
does make my app work on Ubuntu. It is not the RTS args that are the problem, 
it is the args for the application that come after. Windows has the further 
problem of bypassing the passed args completely. My take was that once Windows 
has a way to stop the Win32 call, it still has the problem this solved.

BTW,

I compiled up wxWidgets 3.0.2 on Ubuntu so I could try to hack it a bit, and 
then compile the git head of wxHaskell as referenced in a sandbox, and compiled 
by ghc 7.8.4 and get this link error:

.../.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/wxc-0.92.0.0/libwxc.so: undefined 
reference to `wxDateTime::SetHour(unsigned short)@WXU_UNOFFICIAL_3.0’

I can’t find any references WXU_UNOFFICIAL_3.0 in any code, and the @WXU… is 
unfamiliar to me.

I ran ./configure for wxHaskell and it finds 3.0.2. Yet the problem persists. 
My assumption is I can run ./configure in the source tree and then reference 
that tree in a sandbox. 

I remembered that when I installed wxWidgets with apt-get it had names with 
“unofficial” in them. When I removed it I used apt-get purge to get rid of any 
configurations. Is there something that might have been left behind by the 
apt-get version?

Mike




On Apr 4, 2015, at 4:55 PM, Henk-Jan van Tuyl  wrote:

> On Sat, 04 Apr 2015 21:19:43 +0200, Michael Jones  wrote:
> 
>> I have made a solution to the args problem. To review, if the latest code on 
>> github is used on Ubuntu, and if agreements are passed on the command line 
>> of the application, wxHaskell does a “getArgs” and passes them on, and then 
>> there is an error on the command line. On Windows with the most recent 
>> wxWidgets code, it pops a similar dialog.
>> 
>> To get around the problem, I created startExt, runExt, and argsOnInitExt so 
>> that I can pass a [String]. This allows me to filter out agreements not 
>> destined for wx.
>> 
>> I have attached a patch below to show what I did.
>> 
>> Perhaps one of the developers can give this some consideration. I can 
>> certainly post the patch in the bug tracker if desired, just tell me where 
>> it is. I am not sure if the one on source forge is in use or not, as the 
>> last date is Aug 2014.
> 
> The bug tracker on SourceForge is still in use, it has been quiet for a while 
> in wxHaskell world.
> 
> The patch is not the solution, I wish it were that simple. GHC's run time 
> system filters out the RTS parameters, this can be demonstrated with the 
> following program (Arguments.hs):
> 
>> import System.Environment
>> 
>> main = getArgs >>= print
> 
> The command
>  Arguments x +RTS -RTS y
> results in:
>  ["x","y"]
> 
> wxWidgets (at least on Windows) does not use the arguments that are passed 
> with wxcAppInitializeC, but reads directly from the argument buffer.
> 
> Regards,
> Henk-Jan van Tuyl
> 
> 
> -- 
> Folding@home
> What if you could share your unused computer power to help find a cure? In 
> just 5 minutes you can join the world's biggest networked computer and get us 
> closer sooner. Watch the video.
> http://folding.stanford.edu/
> 
> 
> http://Van.Tuyl.eu/
> http://members.chello.nl/hjgtuyl/tourdemonad.html
> Haskell programming
> --



--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users


Re: [wxhaskell-users] Windows 7 GetCommandLine call interference

2015-04-04 Thread Henk-Jan van Tuyl
On Sat, 04 Apr 2015 21:19:43 +0200, Michael Jones   
wrote:

> I have made a solution to the args problem. To review, if the latest  
> code on github is used on Ubuntu, and if agreements are passed on the  
> command line of the application, wxHaskell does a “getArgs” and passes  
> them on, and then there is an error on the command line. On Windows with  
> the most recent wxWidgets code, it pops a similar dialog.
>
> To get around the problem, I created startExt, runExt, and argsOnInitExt  
> so that I can pass a [String]. This allows me to filter out agreements  
> not destined for wx.
>
> I have attached a patch below to show what I did.
>
> Perhaps one of the developers can give this some consideration. I can  
> certainly post the patch in the bug tracker if desired, just tell me  
> where it is. I am not sure if the one on source forge is in use or not,  
> as the last date is Aug 2014.

The bug tracker on SourceForge is still in use, it has been quiet for a  
while in wxHaskell world.

The patch is not the solution, I wish it were that simple. GHC's run time  
system filters out the RTS parameters, this can be demonstrated with the  
following program (Arguments.hs):

> import System.Environment
>
> main = getArgs >>= print

The command
   Arguments x +RTS -RTS y
results in:
   ["x","y"]

wxWidgets (at least on Windows) does not use the arguments that are passed  
with wxcAppInitializeC, but reads directly from the argument buffer.

Regards,
Henk-Jan van Tuyl


-- 
Folding@home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--

--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
___
wxhaskell-users mailing list
wxhaskell-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxhaskell-users


Re: [wxhaskell-users] Windows 7 GetCommandLine call interference

2015-04-04 Thread Michael Jones
I have made a solution to the args problem. To review, if the latest code on 
github is used on Ubuntu, and if agreements are passed on the command line of 
the application, wxHaskell does a “getArgs” and passes them on, and then there 
is an error on the command line. On Windows with the most recent wxWidgets 
code, it pops a similar dialog.

To get around the problem, I created startExt, runExt, and argsOnInitExt so 
that I can pass a [String]. This allows me to filter out agreements not 
destined for wx.

I have attached a patch below to show what I did.

Perhaps one of the developers can give this some consideration. I can certainly 
post the patch in the bug tracker if desired, just tell me where it is. I am 
not sure if the one on source forge is in use or not, as the last date is Aug 
2014.

Mike

>From 13bd27df2e54972244a59fc38eccc7b9790a176c Mon Sep 17 00:00:00 2001
From: Michael Jones 
Date: Sat, 4 Apr 2015 13:10:49 -0600
Subject: [PATCH] Offer command line args passing at startup

---
 wx/src/Graphics/UI/WX.hs|  5 +
 wxcore/src/haskell/Graphics/UI/WXCore.hs| 10 +-
 wxcore/src/haskell/Graphics/UI/WXCore/Events.hs | 14 +-
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/wx/src/Graphics/UI/WX.hs b/wx/src/Graphics/UI/WX.hs
index f310e63..7827b2f 100644
--- a/wx/src/Graphics/UI/WX.hs
+++ b/wx/src/Graphics/UI/WX.hs
@@ -17,6 +17,7 @@ functionality provided by the "Graphics.UI.WXCore" library.
 module Graphics.UI.WX
   ( -- * Functions
 start
+  , startExt
 -- * Modules
   , module Graphics.UI.WX.Types
   , module Graphics.UI.WX.Attributes
@@ -58,3 +59,7 @@ import Graphics.UI.WXCore
 start :: IO a -> IO ()
 start io
   = run (unitIO io)
+
+startExt :: [String] -> IO a -> IO ()
+startExt args io
+  = runExt args (unitIO io)
\ No newline at end of file
diff --git a/wxcore/src/haskell/Graphics/UI/WXCore.hs 
b/wxcore/src/haskell/Graphics/UI/WXCore.hs
index a6381b2..b276433 100644
--- a/wxcore/src/haskell/Graphics/UI/WXCore.hs
+++ b/wxcore/src/haskell/Graphics/UI/WXCore.hs
@@ -40,6 +40,7 @@ module Graphics.UI.WXCore
 
 -- * Run
 , run
+, runExt
 ) where
 
 import System.Mem( performGC )
@@ -77,6 +78,13 @@ run init
performGC
performGC
 
-
+runExt :: [String] -> IO a -> IO ()
+runExt args init
+  = do enableGUI
+   appOnInitExt args (do wxcAppInitAllImageHandlers
+ init
+ return ())
+   performGC
+   performGC
 
 
diff --git a/wxcore/src/haskell/Graphics/UI/WXCore/Events.hs 
b/wxcore/src/haskell/Graphics/UI/WXCore/Events.hs
index 12ca0a3..668761a 100644
--- a/wxcore/src/haskell/Graphics/UI/WXCore/Events.hs
+++ b/wxcore/src/haskell/Graphics/UI/WXCore/Events.hs
@@ -222,6 +222,7 @@ module Graphics.UI.WXCore.Events
 
 -- * Primitive
 , appOnInit
+, appOnInitExt
 
 -- ** Client data
 , treeCtrlSetItemClientData
@@ -2820,7 +2821,18 @@ appOnInit init
   where
 onDelete ownerDeleted
   = init
-   
+  
+appOnInitExt :: [String] -> IO () -> IO ()
+appOnInitExt args init
+  = do closure  <- createClosure (return () :: IO ()) onDelete (\ev -> return 
())   -- run init on destroy !
+   progName <- getProgName
+   argv <- mapM newCWString (progName:args)
+   let argc = length argv
+   withArray (argv ++ [nullPtr]) $ \cargv -> wxcAppInitializeC closure 
argc cargv
+   mapM_ free argv
+  where
+onDelete ownerDeleted
+  = init 
 
 
 
--
-- 
1.9.1



On Mar 28, 2015, at 7:58 PM, Michael Jones  wrote:

> 
> I also notice that if I use the git repo:head for wxHaskell on Linux, I get a 
> similar error + Usage as windows, but on the command line. The version of 
> wxHaskell that cabal fetches does not have this problem.
> 
> On windows, I took the repo:head because the released wxHaskell that cabal 
> downloads had a compile failure for a ‘long long’
> 
> So perhaps there something that has changed in wxHaskell that causes a 
> generic problem.
> 
> 
> 
> On Mar 28, 2015, at 7:40 PM, Michael Jones  wrote:
> 
>> There is a response from wxWidgets trac
>> 
>> #16935:
>> http://trac.wxwidgets.org/ticket/16935#comment:1
>> 
>> On Mar 28, 2015, at 5:12 PM, Henk-Jan van Tuyl  wrote:
>> 
>>> On Wed, 25 Mar 2015 22:57:12 +0100, Michael Jones 
>>> wrote:
>>> 
 On Win 7...
 
 The latest code on github seems to result in a wxWidgets call to LPTSTR 
 WINAPI GetCommandLine(void);
 
 This results in popping a dialog complaining about command options. On 
 Linux this does not happen. Looks like wxWidgets is trying to use this 
 call to deal with unicode, but it unfortunately bypasses the Haskell 
 argument mechanism and grabs everything including +/-RTS and passes it to 
 wxWidgets for consideration. Perhaps wxHaskell should manage t