c++ - Bada 的 AppLog 奇怪地破坏了我报告的字符串

标签 c++ macros bada

我正在改编示例 of Forms Management here并发现 AppLog 奇怪地破坏了我报告的字符串。

void
MyFormsApp::OnUserEventReceivedN (RequestId requestId, IList *pArgs)
{
    AppLog("OnUEveRxdNb, beginning");
    if(!pArgs) {
        AppLog("OnUserEventReceivedN, null List");
        return;
    }

    if(requestId==TabsForm::TABS_SWITCH_CALL)
    {
        Integer * tabindex = static_cast<Integer *>(pArgs->GetAt(0));
        MyLog(L"OnUEveRxdN, formID : ", formID->ToInt());
        //MyLog(L"OnUserEventReceivedN, formID : ", formID->ToInt());
        if(tabindex)
        {
            switch(tabindex->ToInt())
            {
            case TabsForm::SEARCH_TAB:
                frame_->SetCurrentForm(*search_form_);
                search_form_->RequestRedraw(true);
                break;
            case TabsForm::RESULTS_TAB:
                frame_->SetCurrentForm(*results_form_);
                results_form_->RequestRedraw(true);
                break;
            case TabsForm::CONTENTS_TAB:
                frame_->SetCurrentForm(*contents_form_);
                contents_form_->RequestRedraw(true);
                break;
            }
        }
    }
    pArgs->RemoveAll(true);
    delete pArgs;
} //closebracket

我的日志是

void MyLog(const String &badaStr) {
    char *natStr = new char[badaStr.GetLength()];
    for (int i = 0; i < badaStr.GetLength(); ++i)
        natStr[i] = badaStr[i];
    AppLog(natStr);
    delete[] natStr;
}

void MyLog(const mchar *pValue, const int int_param) {
    String str(pValue);
    result r = str.Append(int_param);
    MyLog(str);
}

void MyLog(const char *pValue, const int int_param) {
    String str(pValue);
    result r = str.Append(int_param);
    MyLog(str);
}

如果您看到我在哪里调用了它的两个调用,则第二个被注释掉了,因为它将垃圾附加到我的字符串的末尾。我从我的应用程序中的其他不同地方调用这些函数没有问题,但这里的字符串必须被截断。这不是每个函数的总 char 计数,因为将第一个 AppLog 替换为 AppLog("BadaReader::OnUserEventReceivedN, beginning"); 不会区别。

谁能发现我的错误,或者 Bada 2.0.2 是否以这种随机故障而闻名?

最佳答案

为什么需要单独的日志记录功能? bada 有三个 AppLog Macros.Yoc 可以使用它们。 另外,如果你需要打印 String,

AppLog("Log Statement %s",string_name->GetPointer());

string_name->GetPointer() 返回 const char*。

关于c++ - Bada 的 AppLog 奇怪地破坏了我报告的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8315906/

相关文章:

macros - 如何在Sun Studio下打印预处理器宏?

C:在宏中隐藏 if 语句的最佳方法

c++ - 在 bada 中使用 cout

c++ - 巴达 C++ std::stringstream

ios - iOS中宏的误区

android - bada中是否有类似于android中的 "Context"的类?

c++ - 用长字符串中的另一个子字符串替换所有出现的子字符串

c# - 创建一个虚拟 HWND 以传递给 Direct3D

c++ - 如何在ubuntu上安装cinder C++

c++ - pcre2_substitute() 函数支持多少捕获组?