librelist archives

« back to archive

Weird Shoes bug?

Weird Shoes bug?

From:
Kádár Tamás (KTamas)
Date:
2010-02-23 @ 15:09
Hi

So I have an app that does some OLE automation among other things, it
goes something like this:

Shoes.app do

def do_stuff(filename)
    -- snip --
    word = WIN32OLE.new("Word.Application")
    word.documents.open(File.expand_path(filename))
    word.activedocument.saveas("#{File.expand_path(filename)}.txt",
WordConst::WdFormatText, false, "", false, "", false, false, false,
false, false, 65001)
    word.activedocument.close(WordConst::WdDoNotSaveChanges)
    word.quit
   --- snip ----
   [ do stuff with the saved .txt file ]
end

button "Select File..." do
   do_stuff(ask_open_file)
end

end

So it basicly saves a word document as a .txt file then deos some
manipulation on it. Now, what's expected to happen is to do the whole
thing linearly, opening the word document, saving it, quitting word,
doing the manipulation, back to the UI. However, what happens is:

1. Word opens
2. The document opens
3. Word saves the file as text
4. manipulating happens with the file
5. Word stays open (!), Shoes app crashes (disappears simply) after
finishing the text file manipulation

Anyone has any ideas why?

Thanks,
Tamas

Re: [shoes] Weird Shoes bug?

From:
i5m
Date:
2010-02-23 @ 17:21
I think what is happening is that "word.quit" is quitting Shoes itself. If
you replace it with Shoes.quit you get the same result. I don't understand
exactly why. "word.exit" produces the same result.

I haven't been able to figure out a work around, I had a go at putting it in
a new thread, and an external module, but no luck.


-----------------------
i5m.co.uk
GPG Key: 0xA18A602B


2010/2/23 Kádár Tamás (KTamas) <ktamas@ktamas.com>

> Hi
>
> So I have an app that does some OLE automation among other things, it
> goes something like this:
>
> Shoes.app do
>
> def do_stuff(filename)
>    -- snip --
>    word = WIN32OLE.new("Word.Application")
>    word.documents.open(File.expand_path(filename))
>    word.activedocument.saveas("#{File.expand_path(filename)}.txt",
> WordConst::WdFormatText, false, "", false, "", false, false, false,
> false, false, 65001)
>    word.activedocument.close(WordConst::WdDoNotSaveChanges)
>    word.quit
>   --- snip ----
>   [ do stuff with the saved .txt file ]
> end
>
> button "Select File..." do
>   do_stuff(ask_open_file)
> end
>
> end
>
> So it basicly saves a word document as a .txt file then deos some
> manipulation on it. Now, what's expected to happen is to do the whole
> thing linearly, opening the word document, saving it, quitting word,
> doing the manipulation, back to the UI. However, what happens is:
>
> 1. Word opens
> 2. The document opens
> 3. Word saves the file as text
> 4. manipulating happens with the file
> 5. Word stays open (!), Shoes app crashes (disappears simply) after
> finishing the text file manipulation
>
> Anyone has any ideas why?
>
> Thanks,
> Tamas
>

Re: [shoes] Weird Shoes bug?

From:
Kádár Tamás
Date:
2010-02-24 @ 09:19
Oh yeah I totally forgot about that, thanks. Lowecase quit works (haha, 
oughta work) cause win32ole does some method_missing magic, but yeah, Quit
is the correct version. I'll dive into shoes' sources today...
 

-----Original Message-----
From: i5m <i5ivem@googlemail.com>
Date: Wed, 24 Feb 2010 08:26:45 
To: <shoes@librelist.com>
Subject: Re: [shoes] Weird Shoes bug?

It is a weird bug. I've just tried a nonsensical app:

Shoes.app do
    sometext = para "Hello"
    sometext.quit
end

It never sees the light of day.

However, I've figured out your problem. You need to do word.*Q*uit not word.
*q*uit. This quits word and not Shoes.




-----------------------
i5m.co.uk
GPG Key: 0xA18A602B


2010/2/23 Kádár Tamás (KTamas) <ktamas@ktamas.com>

> Oooookay. Wow. That's some weird-ass bug. I start to wonder if I call
> *any* class' .quit / .exit method, will I get a same result? Gotta
> test that tomorrow... There has got to be some sort of workaround. Or
> even better, some sort of fix for Shoes itself...
>
>

Re: [shoes] Weird Shoes bug?

