From 2f4575bfcfd715a5341fbfa916488fa1927e365d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 1 Jul 2003 16:04:00 +0000 Subject: [PATCH] Fixed a crashing bug in BParameter::Unflatten(): it accidently called AddInput()/AddOutput() instead of just adding the unflattened (unfixed) pointer to the appropriate lists. Added a comment that it's valid to add the pointers at this time since they will be fixed later on. BParameterGroup::MakeControl() unnecessarily initialized the newly created parameters with some default values. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3785 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/media/ParameterWeb.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/kits/media/ParameterWeb.cpp b/src/kits/media/ParameterWeb.cpp index 5cf6cdd6f8..a04effc0dd 100644 --- a/src/kits/media/ParameterWeb.cpp +++ b/src/kits/media/ParameterWeb.cpp @@ -1232,25 +1232,25 @@ BParameterGroup &BParameterGroup::operator=(const BParameterGroup &clone) */ +/** Creates an uninitialized parameter of the specified type. + * Unlike the BParameterGroup::MakeXXXParameter() type of methods, this + * method does not add the parameter to this group automatically. + */ + BParameter * BParameterGroup::MakeControl(int32 type) { CALLED(); - /*NOTE: - Creates a new parameter for addition within this with a type defined by - the passed 'type' parameter, - BUT DOES NOT ADD THE CREATED PARAMETER TO THE INTERNAL LIST OF PARAMETERS - */ switch (type) { case BParameter::B_NULL_PARAMETER: - return new BNullParameter(-1, B_MEDIA_UNKNOWN_TYPE, mWeb, "nullParameter", B_GENERIC); + return new BNullParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL); case BParameter::B_DISCRETE_PARAMETER: - return new BDiscreteParameter(-1, B_MEDIA_UNKNOWN_TYPE, mWeb, "discreteParameter", B_GENERIC); + return new BDiscreteParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL); case BParameter::B_CONTINUOUS_PARAMETER: - return new BContinuousParameter(-1, B_MEDIA_UNKNOWN_TYPE, mWeb, "continuousParameter", B_GENERIC,"",0,100,1); + return new BContinuousParameter(-1, B_MEDIA_NO_TYPE, NULL, NULL, NULL, NULL, 0, 0, 0); default: ERROR("BParameterGroup::MakeControl unknown type %ld\n", type); @@ -1743,6 +1743,9 @@ BParameter::Unflatten(type_code code, const void *buffer, ssize_t size) // read the list of inputs + // it will directly add the pointers in the flattened message to the list; + // these will be fixed to point to the real inputs/outputs later in FixRefs() + int32 count = read_from_buffer_swap32(&buffer, mSwapDetected); if (mInputs == NULL) @@ -1751,7 +1754,7 @@ BParameter::Unflatten(type_code code, const void *buffer, ssize_t size) mInputs->MakeEmpty(); for (int32 i = 0; i < count; i++) { - AddInput(read_from_buffer_swap32(&buffer, mSwapDetected)); + mInputs->AddItem(read_from_buffer_swap32(&buffer, mSwapDetected)); } // read the list of outputs @@ -1764,7 +1767,7 @@ BParameter::Unflatten(type_code code, const void *buffer, ssize_t size) mOutputs->MakeEmpty(); for (int32 i = 0; i < count; i++) { - AddOutput(read_from_buffer_swap32(&buffer, mSwapDetected)); + mOutputs->AddItem(read_from_buffer_swap32(&buffer, mSwapDetected)); } mMediaType = read_from_buffer_swap32(&buffer, mSwapDetected);