Virtual Table InsertRecord on Android

Virtual Table InsertRecord on Android

Postby eelias » Mon 21 Jul 2014 14:18

Hi there,

This is my first time here, and I am giving a try on TVirtualTable.

I have a project where I am recently using it.

Delphi Xe6 Update 1 Firemonkey.

It is cross platform, so I am trying now to make my project work on Android.

I am using VirtualTable in a DataModule. Since there is a lot of troubles to make LiveBinding with LookupComboBox, I decided to use a Memory Table to hold the lists of data (the lookup data for the combo) and then wire visually to LiveBinding. It is so easy and works just fine on win32

However there is a problem on android that causes an Fragmentation Fault.

All VTtables are the same, 2 fiedls: Text: string and Value: integer

The property ACTIVE is kept true, so when the datamodule all VTTables start opened.

I have added a AFTEROPEN event on each VTTable to fill in the list, as an example, one of them:

Code: Select all
procedure TDMGlobalSystem.vtResourceTypeAfterOpen(DataSet: TDataSet);
var
  enum : TNaharEnumResourceType;
begin
  inherited;

  for enum := Low(TNaharEnumResourceType) to High(TNaharEnumResourceType) do
    DataSet.InsertRecord([EnumResourceTypeToStr(enum), Ord(enum)]);
end;


Like I said, all the tables are the same structure, and I use to hold lists for lookup. In this example I go each value of an enumeration:

Code: Select all
  TNaharEnumResourceType        = (trtApp, trtTab, trtSection, trtField, trtCommand, trtOther);

and add to the table with the correspondent string:

Code: Select all
function EnumResourceTypeToStr(AEnum: TNaharEnumResourceType): string;
begin
  case AEnum of
    trtApp     : result := 'Aplicação';
    trtTab     : result := 'Pagina (Tab)';
    trtSection : result := 'Secção';
    trtField   : result := 'Campo';
    trtCommand : result := 'Comando';
    trtOther   : result := 'Outro';
  end;
end;


Seems basic, and the way implemented with low and high let me change the code without concerns on the future when changes happen.

The problem is that this inserrecord is causing a exception o android.

In this DataModule there are 3 tables that are similar. The 2 first gets started and insertrecord works. The 3rd starts with insertrecords and to some point stops.

Am I using InsertRecord wrong? is it different on Android?

