Skip to content

Commit

Permalink
fixed infinite while loop error calling RunCallBacks() that randomly …
Browse files Browse the repository at this point in the history
…occurs
  • Loading branch information
XFG16 committed Jun 4, 2022
1 parent 0b3eb47 commit beb78cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Host/YTDPwin/YTDPsetup/YTDPsetup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:YouTubeDiscordPresence"
"ProductCode" = "8:{D585A93C-0437-4EED-9287-41071EA51DC4}"
"PackageCode" = "8:{1188F4BB-4B5E-439F-B933-F7A166AFA346}"
"ProductCode" = "8:{E61CE5BB-4017-4332-81C6-1590C97063A6}"
"PackageCode" = "8:{55A66A44-E42A-4C37-AE4D-10A9659BB55E}"
"UpgradeCode" = "8:{E382DBD1-8EDE-47B6-A376-403178519F67}"
"AspNetVersion" = "8:"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.1.0"
"ProductVersion" = "8:1.2.0"
"Manufacturer" = "8:Michael Ren"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:https://github.com/XFG16/YouTubeDiscordPresence"
Expand Down
17 changes: 9 additions & 8 deletions Host/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ void updatePresence(const std::string& title, const std::string& author, const s
return;
}
else if (!core) {
if (title == IDLE_IDENTIFIER) {
return;
}
bool didCreatePresence = createPresence();
if (!didCreatePresence || title == IDLE_IDENTIFIER) {
if (!didCreatePresence) {
destroyPresence();
return;
}
Expand Down Expand Up @@ -122,17 +125,15 @@ void updatePresence(const std::string& title, const std::string& author, const s
previousTitle = title;
previousAuthor = author;

bool presenceUpdated = false, updatedOnce = false;
bool presenceUpdated = false;
core->ActivityManager().UpdateActivity(activity, [&presenceUpdated](discord::Result result) {
presenceUpdated = true;
});
while (!presenceUpdated) {
updatedOnce = true;
core->RunCallbacks();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
if (!updatedOnce) {
int numUpdates = 0;
while (numUpdates < 4 || (numUpdates < 10 && !presenceUpdated)) {
core->RunCallbacks();
std::this_thread::sleep_for(std::chrono::milliseconds(50));
++numUpdates;
}
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- On a more **technical note**, it works similar to the **Spotify rich presence**—it only appears **when a video is playing** and **disappears when there is no video or the video is paused**. In addition, it only displays the presence for videos. Idling and searching are **not displayed**.
- There are **two** components:
- Chrome Extension ( Source code [v1.2]: `Extension` | Release [v1.1]: [<ins>**Chrome Web Store**</ins>](https://chrome.google.com/webstore/detail/youtubediscordpresence/hnmeidgkfcbpjjjpmjmpehjdljlaeaaa) )
- Desktop Application ( Source code [v1.1]: `Host` | Release [v1.1]: [**<ins>Releases</ins>**](https://github.com/XFG16/YouTubeDiscordPresence/releases/tag/1.1) )
- Desktop Application ( Source code [v1.2]: `Host` | Release [v1.2]: [**<ins>Releases</ins>**](https://github.com/XFG16/YouTubeDiscordPresence/releases/tag/1.2) )
- If Discord is closed **while the extension is running**, just switch the extension **off and back on**, and the presence should **reappear** on your profile

## Known Issues
Expand Down

0 comments on commit beb78cd

Please sign in to comment.