rhomobile/rhodes — pull request #265 by ziggythehamster (2014-02-13 00:57:15+00:00)
Title: [iOS 7] Fix crash when using RhoConnect and finish_sync_in_background or checking if the RhoConnect client is syncing

This patch fixes several issues with the RhoConnect sync process on iOS 7. However, due to the fact that rhoconnect-client isn't officially open source, this patch doesn't entirely fix the problem.

The symptom is that the app crashes when backgrounded on iOS 7 if you have `finish_sync_in_background` turned on. The cause is that RhoconnectClientManager.h calls `m_pImpl->rho_sync_issyncing`. This method eventually calls `rho_sync_issyncing()`, which appears to be a C function. LLVM with Xcode 4.x resolves to the C function at build time. LLVM with Xcode 5, however, resolves to calling the C++ class method. So, the method calls itself and causes a crash. It appears that somebody saw this as a problem at some point and added `issyncing` to the class, which calls `rho_sync_issyncing()`. Of course, because this is defined as a method in the same class, LLVM calls that instead of the C function and causes the same problem.

So... the fix. This patch probably needs some editing (going to leave comments), but this patch calls issyncing from Rhodes, and correctly checks for null pointers in the C++ class and background tasks being invalid in Rhodes.m. Those last issues weren't actually causing the crash, though they could possibly crash the app. I've also changed the logging slightly to make tracing down issues a bit easier.

This doesn't fix the underlying RhoConnect problem, however. That fix is to remove the `rho_sync_issyncing` method from Classes/impl/initRhoConnectClient.cpp in the rhoconnect-cilent gem. I have no venue for sending up a patch for that, but it's 4 lines of code to change :).

- Keith Gable @ DecisionPoint (kgable@decisionpt.com)