Fix #5755: Locale preflet crashing when dragging languages around
* The flag bitmaps being part of list items were not treated properly in the language item's copy constructor (the bitmap pointer was copied, not the bitmap object itself). As a result, bitmap objects were freed more than once. * some cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36487 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -37,6 +37,15 @@ LanguageListItem::LanguageListItem(const char* text, const char* code)
|
||||
}
|
||||
|
||||
|
||||
LanguageListItem::LanguageListItem(const LanguageListItem& other)
|
||||
:
|
||||
BStringItem(other.Text()),
|
||||
fLanguageCode(other.fLanguageCode),
|
||||
fIcon(other.fIcon ? new(std::nothrow) BBitmap(other.fIcon) : NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LanguageListItem::~LanguageListItem()
|
||||
{
|
||||
delete fIcon;
|
||||
|
||||
@@ -19,34 +19,18 @@
|
||||
class LanguageListItem: public BStringItem {
|
||||
public:
|
||||
LanguageListItem(const char* text, const char* code);
|
||||
|
||||
LanguageListItem(const LanguageListItem& other)
|
||||
:
|
||||
BStringItem(other.Text()),
|
||||
fLanguageCode(other.fLanguageCode),
|
||||
fIcon(other.fIcon)
|
||||
{}
|
||||
|
||||
LanguageListItem(const LanguageListItem& other);
|
||||
~LanguageListItem();
|
||||
|
||||
const inline BString LanguageCode() { return fLanguageCode; }
|
||||
const BString& LanguageCode() { return fLanguageCode; }
|
||||
void DrawItem(BView *owner, BRect frame, bool complete = false);
|
||||
|
||||
private:
|
||||
const BString fLanguageCode;
|
||||
BString fLanguageCode;
|
||||
BBitmap* fIcon;
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
compare_list_items(const void* _a, const void* _b)
|
||||
{
|
||||
LanguageListItem* a = *(LanguageListItem**)_a;
|
||||
LanguageListItem* b = *(LanguageListItem**)_b;
|
||||
return strcasecmp(a->Text(), b->Text());
|
||||
}
|
||||
|
||||
|
||||
class LanguageListView: public BOutlineListView {
|
||||
public:
|
||||
LanguageListView(const char* name, list_view_type type);
|
||||
|
||||
@@ -34,6 +34,15 @@
|
||||
#define TR_CONTEXT "Locale Preflet Window"
|
||||
|
||||
|
||||
static int
|
||||
compare_list_items(const void* _a, const void* _b)
|
||||
{
|
||||
LanguageListItem* a = *(LanguageListItem**)_a;
|
||||
LanguageListItem* b = *(LanguageListItem**)_b;
|
||||
return strcasecmp(a->Text(), b->Text());
|
||||
}
|
||||
|
||||
|
||||
LocaleWindow::LocaleWindow()
|
||||
:
|
||||
BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_NOT_RESIZABLE
|
||||
|
||||
Reference in New Issue
Block a user