Stupid me, vector icon data loaded by a local BResources
object is lost outside its scope. Now vector data is copied instead. Spotted by Pete Goodeve, thanks! This should close #4562. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34358 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fb40f7a489
commit
50a1d8a4f5
@ -63,11 +63,23 @@ DeviceWatcher::DeviceWatcher()
|
||||
|
||||
BResources resources;
|
||||
if (resources.SetTo(&file) == B_OK) {
|
||||
fVectorIconData = (const uint8*)resources.LoadResource(
|
||||
B_VECTOR_ICON_TYPE, "endpoint_vector_icon", &fVectorIconDataSize);
|
||||
size_t dataSize;
|
||||
// Load MIDI port endpoint vector icon
|
||||
const uint8* data = (const uint8*)resources.LoadResource(
|
||||
B_VECTOR_ICON_TYPE, "endpoint_vector_icon", &dataSize);
|
||||
|
||||
if (data != NULL && dataSize > 0)
|
||||
fVectorIconData = new(std::nothrow) uint8[dataSize];
|
||||
|
||||
if (fVectorIconData) {
|
||||
// data is own by resources local object: copy its content for
|
||||
// later use
|
||||
memcpy(fVectorIconData, data, dataSize);
|
||||
fVectorIconDataSize = dataSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Render 32x32 and 16x16 icons for R5 compatibility
|
||||
// Render 32x32 and 16x16 B_CMAP8 icons for R5 compatibility
|
||||
if (fVectorIconData != NULL) {
|
||||
fLargeIcon = new(std::nothrow) BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
|
||||
fMiniIcon = new(std::nothrow) BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
|
||||
@ -94,6 +106,7 @@ DeviceWatcher::~DeviceWatcher()
|
||||
|
||||
delete fLargeIcon;
|
||||
delete fMiniIcon;
|
||||
delete[] fVectorIconData;
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
typedef HashMap<HashString, DeviceEndpoints*> DeviceEndpointsMap;
|
||||
DeviceEndpointsMap fDeviceEndpointsMap;
|
||||
|
||||
const uint8* fVectorIconData;
|
||||
uint8* fVectorIconData;
|
||||
size_t fVectorIconDataSize;
|
||||
BBitmap* fLargeIcon;
|
||||
BBitmap* fMiniIcon;
|
||||
|
Loading…
Reference in New Issue
Block a user