Opened 4 years ago

Closed 4 years ago

#11388 closed defect (fixed)

wxAuiDefaultTabArt::Clone() should just use copy contructor

Reported by: SnowLeopard Owned by:
Priority: normal Milestone:
Component: wxAui Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: yes

Description

In the function wxAuiDefaultTabArt::Clone(), it creates a new wxAuiDefaultTabArt and then simply calls the "Set" functions like this:

art->SetNormalFont(m_normal_font);
art->SetSelectedFont(m_selected_font);
art->SetMeasuringFont(m_measuring_font);

The problem is, the other flags (colors, brushes, etc.) will get reset because of this. If you are using a custom art provider that changes any of these flags, then your changes will get lost whenever Clone is called.

Why not just have wxAuiDefaultTabArt use a copy CTOR instead of calling Set functions and resetting most of its fields? All the fields in this class are on the stack, so a copy CTOR is safe.

Attachments (1)

update.diff download (571 bytes) - added by SnowLeopard 4 years ago.
patch file

Download all attachments as: .zip

Change History (4)

comment:1 Changed 4 years ago by SnowLeopard

I verified that using a copy CTOR works perfectly. I simply changed the Clone method in auibook.cpp to this:

wxAuiTabArt* wxAuiDefaultTabArt::Clone()
{
    return new wxAuiDefaultTabArt(*this);
}

This makes it so that an art provider derived from wxAuiDefaultTabArt won't loss any customized fields in the base class.

Changed 4 years ago by SnowLeopard

patch file

comment:2 Changed 4 years ago by SnowLeopard

  • Patch set

comment:3 Changed 4 years ago by VZ

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

(In [65069]) Implement wxAuiDefaultTabArt::Clone() using its copy ctor.

Compiler-generated copy ctor works just fine for this class, there is really
no reason to reimplement it, especially wrongly (as it loses many and even
most of the fields), in Clone().

Closes #11388.

Note: See TracTickets for help on using tickets.