View Issue Details

IDProjectCategoryView StatusLast Update
0024202Open CASCADEOCCT:DRAWpublic2014-11-11 12:59
Reporterkgv Assigned Toapn  
PrioritynormalSeverityfeature 
Status closedResolutionfixed 
PlatformAOSL 
Target Version6.8.0Fixed in Version6.8.0 
Summary0024202: Support class methods as callbacks for Draw Harness commands
DescriptionCurrent Draw_Interpretor interface supports only global functions as command implementation. This results in dirty code in each command which wants to access global variables and group them in some class.
Additional information
and documentation updates
New method Draw_Interpretor::Add() accept class method as callback function for tcl-command definition:
  template<typename theHandleType>
  inline void Add (Standard_CString     theCommandName,
                   Standard_CString     theHelp,
                   Standard_CString     theFileName,
                   const theHandleType& theObjPtr,
                   typename Draw_Interpretor::CallBackDataMethod<theHandleType>::methodType theMethod,
                   Standard_CString     theGroup)

Class instance should passed by handle (smart pointer).
TagsNo tags attached.
Test case numberNot needed

Activities

kgv

2013-09-24 18:32

developer   ~0025715

Patch is ready for review in CR24202 branch.

abv

2014-01-15 10:58

manager   ~0027487

The patch seems to me potentially dangerous in that new (templated) method Draw_Interpretor::Add() accepts pointer to an object those lifetime must be longer than life of the command, while no protection is made against passing pointer to local variable, or destruction of the pointer while the command still exists. Please consider using smart pointer (Handle) to ensure sufficient life time of the object. If this is not suitable, at least please document this requirement clearly in comments.

Other remarks:

- name of the argument theClassPtr in the above mentioned method Add(), and similar field and argument in class Draw_CallBackDataFunc, is misleading: I suppose it should be rather called theObjectPtr

- classes defined in Draw_CommandFunction.hxx should better be moved to the inside of the Draw_Interpretor class (as private nested classes), as they are made only for internal usage in this class (I do not think inheritance should be supported)

- method Draw_Interpretor::add() should be made private for the same reason

kgv

2014-01-22 18:35

developer   ~0027613

Updated patch is ready for review in CR24202_3 branch.
Callback now requires Handle rather than object pointer.
Classes moved to Draw_Interpretor.

abv

2014-02-05 12:51

manager   ~0027761

No remarks, please test

mkv

2014-02-05 13:08

tester   ~0027762

Dear kgv,
could you please rebase issue CR24202_3 on current master,
there are conflict files.

kgv

2014-02-05 13:18

developer   ~0027763

Rebased patch is ready for testing in CR24202_4 branch.

mkv

2014-02-06 07:24

tester   ~0027786

Dear BugMaster,

Branch CR24202_4 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
SHA-1: 8a3087db03790768c067eca733f08b1bd3e95b96

Number of compiler warnings:

occt component :
Linux: 44 (44 on master)
Windows: 0 (0 on master)

products component :
Linux: 12 (12 on master)
Windows: 2 (2 on master)

Regressions/Differences:
No regressions/differences

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 372819988 / 372443488
Total CPU difference: 43232.96 / 43920.73000000019

Testing on Windows:
Total MEMORY difference: 419324916 / 409834624
Total CPU difference: 38269.640625 / 35405.109375

There are not differences in images found by testdiff.

Related Changesets

occt: master dda67c1c

2014-02-05 09:17:29

kgv


Committer: apn Details Diff
0024202: Support class methods as callbacks for Draw Harness commands Affected Issues
0024202
mod - src/Draw/Draw.cdl Diff File
rm - src/Draw/Draw_CommandFunction.hxx Diff File
rm - src/Draw/Draw_Interpretor.cdl Diff File
mod - src/Draw/Draw_Interpretor.cxx Diff File
add - src/Draw/Draw_Interpretor.hxx Diff File
mod - src/Draw/FILES Diff File
mod - src/NCollection/NCollection_Handle.hxx Diff File
mod - src/QABugs/QABugs_19.cxx Diff File
mod - src/Standard/Standard_DefineHandle.hxx Diff File

Issue History

Date Modified Username Field Change
2013-09-24 18:28 kgv New Issue
2013-09-24 18:28 kgv Assigned To => mkv
2013-09-24 18:28 kgv Assigned To mkv => kgv
2013-09-24 18:32 kgv Note Added: 0025715
2013-09-24 18:32 kgv Assigned To kgv => abv
2013-09-24 18:32 kgv Status new => resolved
2013-12-21 10:13 abv Target Version 6.7.0 => 6.7.1
2014-01-15 10:58 abv Note Added: 0027487
2014-01-15 10:58 abv Assigned To abv => kgv
2014-01-15 10:58 abv Status resolved => assigned
2014-01-22 18:35 kgv Note Added: 0027613
2014-01-22 18:35 kgv Assigned To kgv => abv
2014-01-22 18:35 kgv Status assigned => resolved
2014-02-05 12:51 abv Note Added: 0027761
2014-02-05 12:51 abv Assigned To abv => bugmaster
2014-02-05 12:51 abv Status resolved => reviewed
2014-02-05 13:08 mkv Note Added: 0027762
2014-02-05 13:08 mkv Assigned To bugmaster => kgv
2014-02-05 13:08 mkv Status reviewed => feedback
2014-02-05 13:18 kgv Note Added: 0027763
2014-02-05 13:18 kgv Assigned To kgv => mkv
2014-02-05 13:18 kgv Status feedback => reviewed
2014-02-06 07:24 mkv Note Added: 0027786
2014-02-06 07:24 mkv Test case number => Not needed
2014-02-06 07:24 mkv Assigned To mkv => bugmaster
2014-02-06 07:24 mkv Status reviewed => tested
2014-02-10 12:41 apn Changeset attached => occt master dda67c1c
2014-02-10 12:41 apn Assigned To bugmaster => apn
2014-02-10 12:41 apn Status tested => verified
2014-02-10 12:41 apn Resolution open => fixed
2014-04-04 12:36 abv Target Version 6.7.1 => 6.8.0
2014-10-07 11:36 kgv Additional Information Updated
2014-11-11 12:44 aiv Fixed in Version => 6.8.0
2014-11-11 12:59 aiv Status verified => closed