Call Stack:
Code: Select all
System.Varutils.SafeArrayValidate(0x7,1)
System.Varutils.SafeArrayDestroy(0x7)
System.Varutils.VariantClear(@0x68bd7688: { = { = {RawData = {1074556108, 1074556108, 7, 1634561859}},  = {VType = 27852,  = { = {VBytes = {12, 64, 204, 108, 12, 64, 7, 0, 0, 0, 67, 111, 109, 97}},  = {VWords = {16396, 27852, 16396, 7, 0, 28483, 24941}},  = {Reserved1 = 16396,  = { = {VLongs = {475148, 1866661888, 1882874221}},  = {Reserved2 = 16396, Reserved3 = 7,  = { = {VRecord = {PRecord = 0x703a616d, RecInfo = 0x4b05659}},  = {VUString = 0x703a616d},  = {VPointer = 0x703a616d},  = {VArray = 0x703a616d},  = {VAny = 0x703a616d},  = {VString = 0x703a616d},  = {VUInt64 = 337864914187739501},  = {VInt64 = 337864914187739501},  = {VLongWord = 1882874221},  = {VWord = 24941},  = {VByte = 109},  = {VShortInt = 109},  = {VUnknown = 0x703a616d},  = {VBoolean = 24941},  = {VError = 1882874221},  = {VDispatch = 0x703a616d},  = {VOleStr = 0x703a616d},  = {VDate = 4.2916517249435426e-286},  = {VCurrency = 188287.4221},  = {VDouble = 4.2916517249435426e-286},  = {VSingle = 2.30727969e+029},  = {VInteger = 1882874221},  = {VSmallInt = 24941}}}}}}}}})
System.Variants.VarArrayClear(@0x68bd7688: { = { = {RawData = {1074556108, 1074556108, 7, 1634561859}},  = {VType = 27852,  = { = {VBytes = {12, 64, 204, 108, 12, 64, 7, 0, 0, 0, 67, 111, 109, 97}},  = {VWords = {16396, 27852, 16396, 7, 0, 28483, 24941}},  = {Reserved1 = 16396,  = { = {VLongs = {475148, 1866661888, 1887330669}},  = {Reserved2 = 16396, Reserved3 = 7,  = { = {VRecord = {PRecord = 0x707e616d, RecInfo = 0x18505659}},  = {VUString = 0x707e616d},  = {VPointer = 0x707e616d},  = {VArray = 0x707e616d},  = {VAny = 0x707e616d},  = {VString = 0x707e616d},  = {VUInt64 = 1751995197186531693},  = {VInt64 = 1751995197186531693},  = {VLongWord = 1887330669},  = {VWord = 24941},  = {VByte = 109},  = {VShortInt = 109},  = {VUnknown = 0x707e616d},  = {VBoolean = 24941},  = {VError = 1887330669},  = {VDispatch = 0x707e616d},  = {VOleStr = 0x707e616d},  = {VDate = 1.4323300712579181e-191},  = {VCurrency = 188733.0669},  = {VDouble = 1.4323300712579181e-191},  = {VSingle = 3.14907892e+029},  = {VInteger = 1887330669},  = {VSmallInt = 24941}}}}}}}}})
System.Variants.VarClearDeep(@0x68bd7688: { = { = {RawData = {1074556108, 1074556108, 7, 1634561859}},  = {VType = 27852,  = { = {VBytes = {12, 64, 204, 108, 12, 64, 7, 0, 0, 0, 67, 111, 109, 97}},  = {VWords = {16396, 27852, 16396, 7, 0, 28483, 24941}},  = {Reserved1 = 16396,  = { = {VLongs = {475148, 1866661888, 1882546541}},  = {Reserved2 = 16396, Reserved3 = 7,  = { = {VRecord = {PRecord = 0x7035616d, RecInfo = 0x5a05659}},  = {VUString = 0x7035616d},  = {VPointer = 0x7035616d},  = {VArray = 0x7035616d},  = {VAny = 0x7035616d},  = {VString = 0x7035616d},  = {VUInt64 = 405418908597969261},  = {VInt64 = 405418908597969261},  = {VLongWord = 1882546541},  = {VWord = 24941},  = {VByte = 109},  = {VShortInt = 109},  = {VUnknown = 0x7035616d},  = {VBoolean = 24941},  = {VError = 1882546541},  = {VDispatch = 0x7035616d},  = {VOleStr = 0x7035616d},  = {VDate = 1.4062884371292916e-281},  = {VCurrency = 188254.6541},  = {VDouble = 1.4062884371292916e-281},  = {VSingle = 2.24538269e+029},  = {VInteger = 1882546541},  = {VSmallInt = 24941}}}}}}}}})
System.Variants._VarCopy(@0x68bd7688: { = { = {RawData = {1074556108, 1074556108, 7, 1634561859}},  = {VType = 27852,  = { = {VBytes = {12, 64, 204, 108, 12, 64, 7, 0, 0, 0, 67, 111, 109, 97}},  = {VWords = {16396, 27852, 16396, 7, 0, 28483, 24941}},  = {Reserved1 = 16396,  = { = {VLongs = {475148, 1866661888, 1887002989}},  = {Reserved2 = 16396, Reserved3 = 7,  = { = {VRecord = {PRecord = 0x7079616d, RecInfo = 0x19685659}},  = {VUString = 0x7079616d},  = {VPointer = 0x7079616d},  = {VArray = 0x7079616d},  = {VAny = 0x7079616d},  = {VString = 0x7079616d},  = {VUInt64 = 1830808190665187693},  = {VInt64 = 1830808190665187693},  = {VLongWord = 1887002989},  = {VWord = 24941},  = {VByte = 109},  = {VShortInt = 109},  = {VUnknown = 0x7079616d},  = {VBoolean = 24941},  = {VError = 1887002989},  = {VDispatch = 0x7079616d},  = {VOleStr = 0x7079616d},  = {VDate = 2.7966951428437351e-186},  = {VCurrency = 188700.2989},  = {VDouble = 2.7966951428437351e-186},  = {VSingle = 3.08718192e+029},  = {VInteger = 1887002989},  = {VSmallInt = 24941}}}}}}}}},{ = { = {RawData = {1757253408, 1757247112, 1635862268, 1605754657}},  = {VType = 36640,  = { = {VBytes = {189, 104, 136, 118, 189, 104, 252, 70, 129, 97, 33, 223, 181, 95}},  = {VWords = {26813, 30344, 26813, 18172, 24961, 57121, 24501}},  = {Reserved1 = 26813,  = { = {VLongs = {1190947005, -551460479, 1883463605}},  = {Reserved2 = 26813, Reserved3 = 18172,  = { = {VRecord = {PRecord = 0x70435fb5, RecInfo = 0x17105659}},  = {VUString = 0x70435fb5},  = {VPointer = 0x70435fb5},  = {VArray = 0x70435fb5},  = {VAny = 0x70435fb5},  = {VString = 0x70435fb5},  = {VUInt64 = 1661923204635254709},  = {VInt64 = 1661923204635254709},  = {VLongWord = 1883463605},  = {VWord = 24501},  = {VByte = 181},  = {VShortInt = -75},  = {VUnknown = 0x70435fb5},  = {VBoolean = 24501},  = {VError = 1883463605},  = {VDispatch = 0x70435fb5},  = {VOleStr = 0x70435fb5},  = {VDate = 1.3659764004263162e-197},  = {VCurrency = 188346.3605},  = {VDouble = 1.3659764004263162e-197},  = {VSingle = 2.41861118e+029},  = {VInteger = 1883463605},  = {VSmallInt = 24501}}}}}}}}})
:5FB5DF20 Memdata.TData.PutFieldData(Memdata.TFieldDesc*, void*, void*, bool, bool)
:5FB5DD7E Memdata.TData.PutField(Memdata.TFieldDesc*, void*, void*, bool, bool)
:5FB7BC66 Memds.TMemDataSet.SetFieldData(Data.Db.TField*, void*)
:5FB78F82 Memds.TMemDataSet.SetFieldData(Data.Db.TField*, System.DynamicArray<unsigned char>)
Data.Db.TDataSet.SetFieldData(0x68bd7bb8,0x68bd8830,0x68bd8f20,true)
:5FB79018 Memds.TMemDataSet.SetFieldData(Data.Db.TField*, System.DynamicArray<unsigned char>, bool)
Data.Db.TField.SetData(0x68bd8830,0x68bd8f20,true)
Data.Db.TVariantField.SetVarValue(0x68bd8830,{ = { = {RawData = {1635862880, 1757251632, 1635862904, 1599109123}},  = {VType = 18784,  = { = {VBytes = {129, 97, 48, 136, 189, 104, 120, 73, 129, 97, 3, 120, 80, 95}},  = {VWords = {24961, 34864, 26813, 18808, 24961, 30723, 24400}},  = {Reserved1 = 24961,  = { = {VLongs = {1232627901, 2013487489, 1881431888}},  = {Reserved2 = 26813, Reserved3 = 18808,  = { = {VRecord = {PRecord = 0x70245f50, RecInfo = 0xa505659}},  = {VUString = 0x70245f50},  = {VPointer = 0x70245f50},  = {VArray = 0x70245f50},  = {VAny = 0x70245f50},  = {VString = 0x70245f50},  = {VUInt64 = 743188880649641808},  = {VInt64 = 743188880649641808},  = {VLongWord = 1881431888},  = {VWord = 24400},  = {VByte = 80},  = {VShortInt = 80},  = {VUnknown = 0x70245f50},  = {VBoolean = 24400},  = {VError = 1881431888},  = {VDispatch = 0x70245f50},  = {VOleStr = 0x70245f50},  = {VDate = 5.3128075033094167e-259},  = {VCurrency = 188143.1888},  = {VDouble = 5.3128075033094167e-259},  = {VSingle = 2.03483069e+029},  = {VInteger = 1881431888},  = {VSmallInt = 24400}}}}}}}}})
Data.Db.TVariantField.SetAsInteger(0x68bd8830,4)
Data.Db.TField.AssignValue(0x68bd8830,{ = { = {_Reserved1 = 1635863332, VType = 48},  = { = { = {VUnicodeString = 0x61814b24},  = {VInt64 = 0x61814b24},  = {VWideString = 0x61814b24},  = {VInterface = 0x61814b24},  = {VVariant = 0x61814b24},  = {VCurrency = 0x61814b24},  = {VPWideChar = 0x61814b24},  = {VWideChar = #19236},  = {VClass = 0x61814b24},  = {VObject = 0x61814b24},  = {VPointer = 0x61814b24},  = {VExtended = 0x61814b24},  = {VBoolean = true (36)},  = {VInteger = 1635863332}}}}})
Data.Db.TDataSet.SetFields(0x68bd7bb8,@0x61814b1c: {{ = { = {_Reserved1 = 1757022860, VType = 17},  = { = { = {VUnicodeString = 0x68ba0a8c},  = {VInt64 = 0x68ba0a8c},  = {VWideString = 0x68ba0a8c},  = {VInterface = 0x68ba0a8c},  = {VVariant = 0x68ba0a8c},  = {VCurrency = 0x68ba0a8c},  = {VPWideChar = 0x68ba0a8c},  = {VWideChar = #2700},  = {VClass = 0x68ba0a8c},  = {VObject = 0x68ba0a8c},  = {VPointer = 0x68ba0a8c},  = {VExtended = 0x68ba0a8c},  = {VBoolean = true (140)},  = {VInteger = 1757022860}}}}}},1)
Data.Db.TDataSet.AddRecord(0x68bd7bb8,@0x61814b1c: {{ = { = {_Reserved1 = 1757022860, VType = 17},  = { = { = {VUnicodeString = 0x68ba0a8c},  = {VInt64 = 0x68ba0a8c},  = {VWideString = 0x68ba0a8c},  = {VInterface = 0x68ba0a8c},  = {VVariant = 0x68ba0a8c},  = {VCurrency = 0x68ba0a8c},  = {VPWideChar = 0x68ba0a8c},  = {VWideChar = #2700},  = {VClass = 0x68ba0a8c},  = {VObject = 0x68ba0a8c},  = {VPointer = 0x68ba0a8c},  = {VExtended = 0x68ba0a8c},  = {VBoolean = true (140)},  = {VInteger = 1757022860}}}}}},1,false)
Data.Db.TDataSet.InsertRecord(0x68bd7bb8,@0x61814b1c: {{ = { = {_Reserved1 = 1757022860, VType = 17},  = { = { = {VUnicodeString = 0x68ba0a8c},  = {VInt64 = 0x68ba0a8c},  = {VWideString = 0x68ba0a8c},  = {VInterface = 0x68ba0a8c},  = {VVariant = 0x68ba0a8c},  = {VCurrency = 0x68ba0a8c},  = {VPWideChar = 0x68ba0a8c},  = {VWideChar = #2700},  = {VClass = 0x68ba0a8c},  = {VObject = 0x68ba0a8c},  = {VPointer = 0x68ba0a8c},  = {VExtended = 0x68ba0a8c},  = {VBoolean = true (140)},  = {VInteger = 1757022860}}}}}},1)
Nahar.Datamodule.Globalsystem.TDMGlobalSystem.vtResourceTypeAfterOpen(0x67c4d808,0x68bd7bb8)
Data.Db.TDataSet.DoAfterOpen(0x68bd7bb8)
:5FB777A8 Memds.TMemDataSet.DoAfterOpen()
Data.Db.TDataSet.OpenCursorComplete(0x68bd7bb8)
Data.Db.TDataSet.SetActive(0x68bd7bb8,true)
:5FB86A3A Virtualtable.TVirtualTable.SetActive(bool)
:5FB86578 Virtualtable.TVirtualTable.Loaded()
System.Classes.NotifyGlobalLoading
System.Classes.InitInheritedComponent(0x6042ab3c)
System.Classes.TDataModule.TDataModule(0x67c4d808,0,0x669b59c8)
Nahar.Datamodule.Base.TDMBase.TDMBase(0x67c4d808,true,0x669b59c8)
Nahar.View.Desktop.Globalusuario.Nahar_View_Desktop_GlobalUsuario$3429$ActRec_$0$Body$3430$ActRec.$0$0$Body(0x68b9f478,0x669b59c8)
:5FD68A04 __stub_in20s__ZN5Nahar4View7Desktop13Globalusuario64Nahar_View_Desktop_GlobalUsuario$3429$ActRec_$0$Body$3430$ActRec9$0$0$BodyEPN3Fmx14Naharbaseframe10TFrameBaseE
Fmx.Naharbaseframe.TFrameBase.TFrameBase(0x669b59c8,1,0x68b9f29c,0x68b9f48c)
Nahar.View.Desktop.Globalusuario.Nahar_View_Desktop_GlobalUsuario$3429$ActRec.$0$Body(0x61d14630,0x68b9f29c)
:5FD688BA __stub_in12s__ZN5Nahar4View7Desktop13Globalusuario44Nahar_View_Desktop_GlobalUsuario$3429$ActRec7$0$BodyEN6System15DelphiInterfaceINS0_4Int221INaharViewConstructorEEE
Nahar.Factory.TNaharFactory__3<System.UnicodeString, System.DelphiInterface<Nahar.View.Int.INaharView>, System.DelphiInterface<Nahar.View.Int2.INaharViewConstructor> >.GetInstance(0x61d02db8,'global.usuario',0x68b9f29c)
Nahar.Factory.Presenter.TNaharPresenterFactory.GetSmartInstance(0x61d02e08,'global.usuario','global.usuario','global.system',{},{},0x66a98878,0x665bbed8,0x665cbd68,0x665c4494)
Nahar.App.TNaharApp.GetPresenterFactoryParam(0x66a7bda0,'global.usuario','global.usuario','global.system',{},{})
Nahar.App.TNaharApp.GetPresenterFactory(0x66a7bda0,'global.usuario','global.usuario','global.system')
Nahar.App.Globalconfig.TNaharAppGlobalConfig.Activate(0x66a7bda0,true)
:5F865F1E __stub_in56v4__ZN5Nahar3App9TNaharApp8ActivateEb
Nahar.App.TNaharAppItem.Activate(0x61d0ddc8,1)
:5F866AE4 __stub_in56s__ZN5Nahar3App13TNaharAppItem8ActivateEb
Nahar.Client.Desktop.TNaharDesktop.AppFactory(0x665c4448,'global.config')
Nahar.Client.Tilemenu.TNaharTile.OnObserver(0x668952c8,0x66897d50,{},{})
:5F4D17E4 __stub_in28v0__ZN5Nahar6Common12TNaharObject10OnObserverEPN6System7TObjectERKNS2_7VariantES7_
Nahar.Common.TNaharObject.NotifyObservers(0x66897d50,{},{})
Fmx.Desktopadapter.TFMXTileAdapter.OnClick(0x66897d50,0x66891b30)
Fmx.Controls.TControl.Click(0x66891b30)
Fmx.Controls.TControl.MouseClick(0x66891b30,0,136,63.0909119,47.2888031)
:5F3F562E __stub_in836v89__ZN3Fmx8Controls8TControl10MouseClickEN6System7Uitypes12TMouseButtonENS2_3SetINS2_7Classes17System_Classes__1ELS7_0ELS7_10EEEff
Fmx.Forms.TCommonCustomForm.MouseUp(0x61e201f8,0,136,93.0909119,148.288803,true)
Fmx.Platform.Android.TWindowManager.MouseUp(0x5ac2de98,0,136,93.0909119,173.288803,true)
Fmx.Platform.Android.TPlatformAndroid.ProcessAndroidMouseEvents(0x5ac68328)
Fmx.Platform.Android.TPlatformAndroid.HandleAndroidMotionEvent(0x5ac68328,0x6696ce60)
Fmx.Platform.Android.TPlatformAndroid.HandleAndroidInputEvent(0x5ac68328,0x6696ce60)
Fmx.Platform.Android.HandleAndroidInputEvent(@0x61adc4e8: {userData = nil, onAppCmd = 0x5f355231 <Fmx.Platform.Android.HandleAndroidCmd(Androidapi.Appglue.TAndroid_app&, int)>, onInputEvent = 0x5f3551f9 <Fmx.Platform.Android.HandleAndroidInputEvent(Androidapi.Appglue.TAndroid_app&, AInputEvent*)>, activity = 0x5ac66cf8, config = 0x61b0e260, savedState = nil, savedStateSize = 0, looper = 0x61adc580, inputQueue = 0x61e1e870, window = 0x61e1f208, contentRect = {left = 0, top = 0, right = 0, bottom = 0}, activityState = 11, destroyRequested = 0, mutex = {value = 0}, cond = {value = -8}, msgread = 40, msgwrite = 41, thread = 0, cmdPollSource = {id = 1, app = 0x61adc4e8, process = 0x5f023ba9 <Androidapi.Appglue.process_cmd(Androidapi.Appglue.TAndroid_app*, Androidapi.Appglue.android_poll_source*)>}, inputPollSource = {id = 2, app = 0x61adc4e8, process = 0x5f023aa9 <Androidapi.Appglue.ProcessInput(Androidapi.Appglue.TAndroid_app*, Androidapi.Appglue.android_poll_source*)>}, running = 0, stateSaved = 0, destroyed = 0, redrawNeeded = 0, pendingInputQueue = 0x61e1e870, pendingWindow = 0x61e1f208, pendingContentRect = {left = 0, top = 0, right = 0, bottom = 0}},0x6696ce60)
Androidapi.Appglue.ProcessInput(0x61adc4e8,0x61adc548)
Fmx.Platform.Android.TPlatformAndroid.InternalWaitMessage(0x5ac68328,0)
Fmx.Platform.Android.TPlatformAndroid.WaitMessage(0x5ac68328)
Fmx.Platform.Android.TPlatformAndroid.Run(0x5ac68328)
:5F34470E __stub_in256s__ZN3Fmx8Platform7Android16TPlatformAndroid3RunEv
eelias
 
Posts: 5
Joined: Mon 21 Jul 2014 13:39

Re: Virtual Table InsertRecord on Android

Postby AlexP » Tue 22 Jul 2014 09:14

Hello,

Please provide the table structure, or send a saved table file (*.VTD) reproducing the problem to alexp*devart*com .
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

Re: Virtual Table InsertRecord on Android

Postby eelias » Tue 22 Jul 2014 13:09

I sent you an email with the file.

Here is the same information as form stream:
object vtTileSizes: TVirtualTable
Active = True
AfterOpen = vtTileSizesAfterOpen
FieldDefs = <
item
Name = 'Text'
DataType = ftString
Size = 20
end
item
Name = 'Value'
DataType = ftVariant
end>
Left = 616
Top = 16
Data = {
030002000400546578740100140000000000050056616C756520000000000000
00000000000000}
end


All the tables are identical to this one, except that I change the name and the AFTERPOST according the data to be loaded.

THe information loaded is not more than 10 itens. I have currently only 3 of this tables on my DataModule.

I am not using much of memory to be a memory problem. (at least what I believe)

Eduardo
eelias
 
Posts: 5
Joined: Mon 21 Jul 2014 13:39

Re: Virtual Table InsertRecord on Android

Postby AlexP » Wed 23 Jul 2014 10:20

I have received your letter, but the problem is not reproduced. Please send a small project reproducing the problem..
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35


Return to VirtualDAC