wxGrid : calling DeleteRows is crashing

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
murali
In need of some credit
In need of some credit
Posts: 5
Joined: Fri May 18, 2018 5:20 pm

wxGrid : calling DeleteRows is crashing

Post by murali » Mon Jul 30, 2018 6:34 am

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 ?

User avatar
doublemax
Moderator
Moderator
Posts: 13886
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGrid : calling DeleteRows is crashing

Post by doublemax » Mon Jul 30, 2018 6:51 am

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.
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3353
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxGrid : calling DeleteRows is crashing

Post by ONEEYEMAN » Mon Jul 30, 2018 2:49 pm

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.

murali
In need of some credit
In need of some credit
Posts: 5
Joined: Fri May 18, 2018 5:20 pm

Re: wxGrid : calling DeleteRows is crashing

Post by murali » Tue Jul 31, 2018 8:47 am

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 ?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3353
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxGrid : calling DeleteRows is crashing

Post by ONEEYEMAN » Tue Jul 31, 2018 2:32 pm

Hi,
Are you using DLL anywhere?
Do you have anything that have "C" interface and not declared as

exterm "C"

?

Thank you.

murali
In need of some credit
In need of some credit
Posts: 5
Joined: Fri May 18, 2018 5:20 pm

Re: wxGrid : calling DeleteRows is crashing

Post by murali » Wed Aug 01, 2018 11:14 am

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).

User avatar
doublemax
Moderator
Moderator
Posts: 13886
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxGrid : calling DeleteRows is crashing

Post by doublemax » Wed Aug 01, 2018 4:33 pm

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()?
Use the source, Luke!

Post Reply