Void safety problem

5 messages Options
Embed this post
Permalink
Chris Saunders-4

Void safety problem

Reply Threaded More More options
Print post
Permalink
I have this procedure in my code:

 button_browse_files_select
   -- Called by `select_actions' of `button_browse_files'.
  local
   dialog: EV_FILE_OPEN_DIALOG
   const: EV_DIALOG_CONSTANTS
  do
   create dialog
   dialog.enable_multiple_selection
   dialog.show_modal_to_window (Current)
   if dialog.selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open) then
    file_names := dialog.file_names
    set_text_field_files
   end
  end

Now dialog.selected_button returns a detachable STRING_32 so I get the error:

 2 VUTA(2): Target of the Object_call is not attached. MAIN_WINDOW.button_browse_files_select (root_cluster) 399, 30

I'm not sure how to repair this.  I have tried a couple of things but, so far, have failed to fix this.  Could someone assist?  I'm not sure if an object test here is appropriate and if so I'm not sure what the current syntax is for one.

Regards
Chris Saunders

[Non-text portions of this message have been removed]

Daniel Furrer

Re: Void safety problem

Reply Threaded More More options
Print post
Permalink
Try the equal helper feature from ANY. It takes two detachables and checks
them for void before calling the regular is_equal.

if equals (dialog.selected_button, create {EV_DIALOG_CONSTANTS}.ev_open)
then
...

should be what you want.

Daniel

On Tue, Aug 25, 2009 at 8:10 AM, Chris Saunders <[hidden email]>wrote:

>
>
> I have this procedure in my code:
>
> button_browse_files_select
> -- Called by `select_actions' of `button_browse_files'.
> local
> dialog: EV_FILE_OPEN_DIALOG
> const: EV_DIALOG_CONSTANTS
> do
> create dialog
> dialog.enable_multiple_selection
> dialog.show_modal_to_window (Current)
> if dialog.selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open)
> then
> file_names := dialog.file_names
> set_text_field_files
> end
> end
>
> Now dialog.selected_button returns a detachable STRING_32 so I get the
> error:
>
> 2 VUTA(2): Target of the Object_call is not attached.
> MAIN_WINDOW.button_browse_files_select (root_cluster) 399, 30
>
> I'm not sure how to repair this. I have tried a couple of things but, so
> far, have failed to fix this. Could someone assist? I'm not sure if an
> object test here is appropriate and if so I'm not sure what the current
> syntax is for one.
>
> Regards
> Chris Saunders
>
> [Non-text portions of this message have been removed]
>
>  
>


[Non-text portions of this message have been removed]

Jocelyn.Fiat

Re: Void safety problem

Reply Threaded More More options
Print post
Permalink
In reply to this post by Chris Saunders-4
You have, at least, two solutions

Using local variable:

 button_browse_files_select
   -- Called by `select_actions' of `button_browse_files'.
  local
   l_selected_button: detachable STRING_32
   dialog: EV_FILE_OPEN_DIALOG
   const: EV_DIALOG_CONSTANTS
  do
   create dialog
   dialog.enable_multiple_selection
   dialog.show_modal_to_window (Current)
   l_selected_button := dialog.selected_button
   if
    l_selected_button /= Void and then
    l_selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open)
   then
    file_names := dialog.file_names
    set_text_field_files
   end
  end


Or using the object test local

 button_browse_files_select
   -- Called by `select_actions' of `button_browse_files'.
  local
   dialog: EV_FILE_OPEN_DIALOG
   const: EV_DIALOG_CONSTANTS
  do
   create dialog
   dialog.enable_multiple_selection
   dialog.show_modal_to_window (Current)
   if
    attached dialog.selected_button as l_selected_button and then
    l_selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open)
   then
    file_names := dialog.file_names
    set_text_field_files
   end
  end

Hope this helps,
-- Jocelyn

Chris Saunders wrote:

> I have this procedure in my code:
>
>  button_browse_files_select
>    -- Called by `select_actions' of `button_browse_files'.
>   local
>    dialog: EV_FILE_OPEN_DIALOG
>    const: EV_DIALOG_CONSTANTS
>   do
>    create dialog
>    dialog.enable_multiple_selection
>    dialog.show_modal_to_window (Current)
>    if dialog.selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open) then
>     file_names := dialog.file_names
>     set_text_field_files
>    end
>   end
>
> Now dialog.selected_button returns a detachable STRING_32 so I get the error:
>
>  2 VUTA(2): Target of the Object_call is not attached. MAIN_WINDOW.button_browse_files_select (root_cluster) 399, 30
>
> I'm not sure how to repair this.  I have tried a couple of things but, so far, have failed to fix this.  Could someone assist?  I'm not sure if an object test here is appropriate and if so I'm not sure what the current syntax is for one.
>
> Regards
> Chris Saunders
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
>  

