Bugs item #2342054, was opened at 2008-11-25 08:21
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=462816&aid=2342054&group_id=51305

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: treelistctrl
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Ronan Chartois (pgriddev)
Assigned to: Otto Wyss (wyo)
Summary: crash after rename / cell edit

Initial Comment:
After several renames, I get either intermittent crashes or failure of
the Edit control to show and work properly.

The bug is due to the usage of a deleted object. Say, we're editing a label and
hit ENTER. In the OnChar handler, the edit control is marked for some
asynchronous deletion, and then m_finished flag is set.


void wxEditTextCtrl::OnChar( wxKeyEvent &event )
{
    //...
    if (event.GetKeyCode() == WXK_RETURN)
    {
        if (!wxPendingDelete.Member(this))
            wxPendingDelete.Append(this);

        m_finished = true;
        // ...
    }
    // ...
}


At some point in time _later_, the destructor is called (because the object has
been pending for deletion), whicn in turn calls CancelEdit. CancelEdit exits
immediately, because m_finished is set. So there's no chance that
m_renameControl of the owner is reset to NULL.


void wxEditTextCtrl::CancelEdit() {
    if (m_finished) return;

    // ...
    if (m_owner) {
        m_owner->OnRenameAccept(true);  // cancelled
        if (m_owner->m_renameControl == this) {
            m_owner->m_renameControl = NULL;
            m_owner->m_editItem = NULL;
        }
        // ...
    }

    // ...
}


In the next EditLabel call, the following code will crash, because
m_renameControl pointer is dangling.


    if (m_renameControl) {
        m_renameControl->CancelEdit();
    }


I patched this bug by moving the "m_owner->m_renameControl = NULL" above the "if
(m_finished) return;" in CancelEdit. The patch works for me but may be wrong in
some way; unfortunately, I don't have time to think it over and test it. So
please fix this major bug as you see fit.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=462816&aid=2342054&group_id=51305

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
wxCode-users mailing list
wxCode-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxcode-users

Reply via email to