2014-10-01 29 views
0

我有一個使用dragandrop當我關閉應用程序,它崩潰上這條線wxwidget應用:wxwidget應用程序崩潰,當我添加代碼來執行拖放

virtual ~wxDropTargetBase() 
    { delete m_dataObject; } 

我設置了drapand降了這種方式:

MainWindow::MainWindow() : MainWindowTemplate(NULL), m_fileDropTarget(textSourceFolder) 
{ 
    // connect events 
    this->Connect(wxEVT_IDLE, wxIdleEventHandler(MainWindow::OnIdle)); 
    // set window minimum size - work around bug that ignores outer border and sets min size slightly too small 
    wxSize minSize = sizerOuter->GetMinSize(); 
    minSize.SetWidth(minSize.GetWidth() + 16); 
    minSize.SetHeight(minSize.GetHeight() + 16); 
    SetMinSize(minSize); 
    Layout(); 
    // set file drop target 
    SetDropTarget(&m_fileDropTarget); 
} 

和我

class MyFileDropTarget : public wxFileDropTarget 
{ 
public: 
    MyFileDropTarget(wxTextCtrl *textCtrl) 
    { 
     m_fileTextCtrl = textCtrl; 
    } 
    virtual bool wxFileDropTarget::OnDropFiles (wxCoord x, wxCoord y, const wxArrayString &filenames) 
    { 
     if (filenames.size() > 0) 
     { 
      m_fileTextCtrl->SetValue(filenames.Item(0)); 
      return true; 
     } 
     return false; 
    } 
private: 
    wxTextCtrl *m_fileTextCtrl; 
}; 

的源代碼是什麼問題和浩我可以修復它嗎?

回答

0

看起來你的m_fileDropTarget是一個對象,在這種情況下,它會被刪除兩次,因爲當你調用SetDropTarget()時,它將傳遞給它的指針的所有權。

相關問題