Jocelyn.Fiat

Re: Void safety problem

Reply Threaded More More options
Print post
Permalink
And a last solution, maybe the recommended one

    if dialog.selected_button ~ (create {EV_DIALOG_CONSTANTS}.ev_open) then

-- Jocelyn

Jocelyn wrote:

> You have, at least, two solutions
>
> Using local variable:
>
>  button_browse_files_select
>    -- Called by `select_actions' of `button_browse_files'.
>   local
>    l_selected_button: detachable STRING_32
>    dialog: EV_FILE_OPEN_DIALOG
>    const: EV_DIALOG_CONSTANTS
>   do
>    create dialog
>    dialog.enable_multiple_selection
>    dialog.show_modal_to_window (Current)
>    l_selected_button := dialog.selected_button
>    if
>     l_selected_button /= Void and then
>     l_selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open)
>    then
>     file_names := dialog.file_names
>     set_text_field_files
>    end
>   end
>
>
> Or using the object test local
>
>  button_browse_files_select
>    -- Called by `select_actions' of `button_browse_files'.
>   local
>    dialog: EV_FILE_OPEN_DIALOG
>    const: EV_DIALOG_CONSTANTS
>   do
>    create dialog
>    dialog.enable_multiple_selection
>    dialog.show_modal_to_window (Current)
>    if
>     attached dialog.selected_button as l_selected_button and then
>     l_selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open)
>    then
>     file_names := dialog.file_names
>     set_text_field_files
>    end
>   end
>
> Hope this helps,
> -- Jocelyn
>
> Chris Saunders wrote:
>  
>> I have this procedure in my code:
>>
>>  button_browse_files_select
>>    -- Called by `select_actions' of `button_browse_files'.
>>   local
>>    dialog: EV_FILE_OPEN_DIALOG
>>    const: EV_DIALOG_CONSTANTS
>>   do
>>    create dialog
>>    dialog.enable_multiple_selection
>>    dialog.show_modal_to_window (Current)
>>    if dialog.selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open) then
>>     file_names := dialog.file_names
>>     set_text_field_files
>>    end
>>   end
>>
>> Now dialog.selected_button returns a detachable STRING_32 so I get the error:
>>
>>  2 VUTA(2): Target of the Object_call is not attached. MAIN_WINDOW.button_browse_files_select (root_cluster) 399, 30
>>
>> I'm not sure how to repair this.  I have tried a couple of things but, so far, have failed to fix this.  Could someone assist?  I'm not sure if an object test here is appropriate and if so I'm not sure what the current syntax is for one.
>>
>> Regards
>> Chris Saunders
>>
>> [Non-text portions of this message have been removed]
>>
>>
>>
>> ------------------------------------
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>  
>>    
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
>  

Bertrand Meyer

RE: Void safety problem

Reply Threaded More More options
Print post
Permalink
In reply to this post by Daniel Furrer
This is equivalent to the solution in Jocelyn's later message, but using ~
is better than using `equal' (note that it's `equal' without an `s') to
avoid any risk of a catcall.

 

-- BM

 

From: [hidden email]
[mailto:[hidden email]] On Behalf Of Daniel Furrer
Sent: Tuesday, 25 August, 2009 08:26
To: [hidden email]
Subject: Re: [eiffel_software] Void safety problem

 

 

Try the equal helper feature from ANY. It takes two detachables and checks
them for void before calling the regular is_equal.

if equals (dialog.selected_button, create {EV_DIALOG_CONSTANTS}.ev_open)
then
...

should be what you want.

Daniel

On Tue, Aug 25, 2009 at 8:10 AM, Chris Saunders <[hidden email]
<mailto:evas%40mountaincable.net> >wrote:

>
>
> I have this procedure in my code:
>
> button_browse_files_select
> -- Called by `select_actions' of `button_browse_files'.
> local
> dialog: EV_FILE_OPEN_DIALOG
> const: EV_DIALOG_CONSTANTS
> do
> create dialog
> dialog.enable_multiple_selection
> dialog.show_modal_to_window (Current)
> if dialog.selected_button.is_equal (create {EV_DIALOG_CONSTANTS}.ev_open)
> then
> file_names := dialog.file_names
> set_text_field_files
> end
> end
>
> Now dialog.selected_button returns a detachable STRING_32 so I get the
> error:
>
> 2 VUTA(2): Target of the Object_call is not attached.
> MAIN_WINDOW.button_browse_files_select (root_cluster) 399, 30
>
> I'm not sure how to repair this. I have tried a couple of things but, so
> far, have failed to fix this. Could someone assist? I'm not sure if an
> object test here is appropriate and if so I'm not sure what the current
> syntax is for one.
>
> Regards
> Chris Saunders
>
> [Non-text portions of this message have been removed]
>
>
>

[Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]