Giter Club home page Giter Club logo

Comments (6)

jonsimantov avatar jonsimantov commented on May 28, 2024

Thanks for posting! I'll investigate whether this is a valid use case for MutableData and will post again shortly.

from quickstart-cpp.

jonsimantov avatar jonsimantov commented on May 28, 2024

Just to be sure, could you paste your call stack (if you get one)?

I don't believe you can create new MutableData instances on the stack or heap, even within a transaction handler. Copying MutableData instances is also not allowed (although I believe we should add a move constructor and move operator, which will help you with your example).

As a workaround, use mutable_data->Child("xxsdd") to access the MutableData at the child path. If you modify a child's data, it will be visible to the parent. If you need to set a vector or map of data, use Variant's vector and map capabilities.

So for example, if you wanted to create a vector child inside a transaction handler with mutable_data as the parameter:

firebase::Variant vect = firebase::Variant::EmptyVector();
vect.vector()->push_back("aaaa");
mutable_data->Child("xxsdd").set_data(vect);

This will set the transaction data's "xxsdd" child to a vector, with the 0th entry of that vectr being "aaaa".

There are other (but similar) ways to use Variant to accomplish this and other tasks; see the firebase::Variant documentation for more information.

You could also get the MutableData contents as a Variant and play around with it like that:

firebase::Variant data = mutable_data->value();
/* change data as needed */
mutable_data->set_value(data);

Hope this helps! I'll leave this issue open until we add that move constructor/operator.

from quickstart-cpp.

feixuwu avatar feixuwu commented on May 28, 2024

thanks for your reply,
I'm try to create a firebase plugin for unreal engine 4, both c++ and blueprint,
After several days struggle for this problem,
I guess the MutableData can not copy,

here is my test code,
I create a class to wrapper the MutableData, so I need to use a member to hold the MutableData, and here is the wrapper Child function:

std::string strPath = TCHAR_TO_UTF8(*path);
firebase::database::MutableData result = mMutableData->Child(strPath);

UFirebaseMutableData* ret = NewObject();
ret->mMutableData = TSharedPtrfirebase::database::MutableData(new firebase::database::MutableData(result) );

because the MutableData did not private it's copy constructor function, so I can copy.
the crash call stack:

10-04 08:31:16.400 32591-32591/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-04 08:31:16.403 32591-32591/? A/DEBUG: Build fingerprint: 'Xiaomi/capricorn/capricorn:7.0/NRD90M/7.9.21:user/release-keys'
10-04 08:31:16.403 32591-32591/? A/DEBUG: Revision: '0'
10-04 08:31:16.403 32591-32591/? A/DEBUG: ABI: 'arm'
10-04 08:31:16.404 32591-32591/? A/DEBUG: pid: 32267, tid: 32590, name: FirebaseDatabas >>> com.google.firebase.quickstart.auth <<<
10-04 08:31:16.404 32591-32591/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x10
10-04 08:31:16.404 32591-32591/? A/DEBUG: r0 c2f57000 r1 c19a42a4 r2 00000000 r3 00000000
10-04 08:31:16.404 32591-32591/? A/DEBUG: r4 c2f57000 r5 c19a42c8 r6 c2f5f960 r7 c4dc2170
10-04 08:31:16.404 32591-32591/? A/DEBUG: r8 c19a4750 r9 c4dc2170 sl 00000000 fp c19a4318
10-04 08:31:16.404 32591-32591/? A/DEBUG: ip d1c88180 sp c19a4298 lr d0fc1e63 pc d0fc1e1e cpsr 400d0030
10-04 08:31:16.425 32591-32591/? W/debuggerd: type=1400 audit(0.0:10087): avc: denied { search } for name="com.google.firebase.quickstart.auth" dev="dm-1" ino=2221450 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
10-04 08:31:16.435 32591-32591/? A/DEBUG: backtrace:
10-04 08:31:16.435 32591-32591/? A/DEBUG: #00 pc 06644e1e /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN8firebase4util19AttachCurrentThreadEP7_JavaVMPP7_JNIEnv+5)
10-04 08:31:16.435 32591-32591/? A/DEBUG: #1 pc 06644e5f /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN8firebase4util19GetThreadsafeJNIEnvEP7_JavaVM+38)
10-04 08:31:16.435 32591-32591/? A/DEBUG: #2 pc 0663fb21 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZNK8firebase3App9GetJNIEnvEv+4)
10-04 08:31:16.435 32591-32591/? A/DEBUG: #3 pc 0664d721 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN8firebase8database8internal19MutableDataInternal8SetValueENS_7VariantE+12)
10-04 08:31:16.435 32591-32591/? A/DEBUG: #4 pc 06648225 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN8firebase8database11MutableData9set_valueENS_7VariantE+18)
10-04 08:31:16.436 32591-32591/? A/DEBUG: #5 pc 055a70e4 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN20UFirebaseMutableData9set_valueEP16UFirebaseVariant+72)
10-04 08:31:16.436 32591-32591/? A/DEBUG: #6 pc 055b79c8 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN20UFirebaseMutableData13execset_valueER6FFramePv+108)
10-04 08:31:16.436 32591-32591/? A/DEBUG: #7 pc 023d6230 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN9UFunction6InvokeEP7UObjectR6FFramePv+124)
10-04 08:31:16.436 32591-32591/? A/DEBUG: #8 pc 02543e34 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN7UObject12CallFunctionER6FFramePvP9UFunction+8896)
10-04 08:31:16.436 32591-32591/? A/DEBUG: #9 pc 0254f31c /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN7UObject20ProcessContextOpcodeER6FFramePvb+416)
10-04 08:31:16.437 32591-32591/? A/DEBUG: #10 pc 02545128 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN7UObject15ProcessInternalER6FFramePv+3564)
10-04 08:31:16.437 32591-32591/? A/DEBUG: #11 pc 023d6230 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN9UFunction6InvokeEP7UObjectR6FFramePv+124)
10-04 08:31:16.437 32591-32591/? A/DEBUG: #12 pc 02548df4 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN7UObject12ProcessEventEP9UFunctionPv+5360)
10-04 08:31:16.437 32591-32591/? A/DEBUG: #13 pc 055af2e0 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so
10-04 08:31:16.437 32591-32591/? A/DEBUG: #14 pc 0664f141 /data/app/com.google.firebase.quickstart.auth-1/lib/arm/libUE4.so (_ZN8firebase8database8internal9Callbacks31TransactionHandlerDoTransactionEP7_JNIEnvP7_jclassxxP8_jobject+54)
10-04 08:31:16.437 32591-32591/? A/DEBUG: #15 pc 000008f1 /data/data/com.google.firebase.quickstart.auth/code_cache/database_resources_lib.dex (offset 0x3000)

from quickstart-cpp.

feixuwu avatar feixuwu commented on May 28, 2024

By the way, because the firebase c++ windows lib is build with single thread static,
so with my project, windows will link error(I know it will not work on desktop),
I need to use a lot of #ifdef to make the code both compile on desktop and android.
if can add the MDD and MD version will be perfect.

from quickstart-cpp.

WanMhdrosuwan avatar WanMhdrosuwan commented on May 28, 2024

it's ok

from quickstart-cpp.

johnb003 avatar johnb003 commented on May 28, 2024

We have fixed both the crash and the windows linkage issues in Firebase C++ 4.4.2.
https://firebase.google.com/support/release-notes/cpp-relnotes#4.4.2

from quickstart-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.