Factored out initialization of default values into an _Init() function that's now called by all constructors.

The BMessage version of the ViewState constructor was not retrieving the icon/last icon size values.

May fix #4322.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36455 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2010-04-24 19:35:53 +00:00
parent 49a0c7942f
commit b64b6705ad
2 changed files with 23 additions and 12 deletions

View File

@ -278,24 +278,14 @@ BColumn::_Sanitize(BColumn *column)
BViewState::BViewState() BViewState::BViewState()
{ {
fViewMode = kListMode; _Init();
fLastIconMode = 0;
fIconSize = 32;
fLastIconSize = 32;
fListOrigin.Set(0, 0);
fIconOrigin.Set(0, 0);
fPrimarySortAttr = AttrHashString(kAttrStatName, B_STRING_TYPE);
fPrimarySortType = B_STRING_TYPE;
fSecondarySortAttr = 0;
fSecondarySortType = 0;
fReverseSort = false;
_StorePreviousState(); _StorePreviousState();
} }
BViewState::BViewState(BMallocIO *stream, bool endianSwap) BViewState::BViewState(BMallocIO *stream, bool endianSwap)
{ {
_Init();
stream->Read(&fViewMode, sizeof(uint32)); stream->Read(&fViewMode, sizeof(uint32));
stream->Read(&fLastIconMode, sizeof(uint32)); stream->Read(&fLastIconMode, sizeof(uint32));
stream->Read(&fListOrigin, sizeof(BPoint)); stream->Read(&fListOrigin, sizeof(BPoint));
@ -331,8 +321,11 @@ BViewState::BViewState(BMallocIO *stream, bool endianSwap)
BViewState::BViewState(const BMessage &message) BViewState::BViewState(const BMessage &message)
{ {
_Init();
message.FindInt32(kViewStateViewModeName, (int32 *)&fViewMode); message.FindInt32(kViewStateViewModeName, (int32 *)&fViewMode);
message.FindInt32(kViewStateLastIconModeName, (int32 *)&fLastIconMode); message.FindInt32(kViewStateLastIconModeName, (int32 *)&fLastIconMode);
message.FindInt32(kViewStateLastIconSizeName,(int32 *)&fLastIconSize);
message.FindInt32(kViewStateIconSizeName, (int32 *)&fIconSize);
message.FindPoint(kViewStateListOriginName, &fListOrigin); message.FindPoint(kViewStateListOriginName, &fListOrigin);
message.FindPoint(kViewStateIconOriginName, &fIconOrigin); message.FindPoint(kViewStateIconOriginName, &fIconOrigin);
message.FindInt32(kViewStatePrimarySortAttrName, message.FindInt32(kViewStatePrimarySortAttrName,
@ -433,6 +426,23 @@ BViewState::InstantiateFromMessage(const BMessage &message)
} }
void
BViewState::_Init()
{
fViewMode = kListMode;
fLastIconMode = 0;
fIconSize = 32;
fLastIconSize = 32;
fListOrigin.Set(0, 0);
fIconOrigin.Set(0, 0);
fPrimarySortAttr = AttrHashString(kAttrStatName, B_STRING_TYPE);
fPrimarySortType = B_STRING_TYPE;
fSecondarySortAttr = 0;
fSecondarySortType = 0;
fReverseSort = false;
}
void void
BViewState::_StorePreviousState() BViewState::_StorePreviousState()
{ {

View File

@ -151,6 +151,7 @@ class BViewState {
uint32 fSecondarySortType; uint32 fSecondarySortType;
bool fReverseSort; bool fReverseSort;
void _Init();
void _StorePreviousState(); void _StorePreviousState();
uint32 fPreviousViewMode; uint32 fPreviousViewMode;