Opened 20 years ago

Last modified 20 years ago

#490 closed defect (invalid)

How and when the IWriteBlock() function being called by the IRasterIO Function!

Reported by: tinax@… Owned by: warmerdam
Priority: high Milestone:
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords:
Cc:

Description

Hi, Frank:
    Now, I am doing some work for adding a new image form.  After had 
successfully added the Open() and Create() functions for my new image form, I 
tried to make the form can be written by calling my IWriteBlock() function.My 
IWriteBlock() funtion coded as below:
CPLErr MHRasterBand::IWriteBlock(int nBlockXOff,int nBlockYOff,	void * pImage )
{					  
	CPLError( CE_Failure, CPLE_AppDefined, 
		"It is mhdataset writeblock." );
	MHDataset *poGDS = (MHDataset *)poDS;
		CPLAssert( poGDS != NULL
		&& nBlockXOff >= 0
		&& nBlockYOff >= 0
		&& pImage != NULL );
	_MHDataWrite ( data,  offset, count, pabuff );//my IO funtion
	return CE_None;
}
    But , when I was tring to write some data to my new imgefile, I received 
the error as "WriteBlock() not supported for this dataset" instead of the debug 
info "It is mhdataset writeblock" .Although I had adapted the virtual function 
in my new form class, IRasterIO() still called the father class's 
(GDALRasterBand)!
    I am so erger to get help by you! Could you direct me when the IWriteBlock
() being called and which way the IRasterIO() called the IWriteBlock().Thanks!
    By the way, I had could creat and open my new image files.

Change History (2)

comment:1 by warmerdam, 20 years ago

I suspect the problem you are encountering is related to dataset teardown.
Because data isn't normally flushed out of the write cache to the file till
the dataset is being destroyed you need to include a FlushCache() call in your
dataset class destructor.  The GDALDataset class destructor also includes this
but that the time it is called the higher level dataset object is already torn
down and the virtual methods for that class no longer work properly (apparently). 


comment:2 by warmerdam, 20 years ago

No followup ... closing.

Note: See TracTickets for help on using tickets.