GUI: fix division by zero when disabling frame rat
e limit
This commit is contained in:
		
							parent
							
								
									a793f286c5
								
							
						
					
					
						commit
						03952b7564
					
				| 
						 | 
					@ -6468,19 +6468,20 @@ bool FurnaceGUI::loop() {
 | 
				
			||||||
    drawTimeEnd=SDL_GetPerformanceCounter();
 | 
					    drawTimeEnd=SDL_GetPerformanceCounter();
 | 
				
			||||||
    swapTimeBegin=SDL_GetPerformanceCounter();
 | 
					    swapTimeBegin=SDL_GetPerformanceCounter();
 | 
				
			||||||
    if (!settings.vsync || !rend->canVSync()) {
 | 
					    if (!settings.vsync || !rend->canVSync()) {
 | 
				
			||||||
      unsigned int presentDelay=SDL_GetPerformanceFrequency()/settings.frameRateLimit;
 | 
					      if (settings.frameRateLimit>0) {
 | 
				
			||||||
      if ((nextPresentTime-swapTimeBegin)<presentDelay) {
 | 
					        unsigned int presentDelay=SDL_GetPerformanceFrequency()/settings.frameRateLimit;
 | 
				
			||||||
 | 
					        if ((nextPresentTime-swapTimeBegin)<presentDelay) {
 | 
				
			||||||
#ifdef _WIN32
 | 
					#ifdef _WIN32
 | 
				
			||||||
        unsigned int mDivider=SDL_GetPerformanceFrequency()/1000;
 | 
					          unsigned int mDivider=SDL_GetPerformanceFrequency()/1000;
 | 
				
			||||||
        Sleep((unsigned int)(nextPresentTime-swapTimeBegin)/mDivider);
 | 
					          Sleep((unsigned int)(nextPresentTime-swapTimeBegin)/mDivider);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
        unsigned int mDivider=SDL_GetPerformanceFrequency()/1000000;
 | 
					          unsigned int mDivider=SDL_GetPerformanceFrequency()/1000000;
 | 
				
			||||||
        usleep((unsigned int)(nextPresentTime-swapTimeBegin)/mDivider);
 | 
					          usleep((unsigned int)(nextPresentTime-swapTimeBegin)/mDivider);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					          nextPresentTime+=presentDelay;
 | 
				
			||||||
        nextPresentTime+=presentDelay;
 | 
					        } else {
 | 
				
			||||||
      } else {
 | 
					          nextPresentTime=swapTimeBegin+presentDelay;
 | 
				
			||||||
        nextPresentTime=swapTimeBegin+presentDelay;
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    rend->present();
 | 
					    rend->present();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue