Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16768 closed defect (invalid)

wxPropertyGridIterator only works in reverse

Reported by: ravenspoint Owned by:
Priority: normal Milestone:
Component: wxPropertyGrid Version: 3.0.1
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

Please look at http://stackoverflow.com/q/27769092/16582 for details.

Ticket submitted on reccomendation from stackoverflow user 'VZ'

Attachments (3)

wxt16768.cpp download (1.8 KB) - added by ravenspoint 5 years ago.
minimal complete program showing problem
Capture.JPG download (22.0 KB) - added by ravenspoint 5 years ago.
screenshot
modified-sample.patch download (1.7 KB) - added by awi 5 years ago.
Modified sample reproducing the issue.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 5 years ago by vadz

As I said there, it would be really, really helpful to have a way to reproduce this in the sample, please consider making a patch to it demonstrating the problem. TIA!

Changed 5 years ago by ravenspoint

minimal complete program showing problem

Changed 5 years ago by ravenspoint

screenshot

comment:2 Changed 5 years ago by ravenspoint

Attached minimal complete program showing problem with screenshot


#include <wx/propgrid/propgrid.h>

#include <wx/app.h>
#include <wx/frame.h>
#include <wx/stattext.h>

class wxt16768App : public wxApp
{
    public:
        virtual bool OnInit();
};


IMPLEMENT_APP(wxt16768App);

class wxt16768_frame: public wxFrame
{
    public:
        wxt16768_frame(wxFrame *frame, const wxString& title);

};

wxt16768_frame::wxt16768_frame(wxFrame *frame, const wxString& title)
    : wxFrame(frame, -1, title)
{

// Create prop grid with three items
    wxPropertyGrid * pg = new wxPropertyGrid( this, -1, wxPoint( 5,5), wxSize(300,70) );
    pg->Append(  new wxStringProperty( "A", wxPG_LABEL, "av") ) ;
    pg->Append(  new wxStringProperty( "B", wxPG_LABEL, "bv") ) ;
    pg->Append(  new wxStringProperty( "C", wxPG_LABEL, "cv") ) ;

// iterate over items
    wxString msg1;
    wxPropertyGridIterator it;
    for ( it = pg->GetIterator( ); !it.AtEnd();      it-- )
    {
        // add item label and value to string
        wxPGProperty* p = *it;
        msg1 += p->GetLabel() + " : " + p->GetValueAsString() + "\n";
    }

    wxString msg2;
    for ( it = pg->GetIterator(wxPG_ITERATE_DEFAULT, wxBOTTOM ); !it.AtEnd();      it-- )
    {
        // add item label and value to string
        wxPGProperty* p = *it;
        msg2 += p->GetLabel(   ) + " : " + p->GetValueAsString() + "\n";
    }

    new wxStaticText( this,-1, msg1 + " ( default ) ",
                      wxPoint( 5,100), wxSize(-1,-1));
    new wxStaticText( this,-1, msg2 + " ( bottom ) ",
                      wxPoint( 200,100), wxSize(-1,-1));

}

bool wxt16768App::OnInit()
{
    wxt16768_frame* frame = new wxt16768_frame(0L, _("wxWidgets Application Template"));
    frame->SetIcon(wxICON(aaaa)); // To Set App Icon
    frame->Show();

    return true;
}

comment:3 Changed 5 years ago by ravenspoint

I took look at the sample program as you requested but the sample application works just fine as is.

void FormMain::OnIterate1Click( wxCommandEvent& WXUNUSED(event) )
{
    wxPropertyGridIterator it;

    for ( it = m_pPropGridManager->GetCurrentPage()->
            GetIterator();
          !it.AtEnd();
          it++ )
    {
        wxPGProperty* p = *it;
        int res = IterateMessage( p );
        if ( res == wxCANCEL ) break;
    }
}

comment:4 Changed 5 years ago by ericj

In your original code you're using "it--" instead of "it++". Which explains the behavior perfectly.

Last edited 5 years ago by ericj (previous) (diff)

comment:5 Changed 5 years ago by awi

  • Resolution set to invalid
  • Status changed from new to closed

If your code exhibiting the issue is complete then the problem is indeed caused by advancing the iterator in the wrong direction.
If this is not the case then please reopen the ticket.

BTW: As it was said in comment:1 making a patch modifying any existing wxWidgets sample is a preferred way to demonstrate the issue. Something like attached patch file (attachment:modified-sample.patch).

Changed 5 years ago by awi

Modified sample reproducing the issue.

comment:6 Changed 5 years ago by vadz

Sorry for missing the problem with -- instead of ++ in the original question.

Note: See TracTickets for help on using tickets.