Catching Valentina exceptions Mac OS X
Ruslan Zasukhin
sunshine at public.kherson.ua
Tue May 18 10:21:20 CDT 2004
On 5/18/04 10:13 AM, "Pascal.Brandt at swisstopo.ch"
<Pascal.Brandt at swisstopo.ch> wrote:
Hi Pascal,
> 1. Catching Valentina exceptions works fine on Windows (C++ SDK 1.10, Visual
> C++ 6.0) but I can't bring it to work correctly on Mac OS X (10.3.3, C++ SDK
> 1.10, CW 8.3).
>
> Code snippet used on both platform:
>
> try
> {
> // Make sure we catch the exception if opening fails
> m_pMapDB->OpenDataBase(pszMap);
> }
> catch (xFBL_Exception e)
> {
> // handle exception
> catch (xFBL_Exception e)
^^^^^^^^^^^^^^^^^^^^^^^^^
what is this an why ?
> sprintf( buf, "Map database access error: %d", e.GetErrorCode());
> ...
> }
>
> If the encryption key is wrong, the exception is caught on Windows (returns
> Valentina error number 326: kFBL_WrongEncryptionKey) like I want and I am
> happy :-). But on Mac OS X it crashes on "OpenDataBase()" -(.
>
> Have you an idea, a tip on what's could be problematic?
You try open encrypted db with no key ?
So problem only with THIS kind of exception/error?
All rest exceptions works?
> 2. When can I release allocated memory for the encryption key?
You should not, it use smart ptr.
> m_pStructureEncryption=new FBL_EncryptionKey((uchar*)"mypassword",(ulong)10);
>
> Trying to release it with "delete pMap->m_pStructureEncryption" brings to
> crash. What's wrong?
>
>
> Thank you in advance for your support, best regards
This is my code from Valentina for REALBasic
void DataBase_SetEncryption( REALobject instance, REALstring inKey )
{
V4RB_FUNC_START( "DataBase_SetEncryption" );
gVRB_Error = 0;
ClassData( DataBaseClass, instance, DataBaseData, data );
if( data->mDataBase )
{
try
{
FBL_EncryptionKeyCPtr key1 = (inKey)
? new FBL_EncryptionKey( (uchar*)inKey->CString(),
(ulong)inKey->Length())
: NULL;
data->mDataBase->SetEncryption( key1 );
}MY_END_TRY
}
V4RB_FUNC_DONE;
}
/***************************************************************************
********************
FUNCTION : void DataBase_ChangeEncryption( REALobject instance, REALstring
inOldKey, REALstring inNewKey );
DESCRIPTION:
****************************************************************************
*******************/
void DataBase_ChangeEncryption( REALobject instance, REALstring inOldKey,
REALstring inNewKey )
{
V4RB_FUNC_START( "DataBase_ChangeEncryption" );
gVRB_Error = 0;
ClassData( DataBaseClass, instance, DataBaseData, data );
if( data->mDataBase )
{
try
{
FBL_EncryptionKeyCPtr key1 = (inOldKey)
? new FBL_EncryptionKey(
(uchar*)inOldKey->CString(), (ulong)inOldKey->Length())
: NULL;
FBL_EncryptionKeyCPtr key2 = (inNewKey)
? new FBL_EncryptionKey(
(uchar*)inNewKey->CString(), (ulong)inNewKey->Length())
: NULL;
data->mDataBase->ChangeEncryption( key1, key2 );
}MY_END_TRY
}
V4RB_FUNC_DONE;
}
/***************************************************************************
********************
FUNCTION : void DataBase_SetStructureEncryption( REALobject instance,
REALstring inKey );
DESCRIPTION:
****************************************************************************
*******************/
void DataBase_SetStructureEncryption( REALobject instance, REALstring inKey
)
{
V4RB_FUNC_START( "DataBase_SetStructureEncryption" );
gVRB_Error = 0;
ClassData( DataBaseClass, instance, DataBaseData, data );
if( data->mDataBase )
{
try
{
FBL_EncryptionKeyCPtr key1 = (inKey)
? new FBL_EncryptionKey( (uchar*)inKey->CString(),
(ulong)inKey->Length())
: NULL;
data->mDataBase->SetStructureEncryption( key1 );
}MY_END_TRY
}
V4RB_FUNC_DONE;
}
/***************************************************************************
********************
FUNCTION : void DataBase_ChangeStructureEncryption( REALobject instance,
REALstring inOldKey, REALstring inNewKey );
DESCRIPTION:
****************************************************************************
*******************/
void DataBase_ChangeStructureEncryption( REALobject instance, REALstring
inOldKey, REALstring inNewKey )
{
V4RB_FUNC_START( "DataBase_ChangeStructureEncryption" );
gVRB_Error = 0;
ClassData( DataBaseClass, instance, DataBaseData, data );
if( data->mDataBase )
{
try
{
FBL_EncryptionKeyCPtr key1 = (inOldKey)
? new FBL_EncryptionKey(
(uchar*)inOldKey->CString(), (ulong)inOldKey->Length())
: NULL;
FBL_EncryptionKeyCPtr key2 = (inNewKey)
? new FBL_EncryptionKey(
(uchar*)inNewKey->CString(), (ulong)inNewKey->Length())
: NULL;
data->mDataBase->ChangeStructureEncryption( key1, key2 );
}MY_END_TRY
}
V4RB_FUNC_DONE;
}
--
Best regards,
Ruslan Zasukhin [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com
To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
More information about the Valentina
mailing list