1
0

3 Коммиты b54cd0a3d8 ... 4208508486

Автор SHA1 Сообщение Дата
  kiwec 4208508486 Fix double free when closing McOsu 1 месяц назад
  kiwec 3e87701a4b Hide cursor when it should be hidden 1 месяц назад
  kiwec 0b3cb688e8 Fix crash 1 месяц назад

+ 1 - 1
src/App/Osu/Downloader.cpp

@@ -213,8 +213,8 @@ void download(const char* url, float* progress, std::vector<uint8_t>& out, int*
     pthread_mutex_unlock(&threads_mtx);
 
 end:
+    curl_free(hostname);
     curl_url_cleanup(urlu);
-    free(hostname);
 }
 
 void download_beatmapset(uint32_t set_id, float* progress) {

+ 3 - 10
src/App/Osu/Osu.cpp

@@ -987,10 +987,6 @@ void Osu::update() {
         }
     }
 
-    // it's a bit of a hack, because using cursor visibility to work around SetCursorPos() affecting the windows cursor
-    // in the Mouse class
-    if(!env->isCursorVisible()) env->setCursorVisible(true);
-
     // endless mod
     if(m_bScheduleEndlessModNextBeatmap) {
         m_bScheduleEndlessModNextBeatmap = false;
@@ -1155,11 +1151,8 @@ void Osu::updateMods() {
     if(m_bModAutopilot) m_bModAuto = false;
 
     // handle auto/pilot cursor visibility
-    if(!m_bModAuto && !m_bModAutopilot) {
-        m_bShouldCursorBeVisible = false;
-        env->setCursorVisible(m_bShouldCursorBeVisible);
-    } else if(isInPlayMode()) {
-        m_bShouldCursorBeVisible = true;
+    if(isInPlayMode()) {
+        m_bShouldCursorBeVisible = m_bModAuto || m_bModAutopilot || getSelectedBeatmap()->m_bIsWatchingReplay;
         env->setCursorVisible(m_bShouldCursorBeVisible);
     }
 
@@ -1650,7 +1643,7 @@ void Osu::onPlayStart() {
 
     m_snd_change_check_interval_ref->setValue(0.0f);
 
-    if(m_bModAuto || m_bModAutopilot) {
+    if(m_bModAuto || m_bModAutopilot || getSelectedBeatmap()->m_bIsWatchingReplay) {
         m_bShouldCursorBeVisible = true;
         env->setCursorVisible(m_bShouldCursorBeVisible);
     }

+ 5 - 12
src/App/Osu/OsuBeatmap.cpp

@@ -730,13 +730,11 @@ bool OsuBeatmap::watch(Score score, double start_percent) {
     m_bIsWatchingReplay = true;  // play() resets this to false
     spectated_replay = score.replay;
 
-    env->setCursorVisible(true);
-
     m_osu->m_songBrowser2->m_bHasSelectedAndIsPlaying = true;
     m_osu->m_songBrowser2->setVisible(false);
 
-    m_bIsWaiting = true;  // ensure onPlayStart() will be called by seekPercent()
     seekPercent(start_percent);
+    m_osu->onPlayStart();
 
     return true;
 }
@@ -1112,7 +1110,8 @@ void OsuBeatmap::seekPercent(double percent) {
 
         engine->getSound()->play(m_music);
 
-        onPlayStart();
+        // if there are calculations in there that need the hitobjects to be loaded, also applies speed/pitch
+        onModUpdate(false, false);
     }
 
     if(!m_bIsWatchingReplay) {  // score submission already disabled when watching replay
@@ -2376,7 +2375,8 @@ void OsuBeatmap::update2() {
 
                     m_bIsRestartScheduledQuick = false;
 
-                    onPlayStart();
+                    // if there are calculations in there that need the hitobjects to be loaded, also applies speed/pitch
+                    onModUpdate(false, false);
                 }
             } else
                 m_iCurMusicPos = (engine->getTimeReal() - m_fWaitTime) * 1000.0f * m_osu->getSpeedMultiplier();
@@ -3419,13 +3419,6 @@ Vector2 OsuBeatmap::getFirstPersonCursorDelta() const {
 
 float OsuBeatmap::getHitcircleDiameter() const { return m_fHitcircleDiameter; }
 
-void OsuBeatmap::onPlayStart() {
-    debugLog("OsuBeatmap::onPlayStart()\n");
-
-    // if there are calculations in there that need the hitobjects to be loaded, also applies speed/pitch
-    onModUpdate(false, false);
-}
-
 void OsuBeatmap::saveAndSubmitScore(bool quit) {
     // calculate stars
     double aim = 0.0;

+ 0 - 1
src/App/Osu/OsuBeatmap.h

@@ -407,7 +407,6 @@ class OsuBeatmap {
         }
     }
 
-    void onPlayStart();
     void saveAndSubmitScore(bool quit);
     void onPaused(bool first);
 

+ 1 - 48
src/App/Osu/OsuSongBrowser.cpp

@@ -636,54 +636,7 @@ OsuSongBrowser::~OsuSongBrowser() {
     engine->getResourceManager()->destroyResource(m_dynamicStarCalculator);
     engine->getResourceManager()->destroyResource(m_backgroundSearchMatcher);
 
-    m_songBrowser->getContainer()->empty();
-
-    for(size_t i = 0; i < m_songButtons.size(); i++) {
-        delete m_songButtons[i];
-    }
-    for(size_t i = 0; i < m_collectionButtons.size(); i++) {
-        delete m_collectionButtons[i];
-    }
-    for(size_t i = 0; i < m_artistCollectionButtons.size(); i++) {
-        delete m_artistCollectionButtons[i];
-    }
-    for(size_t i = 0; i < m_difficultyCollectionButtons.size(); i++) {
-        delete m_difficultyCollectionButtons[i];
-    }
-    for(size_t i = 0; i < m_bpmCollectionButtons.size(); i++) {
-        delete m_bpmCollectionButtons[i];
-    }
-    for(size_t i = 0; i < m_creatorCollectionButtons.size(); i++) {
-        delete m_creatorCollectionButtons[i];
-    }
-    for(size_t i = 0; i < m_dateaddedCollectionButtons.size(); i++) {
-        delete m_dateaddedCollectionButtons[i];
-    }
-    for(size_t i = 0; i < m_lengthCollectionButtons.size(); i++) {
-        delete m_lengthCollectionButtons[i];
-    }
-    for(size_t i = 0; i < m_titleCollectionButtons.size(); i++) {
-        delete m_titleCollectionButtons[i];
-    }
-
-    m_scoreBrowser->getContainer()->empty();
-    for(size_t i = 0; i < m_scoreButtonCache.size(); i++) {
-        delete m_scoreButtonCache[i];
-    }
-    SAFE_DELETE(m_scoreBrowserScoresStillLoadingElement);
-    SAFE_DELETE(m_scoreBrowserNoRecordsYetElement);
-
-    for(size_t i = 0; i < m_sortingMethods.size(); i++) {
-        delete m_sortingMethods[i].comparator;
-    }
-
-    SAFE_DELETE(m_search);
-    SAFE_DELETE(m_topbarLeft);
-    SAFE_DELETE(m_topbarRight);
-    SAFE_DELETE(m_bottombar);
-    SAFE_DELETE(m_scoreBrowser);
-    SAFE_DELETE(m_songBrowser);
-    SAFE_DELETE(m_db);
+    // leak memory, who cares we're closing mcosu anyway
 }
 
 void OsuSongBrowser::draw(Graphics *g) {