I didn't realize that the assignment operator was defined I will debug it.
This is what I've done in the assigment operator(just put some printf's):
void wxPrintData::operator=(const wxPrintData& data)
{
printf("Aqui 1\n");
m_printNoCopies = data.m_printNoCopies;
m_printCollate = data.m_printCollate;
m_printOrientation = data.m_printOrientation;
m_printerName = data.m_printerName;
m_colour = data.m_colour;
m_duplexMode = data.m_duplexMode;
m_printQuality = data.m_printQuality;
m_paperId = data.m_paperId;
m_paperSize = data.m_paperSize;
m_bin = data.m_bin;
m_printMode = data.m_printMode;
m_filename = data.m_filename;
printf("Aqui 2\n");
// UnRef old m_nativeData
if (m_nativeData)
{
m_nativeData->m_ref--;
if (m_nativeData->m_ref == 0)
delete m_nativeData;
}
// Set Ref new one
printf("Aqui 3\n");
m_nativeData = data.GetNativeData();
m_nativeData->m_ref++;
if (m_privData)
{
printf("Aqui 3.1\n");
delete m_privData;
printf("Aqui 3.2\n");
m_privData = NULL;
}
printf("Aqui 4\n");
m_privDataLen = data.GetPrivDataLen();
if (m_privDataLen > 0)
{
m_privData = new char[m_privDataLen];
memcpy( m_privData, data.GetPrivData(), m_privDataLen );
}
printf("Aqui 5\n");
#ifdef __WXMAC__
m_nativePrintData->CopyFrom( data.m_nativePrintData ) ;
#endif
}
···
-----------------------------------------------------
This is the python program that I use to debug:
import wx
app= wx.PySimpleApp()
print 'Creating data'
data = wx.PrintDialogData()
print 'Creating dialog'
dlg = wx.PrintDialog(None, data)
dlg.ShowModal()
--------------------------------------------------------
This is the python test program output:
[rpedroso@portatil ~]$ python p.py
Creating data
Creating dialog
Aqui 1
Aqui 2
Aqui 3
Aqui 4
Aqui 5
Aqui 1
Aqui 2
Aqui 3
Aqui 3.1
Segmentation fault
In conclusion, the segfault is when we are freeing the m_privData:
delete m_privData;
----------------------------------------------------------
In one of my debugs, instead of a segmentation fault, I had this:
*** glibc detected *** double free or corruption (!prev): 0x00ad8110 ***
Aborted
I don't know if it will help but,
I google for it and one thing I found was someone tell that:
(double free error)
"
Using Fedora Core 3 (latest release, fully upgraded), I encountered an
error. This release of Fedora uses a new glibc which does not allow one to
perform a free() on the same location twice. (Since glibc-20040925T0738,
released in glibc 2.3.4)
"
I hope, this big mail, help.
Ricardo