Quantcast
Channel: Adobe Community : Popular Discussions - InDesign SDK
Viewing all articles
Browse latest Browse all 78596

Delete old SnapshotUtilsEx* Objects results in Bus Error

$
0
0

Hi,

 

we are developing a PlugIn for CS6 that maintains multiple snapshots, and are facing the following problem. At some points we need to release memory that was previously allocated by a SnapshotUtilsEx object (by calling the destructor via delete), which results in a InDesing crash. Strange thing is that if you delete the object right after usage (as can be found in the sdksamples) everything is fine, while deletion of an old snapshots results in a crash.

 

We hunted the problem down to a minimal example (see snippet below) but were not able to come up with a solution nor did we find any similar problem in the forum.

 

Any help appreciated, we are happy to share more background if needed.

 

 

class MyView : public CControlView

{

 

(…)

 

private:

    (…)

    SnapshotUtilsEx* i_store_the_current_snapshot;

    SnapshotUtilsEx* i_store_the_previous_snapshot;

};

 

(…)

 

MyView::MyView(IPMUnknown* boss)

: CControlView(boss)

{   

    i_store_the_current_snapshot = NULL;

    i_store_the_previous_snapshot = NULL;

}

 

(…)

 

// this version works (but doesn't fit to our needs)

void CMMCS6UIPanelWTFView::Draw(IViewPort* viewPort, SysRgn updateRgn)

{

    (…)

 

    i_store_the_current_snapshot = new SnapshotUtilsEx(spreadUIDRef);

               

    i_store_the_current_snapshot->Draw(IShape::kPreviewMode, kTrue);

    __DrawSnapshot(gPort, 0, 0, 200, i_store_the_current_snapshot);

    // using SnapshotUtilsEx::CreateAGMImageAccessor() and IGraphicsPort::image(..)

           

    delete i_store_the_current_snapshot;

   

    (…)

 

}

 

 

// this version DOES NOT wok

void CMMCS6UIPanelWTFView::NotWorkingDraw(IViewPort* viewPort, SysRgn updateRgn)

{

    (…)

 

    i_store_the_previous_snapshot = i_store_the_current_snapshot;

    i_store_the_current_snapshot = new SnapshotUtilsEx(spreadUIDRef);

               

    i_store_the_current_snapshot->Draw(IShape::kPreviewMode, kTrue);

    __DrawSnapshot(gPort, 0, 0, 200, i_store_the_current_snapshot);

    // using SnapshotUtilsEx::CreateAGMImageAccessor() and IGraphicsPort::image(..)

           

    if(i_store_the_previous_snapshot != NULL)

    {

        delete i_store_the_pre_previous_snapshot;

    }   

   

    (…)

 

}


Viewing all articles
Browse latest Browse all 78596


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>