- fixed CPU usage on windows for map editor

This commit is contained in:
Mark Vejvoda 2010-07-01 16:31:06 +00:00
parent c85b8baa49
commit 75c50f1052
2 changed files with 16 additions and 4 deletions

View File

@ -54,7 +54,8 @@ MainWindow::MainWindow()
, enabledGroup(ctHeight)
, fileModified(false)
, menuBar(NULL)
, panel(NULL) {
, panel(NULL)
, timer(NULL) {
this->panel = new wxPanel(this, wxID_ANY);
@ -302,9 +303,11 @@ MainWindow::MainWindow()
//std::cout << "C" << std::endl;
SetIcon(icon);
lastPaintEvent.start();
//#ifndef WIN32
timer = new wxTimer(this);
timer->Start(250);
//timer = new wxTimer(this);
//timer->Start(250);
//#endif
glCanvas->SetFocus();
}
@ -342,8 +345,8 @@ MainWindow::~MainWindow() {
if(timer != NULL) delete timer;
timer = NULL;
delete program;
delete glCanvas;
delete program;
}
void MainWindow::setDirty(bool val) {
@ -430,6 +433,12 @@ void MainWindow::onMouseMove(wxMouseEvent &event, int x, int y) {
}
void MainWindow::onPaint(wxPaintEvent &event) {
if(lastPaintEvent.getMillis() < 100) {
sleep(5);
return;
}
lastPaintEvent.start();
if(panel) panel->Update();
if(menuBar) menuBar->Update();

View File

@ -20,10 +20,12 @@
#include "program.h"
#include "util.h"
#include "platform_common.h"
using std::string;
using std::vector;
using std::pair;
using namespace Shared::PlatformCommon;
namespace MapEditor {
@ -165,6 +167,7 @@ private:
string fileName;
bool fileModified;
Chrono lastPaintEvent;
public:
MainWindow();