Skip to content

Commit

Permalink
Fix spurious assert in wxGTK wxDataViewCtrl::EditItem().
Browse files Browse the repository at this point in the history
The assert in wxGtkTreeSelectionLock ctor failed after the first time this
object was created as it doesn't reset the selection function to NULL with
wxGTK2, fix this by checking for different values depending on whether it's
actually the first time we do it or not.

In the future we should just reset the selection function to NULL as it does
work in GTK+ 3, also update the comment explaining the problem to mention this.

(cherry picked from commit 24c0401)
  • Loading branch information
vadz authored and vslavik committed Apr 4, 2017
1 parent 8fad217 commit ed88188
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/gtk/dataview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ class wxGtkTreePathList : public wxGtkList

// Implementation note: it could be expected that setting the selection
// function in this class ctor and resetting it back to the old value in its
// dtor would work. However currently gtk_tree_selection_get_select_function()
// can't be passed NULL (see https://bugzilla.gnome.org/show_bug.cgi?id=626276)
// so we can't do this. Instead, we always use the selection function (which
// dtor would work, However in GTK+2 gtk_tree_selection_get_select_function()
// can't be passed NULL (see https://bugzilla.gnome.org/show_bug.cgi?id=626276
// which was only fixed in 2.90.5-304-g316b9da) so we can't do this.
//
// Instead, we always use the selection function (which
// imposes extra overhead, albeit minimal one, on all selection operations) and
// just set/reset the flag telling it whether it should allow or forbid the
// selection.
Expand Down Expand Up @@ -168,7 +170,15 @@ class wxGtkTreeSelectionLock

ms_instance = this;

CheckCurrentSelectionFunc(NULL);
if ( ms_firstTime )
{
ms_firstTime = false;
CheckCurrentSelectionFunc(NULL);
}
else
{
CheckCurrentSelectionFunc(wxdataview_selection_func);
}

// Pass some non-NULL pointer as "data" for the callback, it doesn't
// matter what it is as long as it's non-NULL.
Expand Down Expand Up @@ -215,13 +225,15 @@ class wxGtkTreeSelectionLock
}

static wxGtkTreeSelectionLock *ms_instance;
static bool ms_firstTime;

GtkTreeSelection * const m_selection;

wxDECLARE_NO_COPY_CLASS(wxGtkTreeSelectionLock);
};

wxGtkTreeSelectionLock *wxGtkTreeSelectionLock::ms_instance = NULL;
bool wxGtkTreeSelectionLock::ms_firstTime = true;

//-----------------------------------------------------------------------------
// wxDataViewCtrlInternal
Expand Down

0 comments on commit ed88188

Please sign in to comment.