Page 1 of 1

wxGrid : calling DeleteRows is crashing

Posted: Mon Jul 30, 2018 6:34 am
by murali
Hi,

I have an application of wxwidgets. I have wxGrid in my application and I am deleting and inserting some rows at runtime.
I call grid->DeleteRows(pos, numRows). When the function returns from DoModifyLines(bool (wxGridTableBase::*funcModify)(size_t, size_t),
int pos, int num, bool WXUNUSED(updateLabels) )
, I am getting crash. I have attached the snapshot of the error message.
Same thing (ie. grid->DeleteRows(pos, numRows) if I do from grid sample, I works fine. What can go wrong here ?

Re: wxGrid : calling DeleteRows is crashing

Posted: Mon Jul 30, 2018 6:51 am
by doublemax
I don't see a snapshot.

Please make sure that the grid is already created when you make the call. Also check that the "pos" and "numRows" paramaters are valid. E.g. that pos+numRows does not go beyond the last row of the grid.

Re: wxGrid : calling DeleteRows is crashing

Posted: Mon Jul 30, 2018 2:49 pm
by ONEEYEMAN
Hi,
It is best not to attach a screenshot of the error, but put it in the text (copy'n'paste).
Now, what do you mean by crash? Does the program asserts and youget a nice assertion report from the wxWidgets? Or you get a crash from Windows where you are asked if you want to Debug the application or stop it?

Thank you.

Re: wxGrid : calling DeleteRows is crashing

Posted: Tue Jul 31, 2018 8:47 am
by murali
Hi,

Ok. I forgot to attach snapshot. I will make it more clear. I have derived a class from wxGrid. I am calling the function DeleteRows from one of the functions of my derived class.
void myGrid::updateGrid(int pos, int numRows)
{
DeleteRows(pos, numRows);
}

When the call returns from the function DoModifyLines(&wxGridTableBase::DeleteRows ,pos, numRows, updateLabels);

I will get following error message.

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

I have made sure that pos+numRows < totalNoOfRows .

My application is written using c++. So i do not see anywhere the mismatch between calling conventions. What could be the possible cause of such an error message ?

Re: wxGrid : calling DeleteRows is crashing

Posted: Tue Jul 31, 2018 2:32 pm
by ONEEYEMAN
Hi,
Are you using DLL anywhere?
Do you have anything that have "C" interface and not declared as

exterm "C"

?

Thank you.

Re: wxGrid : calling DeleteRows is crashing

Posted: Wed Aug 01, 2018 11:14 am
by murali
Hi,

Yes. My application is a DLL. I have extern "C" functions In my application.
Ex: extern "C" __declspec(dllexport)
void myFunc() { }


But DeleteRows() I am calling from a function which is normal c++ member function (it is not extern C function).

Re: wxGrid : calling DeleteRows is crashing

Posted: Wed Aug 01, 2018 4:33 pm
by doublemax
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
This is not a common mistake. AFAIR i only encountered it once or twice and in both cases it was caused by incompatible libraries. Double-check the compiler and linker settings for all libraries in your project. Make sure they all include the headers from the same locations.

The documentation for wxGrid::DeleteRows() says:
If you are using a derived grid table class you will need to override wxGridTableBase::DeleteRows().
Are you using a custom wxGridTableBase? And if yes, did you override wxGridTableBase::DeleteRows()?