From:
i5m
Date:
2010-02-24 @ 10:26
I forgot to check last night if the same bug exists on OSX. I'm guessing
so. Relevant bit seems to be in ruby.c

http://github.com/shoes/shoes/blob/master/shoes/ruby.c#L4701-4702

I'm assuming it's parsing the code, picking up the 'quit' method (whatever
it's attached to) and thus quitting. Although perhaps it's not parsing
anything? And just defining a quit method that works whatever you put it on?
Is it because it's a Kernel method and so applies to all objects?

My naive way of fixing this would be to just rename the method to
"shoesquit" or something, but I realise that is not the right way.


-----------------------
i5m.co.uk
GPG Key: 0xA18A602B


2010/2/24 Kádár Tamás <ktamas@ktamas.com>

> Oh yeah I totally forgot about that, thanks. Lowecase quit works (haha,
> oughta work) cause win32ole does some method_missing magic, but yeah, Quit
> is the correct version. I'll dive into shoes' sources today...
>
> ------------------------------
> *From: * i5m <i5ivem@googlemail.com>
> *Date: *Wed, 24 Feb 2010 08:26:45 +0000
> *To: *<shoes@librelist.com>
> *Subject: *Re: [shoes] Weird Shoes bug?
>
> It is a weird bug. I've just tried a nonsensical app:
>
> Shoes.app do
>     sometext = para "Hello"
>     sometext.quit
> end
>
> It never sees the light of day.
>
> However, I've figured out your problem. You need to do word.*Q*uit not
> word.*q*uit. This quits word and not Shoes.
>
>
>
>
> -----------------------
> i5m.co.uk
> GPG Key: 0xA18A602B
>
>
> 2010/2/23 Kádár Tamás (KTamas) <ktamas@ktamas.com>
>
>> Oooookay. Wow. That's some weird-ass bug. I start to wonder if I call
>> *any* class' .quit / .exit method, will I get a same result? Gotta
>> test that tomorrow... There has got to be some sort of workaround. Or
>> even better, some sort of fix for Shoes itself...
>>
>>

Re: [shoes] Weird Shoes bug?

From:
Kádár Tamás (KTamas)
Date:
2010-02-24 @ 10:32
Yeah I think that might also break things. Since this bug is in the C
part of Shoes, I'm guessing it's pretty damn deep. Unfortunatelly, I'm
not quite confident and experienced to touch those parts... :(

On Wed, Feb 24, 2010 at 11:26 AM, i5m <i5ivem@googlemail.com> wrote:
> I forgot to check last night if the same bug exists on OSX. I'm guessing
> so. Relevant bit seems to be in ruby.c
> http://github.com/shoes/shoes/blob/master/shoes/ruby.c#L4701-4702
> I'm assuming it's parsing the code, picking up the 'quit' method (whatever
> it's attached to) and thus quitting. Although perhaps it's not parsing
> anything? And just defining a quit method that works whatever you put it on?
> Is it because it's a Kernel method and so applies to all objects?
> My naive way of fixing this would be to just rename the method to
> "shoesquit" or something, but I realise that is not the right way.
>
> -----------------------
> i5m.co.uk
> GPG Key: 0xA18A602B
>
>
> 2010/2/24 Kádár Tamás <ktamas@ktamas.com>
>>
>> Oh yeah I totally forgot about that, thanks. Lowecase quit works (haha,
>> oughta work) cause win32ole does some method_missing magic, but yeah, Quit
>> is the correct version. I'll dive into shoes' sources today...
>>
>> ________________________________
>> From: i5m <i5ivem@googlemail.com>
>> Date: Wed, 24 Feb 2010 08:26:45 +0000
>> To: <shoes@librelist.com>
>> Subject: Re: [shoes] Weird Shoes bug?
>> It is a weird bug. I've just tried a nonsensical app:
>> Shoes.app do
>>     sometext = para "Hello"
>>     sometext.quit
>> end
>> It never sees the light of day.
>> However, I've figured out your problem. You need to do word.Quit not
>> word.quit. This quits word and not Shoes.
>>
>>
>>
>> -----------------------
>> i5m.co.uk
>> GPG Key: 0xA18A602B
>>
>>
>> 2010/2/23 Kádár Tamás (KTamas) <ktamas@ktamas.com>
>>>
>>> Oooookay. Wow. That's some weird-ass bug. I start to wonder if I call
>>> *any* class' .quit / .exit method, will I get a same result? Gotta
>>> test that tomorrow... There has got to be some sort of workaround. Or
>>> even better, some sort of fix for Shoes itself...
>>>
>
>

Re: [shoes] Weird Shoes bug?

From:
Satoshi Asakawa
Date:
2010-02-24 @ 14:35
Hi Kádár and i5m,

Very interesting discussion. Great! Thank you.
I'm not sure this is bug or not. But let me show the snippet:

class Object
  def quit
    debug 'bye'
  end
end

Shoes.app do
  sometext = para "Hello"
  button('quit'){sometext.quit}
end

You can overwrite `quit` method. ;-)

Cheers,
ashbb

Re: [shoes] Weird Shoes bug?

From:
Kádár Tamás (KTamas)
Date:
2010-02-24 @ 14:54
Yes, thanks. Monkeypatching the Object class is certainly one
solution... but I still consider this a serious (albeit minor) bug.

On Wed, Feb 24, 2010 at 3:35 PM, Satoshi Asakawa <ashbbb@gmail.com> wrote:
> Hi Kádár and i5m,
>
> Very interesting discussion. Great! Thank you.
> I'm not sure this is bug or not. But let me show the snippet:
>
> class Object
>   def quit
>     debug 'bye'
>   end
> end
>
> Shoes.app do
>   sometext = para "Hello"
>   button('quit'){sometext.quit}
> end
>
> You can overwrite `quit` method. ;-)
>
> Cheers,
> ashbb
>

Re: [shoes] Weird Shoes bug?

From:
Kádár Tamás (KTamas)
Date:
2010-02-23 @ 22:13
Oooookay. Wow. That's some weird-ass bug. I start to wonder if I call
*any* class' .quit / .exit method, will I get a same result? Gotta
test that tomorrow... There has got to be some sort of workaround. Or
even better, some sort of fix for Shoes itself...

On Tue, Feb 23, 2010 at 6:21 PM, i5m <i5ivem@googlemail.com> wrote:
> I think what is happening is that "word.quit" is quitting Shoes itself. If
> you replace it with Shoes.quit you get the same result. I don't understand
> exactly why. "word.exit" produces the same result.
> I haven't been able to figure out a work around, I had a go at putting it in
> a new thread, and an external module, but no luck.
>
> -----------------------
> i5m.co.uk
> GPG Key: 0xA18A602B
>
>
> 2010/2/23 Kádár Tamás (KTamas) <ktamas@ktamas.com>
>>
>> Hi
>>
>> So I have an app that does some OLE automation among other things, it
>> goes something like this:
>>
>> Shoes.app do
>>
>> def do_stuff(filename)
>>    -- snip --
>>    word = WIN32OLE.new("Word.Application")
>>    word.documents.open(File.expand_path(filename))
>>    word.activedocument.saveas("#{File.expand_path(filename)}.txt",
>> WordConst::WdFormatText, false, "", false, "", false, false, false,
>> false, false, 65001)
>>    word.activedocument.close(WordConst::WdDoNotSaveChanges)
>>    word.quit
>>   --- snip ----
>>   [ do stuff with the saved .txt file ]
>> end
>>
>> button "Select File..." do
>>   do_stuff(ask_open_file)
>> end
>>
>> end
>>
>> So it basicly saves a word document as a .txt file then deos some
>> manipulation on it. Now, what's expected to happen is to do the whole
>> thing linearly, opening the word document, saving it, quitting word,
>> doing the manipulation, back to the UI. However, what happens is:
>>
>> 1. Word opens
>> 2. The document opens
>> 3. Word saves the file as text
>> 4. manipulating happens with the file
>> 5. Word stays open (!), Shoes app crashes (disappears simply) after
>> finishing the text file manipulation
>>
>> Anyone has any ideas why?
>>
>> Thanks,
>> Tamas
>
>

Re: [shoes] Weird Shoes bug?

From:
i5m
Date:
2010-02-24 @ 08:26
It is a weird bug. I've just tried a nonsensical app:

Shoes.app do
    sometext = para "Hello"
    sometext.quit
end

It never sees the light of day.

However, I've figured out your problem. You need to do word.*Q*uit not word.
*q*uit. This quits word and not Shoes.




-----------------------
i5m.co.uk
GPG Key: 0xA18A602B


2010/2/23 Kádár Tamás (KTamas) <ktamas@ktamas.com>

> Oooookay. Wow. That's some weird-ass bug. I start to wonder if I call
> *any* class' .quit / .exit method, will I get a same result? Gotta
> test that tomorrow... There has got to be some sort of workaround. Or
> even better, some sort of fix for Shoes itself...
>
>