Skip to content

Commit

Permalink
chore(rime_api): fix compile error with older boost libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Aug 17, 2020
1 parent dbb35c6 commit 4b84dbf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/rime_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -785,27 +785,27 @@ RIME_API Bool RimeRunTask(const char* task_name) {

RIME_API const char* RimeGetSharedDataDir() {
Deployer &deployer(Service::instance().deployer());
return deployer.shared_data_dir.c_str();
return deployer.shared_data_dir.string().c_str();
}

RIME_API const char* RimeGetUserDataDir() {
Deployer &deployer(Service::instance().deployer());
return deployer.user_data_dir.c_str();
return deployer.user_data_dir.string().c_str();
}

RIME_API const char* RimeGetPrebuiltDataDir() {
Deployer &deployer(Service::instance().deployer());
return deployer.prebuilt_data_dir.c_str();
return deployer.prebuilt_data_dir.string().c_str();
}

RIME_API const char* RimeGetStagingDir() {
Deployer &deployer(Service::instance().deployer());
return deployer.staging_dir.c_str();
return deployer.staging_dir.string().c_str();
}

RIME_API const char* RimeGetSyncDir() {
Deployer &deployer(Service::instance().deployer());
return deployer.sync_dir.c_str();
return deployer.sync_dir.string().c_str();
}

RIME_API const char* RimeGetUserId() {
Expand Down

4 comments on commit 4b84dbf

@hchunhui
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, the fix may be incorrect. The string object will be destroyed, so the result of c_str() is invalid.
See hchunhui/librime-lua#67 (comment)

@lotem
Copy link
Member Author

@lotem lotem commented on 4b84dbf Sep 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to fix it then?

@hchunhui
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure. To keep the function signature, maybe the deployer has to hold a extra string buffer.

@lotem
Copy link
Member Author

@lotem lotem commented on 4b84dbf Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 78abaa8
I changed the paths back to strings so that c_str()s last longer. Just cost some more convertions.

Please sign in to comment.