BOOL CMainFrame::DestroyWindow() { StopThreads(); PMainframe()->KillTimers(); // Save window position WINDOWPLACEMENT wp; GetWindowPlacement(&wp); Preferences()->SetValue(k_prefs_main_x, wp.rcNormalPosition.left); Preferences()->SetValue(k_prefs_main_y, wp.rcNormalPosition.top); write_log(Preferences()->debug_gui(), "[GUI] Going to delete the GUI\n"); write_log(Preferences()->debug_gui(), "[GUI] this = [%i]\n", this); // All OK here assert(AfxCheckMemory()); // http://www.maxinmontreal.com/forums/viewtopic.php?f=111&t=20459 // probably caused by incorrect order of deletion, // caused by incorrect position of StopThreads and KillTimers. bool success = CFrameWnd::DestroyWindow(); write_log(Preferences()->debug_gui(), "[GUI] Window deleted\n"); return success; }
VOID CALLBACK CUploadQueue::UploadTimer(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR /*idEvent*/, DWORD /*dwTime*/) { // NOTE: Always handle all type of MFC exceptions in TimerProcs - otherwise we'll get mem leaks try { // Barry - Don't do anything if the app is shutting down - can cause unhandled exceptions if (!theApp.emuledlg->IsRunning()) return; // Elandal:ThreadSafeLogging --> // other threads may have queued up log lines. This prints them. theApp.HandleDebugLogQueue(); theApp.HandleLogQueue(); // Elandal: ThreadSafeLogging <-- // ZZ:UploadSpeedSense --> theApp.lastCommonRouteFinder->SetPrefs(thePrefs.IsDynUpEnabled(), theApp.uploadqueue->GetDatarate(), thePrefs.GetMinUpload()*1024, (thePrefs.GetMaxUpload() != 0) ? thePrefs.GetMaxUpload() * 1024 : thePrefs.GetMaxGraphUploadRate(false) * 1024, thePrefs.IsDynUpUseMillisecondPingTolerance(), (thePrefs.GetDynUpPingTolerance() > 100) ? ((thePrefs.GetDynUpPingTolerance() - 100) / 100.0f) : 0, thePrefs.GetDynUpPingToleranceMilliseconds(), thePrefs.GetDynUpGoingUpDivider(), thePrefs.GetDynUpGoingDownDivider(), thePrefs.GetDynUpNumberOfPings(), 20); // PENDING: Hard coded min pLowestPingAllowed // ZZ:UploadSpeedSense <-- theApp.uploadqueue->Process(); theApp.downloadqueue->Process(); if (thePrefs.ShowOverhead()){ theStats.CompUpDatarateOverhead(); theStats.CompDownDatarateOverhead(); } counter++; // one second if (counter >= 10){ counter=0; // try to use different time intervals here to not create any disk-IO bottle necks by saving all files at once theApp.clientcredits->Process(); // 13 minutes theApp.serverlist->Process(); // 17 minutes theApp.knownfiles->Process(); // 11 minutes theApp.friendlist->Process(); // 19 minutes theApp.clientlist->Process(); theApp.sharedfiles->Process(); if( Kademlia::CKademlia::IsRunning() ) { Kademlia::CKademlia::Process(); if(Kademlia::CKademlia::GetPrefs()->HasLostConnection()) { Kademlia::CKademlia::Stop(); theApp.emuledlg->ShowConnectionState(); } } if( theApp.serverconnect->IsConnecting() && !theApp.serverconnect->IsSingleConnect() ) theApp.serverconnect->TryAnotherConnectionRequest(); theApp.listensocket->UpdateConnectionsStatus(); if (thePrefs.WatchClipboard4ED2KLinks()) { // TODO: Remove this from here. This has to be done with a clipboard chain // and *not* with a timer!! theApp.SearchClipboard(); } if (theApp.serverconnect->IsConnecting()) theApp.serverconnect->CheckForTimeout(); // -khaos--+++> Update connection stats... iupdateconnstats++; // 2 seconds if (iupdateconnstats>=2) { iupdateconnstats=0; theStats.UpdateConnectionStats((float)theApp.uploadqueue->GetDatarate()/1024, (float)theApp.downloadqueue->GetDatarate()/1024); } // <-----khaos- // display graphs if (thePrefs.GetTrafficOMeterInterval()>0) { igraph++; if (igraph >= (uint32)(thePrefs.GetTrafficOMeterInterval()) ) { igraph=0; //theApp.emuledlg->statisticswnd->SetCurrentRate((float)(theApp.uploadqueue->Getavgupload()/theApp.uploadqueue->Getavg())/1024,(float)(theApp.uploadqueue->Getavgdownload()/theApp.uploadqueue->Getavg())/1024); theApp.emuledlg->statisticswnd->SetCurrentRate((float)(theApp.uploadqueue->GetDatarate())/1024,(float)(theApp.downloadqueue->GetDatarate())/1024); //theApp.uploadqueue->Zeroavg(); } } if (theApp.emuledlg->activewnd == theApp.emuledlg->statisticswnd && theApp.emuledlg->IsWindowVisible() ) { // display stats if (thePrefs.GetStatsInterval()>0) { istats++; if (istats >= (uint32)(thePrefs.GetStatsInterval()) ) { istats=0; theApp.emuledlg->statisticswnd->ShowStatistics(); } } } theApp.uploadqueue->UpdateDatarates(); //save rates every second theStats.RecordRate(); // mobilemule sockets #ifdef MobileMule theApp.mmserver->Process(); #endif // ZZ:UploadSpeedSense --> theApp.emuledlg->ShowPing(); bool gotEnoughHosts = theApp.clientlist->GiveClientsForTraceRoute(); if(gotEnoughHosts == false) { theApp.serverlist->GiveServersForTraceRoute(); } // ZZ:UploadSpeedSense <-- if (theApp.emuledlg->IsTrayIconToFlash()) theApp.emuledlg->ShowTransferRate(true); sec++; // *** 5 seconds ********************************************** if (sec >= 5) { #ifdef _DEBUG if (thePrefs.m_iDbgHeap > 0 && !AfxCheckMemory()) AfxDebugBreak(); #endif sec = 0; theApp.listensocket->Process(); theApp.OnlineSig(); // Added By Bouc7 if (!theApp.emuledlg->IsTrayIconToFlash()) theApp.emuledlg->ShowTransferRate(); thePrefs.EstimateMaxUploadCap(theApp.uploadqueue->GetDatarate()/1024); if (!thePrefs.TransferFullChunks()) theApp.uploadqueue->UpdateMaxClientScore(); // update cat-titles with downloadinfos only when needed if (thePrefs.ShowCatTabInfos() && theApp.emuledlg->activewnd == theApp.emuledlg->transferwnd && theApp.emuledlg->IsWindowVisible()) theApp.emuledlg->transferwnd->UpdateCatTabTitles(false); #ifdef Scheduler if (thePrefs.IsSchedulerEnabled()) theApp.scheduler->Check(); #endif theApp.emuledlg->transferwnd->UpdateListCount(CTransferWnd::wnd2Uploading, -1); } statsave++; // *** 60 seconds ********************************************* if (statsave >= 60) { statsave=0; if (thePrefs.GetWSIsEnabled()) theApp.webserver->UpdateSessionCount(); theApp.serverconnect->KeepConnectionAlive(); if (thePrefs.GetPreventStandby()) theApp.ResetStandByIdleTimer(); // Reset Windows idle standby timer if necessary } s_uSaveStatistics++; if (s_uSaveStatistics >= thePrefs.GetStatsSaveInterval()) { s_uSaveStatistics = 0; thePrefs.SaveStats(); } } // need more accuracy here. don't rely on the 'sec' and 'statsave' helpers. thePerfLog.LogSamples(); } CATCH_DFLT_EXCEPTIONS(_T("CUploadQueue::UploadTimer")) }