bugGNU Octave - Bugs: bug #66229, class destructor delete cannot...

 
 

bug #66229: class destructor delete cannot access protected data

Submitter:  Reimund <rayman>
Submitted:  Tue 17 Sep 2024 05:49:23 PM UTC
   
 
Category:  Classdef Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Works For Me Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 9.2.0 Release: 
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 22 Oct 2024 12:18:19 AM UTC, comment #3: 

Your sequence also works for me.

You might try starting Octave as


octave -f


which will not read any of your personal or site-wide configuration files.  Perhaps there is something in your individual setup that is causing the problem.

Rik <rik5>
Group administrator
Mon 21 Oct 2024 09:35:12 AM UTC, comment #2: 

Thank you for checking! True, in that order it works.
The error arises for me when using `clear all`:

x = Test;
delete (x)
clear all

>> warning: error caught while executing handle class delete method:

subsref: property 'test' has protected access and cannot be obtained in this context

Reimund <rayman>
Fri 18 Oct 2024 11:42:09 PM UTC, comment #1: 

This works for me.  Could you document the exact sequence that led to the error from subsref?

I tried


x = Test;
delete (x)
clear x


Rik <rik5>
Group administrator
Tue 17 Sep 2024 05:49:23 PM UTC, original submission:  

Hi, when using a destructor method in class, it throws a subsref warning:

warning: error caught while executing handle class delete method:
subsref: property 'test' has protected access and cannot be obtained in this context

Example class:

classdef Test < handle
  properties (Access = protected)
    test
  end

  methods
    function obj = Test()
      obj.test = true;
    end

    function delete(obj)
      if obj.test
        x = 1;
      end
    end
  end
end


I hope this can be fixed...
Kind regards, Reimund

Reimund <rayman>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rayman (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-10-22 rik5 Open/ClosedOpen Closed
    2024-10-18 rik5 StatusNone Works For Me

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code