示例#1
0
void  layprop::ViewProperties::lockLayer(word layno, bool lock) {
   // No error messages here, because of possible range use
   while (wxMUTEX_NO_ERROR != DBLock.TryLock());
   if (_drawprop._layset.end() != _drawprop._layset.find(layno))
      _drawprop._layset[layno]->_locked = lock;
   DBLock.Unlock();
}
示例#2
0
bool layprop::ViewProperties::viewGrid(byte No, bool status) {
   while (wxMUTEX_NO_ERROR != DBLock.TryLock());
   if (_grid.end() != _grid.find(No)) 
      _grid[No]->turnover(status);
   else status = false;
   DBLock.Unlock();
   return status;
}
示例#3
0
void layprop::ViewProperties::setGrid(byte No, real step, std::string colname) {
   while (wxMUTEX_NO_ERROR != DBLock.TryLock());
   if (_grid.end() != _grid.find(No)) // if this grid No is already defined
      _grid[No]->Init(step,colname);
   else // define a new grid
      _grid[No] = new layprop::LayoutGrid(step, colname);
   DBLock.Unlock();
}
示例#4
0
laydata::tdtdesign*  DataCenter::lockDB(bool checkACTcell) 
{
   if (_TEDDB) 
   {
      if (checkACTcell) _TEDDB->check_active();
      while (wxMUTEX_NO_ERROR != DBLock.TryLock());
      return _TEDDB;
   }
   else throw EXPTNactive_DB();
}
示例#5
0
void DataCenter::tmp_draw(const layprop::DrawProperties& drawprop,
                              TP base, TP newp) {
   if (_TEDDB) {
//      _TEDDB->check_active();
      while (wxMUTEX_NO_ERROR != DBLock.TryLock());
      _TEDDB->tmp_draw(drawprop, base, newp);
      DBLock.Unlock();
   }
// 
//   else throw EXPTNactive_DB();      
}
示例#6
0
void DataCenter::openGL_draw(layprop::DrawProperties& drawprop) {
// Maybe we need another try/catch in the layoutcanvas ?   
   if (_TEDDB) {
//      _TEDDB->check_active();
      while (wxMUTEX_NO_ERROR != DBLock.TryLock());
      _TEDDB->openGL_draw(drawprop);
      DBLock.Unlock();
   }
// 
//   else throw EXPTNactive_DB();      
}
示例#7
0
void layprop::ViewProperties::addfill(std::string name, byte* ptrn) {
   while (wxMUTEX_NO_ERROR != DBLock.TryLock());
   if (_drawprop._layfill.end() != _drawprop._layfill.find(name)) {
      delete [] _drawprop._layfill[name];
      std::ostringstream ost;
      ost << "Warning! Fill \""<<name<<"\" redefined";
      tell_log(console::MT_WARNING, ost.str());
   }
   _drawprop._layfill[name] = ptrn;
   DBLock.Unlock();
}
示例#8
0
void layprop::ViewProperties::addcolor(std::string name, byte R, byte G, byte B, byte A) {
   while (wxMUTEX_NO_ERROR != DBLock.TryLock());
   if (_drawprop._laycolors.end() != _drawprop._laycolors.find(name)) {
      delete _drawprop._laycolors[name];
      std::ostringstream ost;
      ost << "Warning! Color \""<<name<<"\" redefined";
      tell_log(console::MT_WARNING, ost.str());
   }
   tellRGB* col = new tellRGB(R,G,B,A);
   _drawprop._laycolors[name] = col;
   DBLock.Unlock();
}
示例#9
0
//==============================================================================
void* console::parse_thread::Entry() {
//   wxLogMessage(_T("Mouse is %s (%ld, %ld)"), where.c_str(), x, y);
//   wxLogMessage(_T("Mutex try to lock..."));
   while (wxMUTEX_NO_ERROR != Mutex.TryLock());
//   wxLogMessage(_T("Mutex locked!"));
   telllloc.first_column = telllloc.first_line = 1;
   telllloc.last_column  = telllloc.last_line  = 1;
   telllloc.filename = NULL;
   void* b = tell_scan_string( command.c_str() );
   tellparse();
   my_delete_yy_buffer( b );
   Mutex.Unlock();
//   wxLogMessage(_T("Mutex unlocked"));
   return NULL;
};
示例#10
0
GDSin::GDSFile* DataCenter::lockGDS(bool throwexception) 
{
   // Carefull HERE! When GDS is locked form the main thread
   // (GDS browser), then there is no catch pending -i.e.
   // throwing an exception will make the things worse
   // When it is locked from the parser command - then exception
   // is fine 
   if (_GDSDB) 
   {
      while (wxMUTEX_NO_ERROR != GDSLock.TryLock());
      return _GDSDB;
   }
   else {
      if (throwexception) throw EXPTNactive_GDS();
      else return NULL;
   }
}
示例#11
0
wxThread::ExitCode AegisubVersionCheckerThread::Entry()
{
	if (!interactive)
	{
		// Automatic checking enabled?
		if (!OPT_GET("App/Auto/Check For Updates")->GetBool())
			return 0;

		// Is it actually time for a check?
		time_t next_check = OPT_GET("Version/Next Check")->GetInt();
		if (next_check > wxDateTime::GetTimeNow())
			return 0;
	}

	if (VersionCheckLock.TryLock() != wxMUTEX_NO_ERROR) return 0;

	try {
		DoCheck();
	}
	catch (const agi::Exception &e) {
		PostErrorEvent(wxString::Format(
			_("There was an error checking for updates to Aegisub:\n%s\n\nIf other applications can access the Internet fine, this is probably a temporary server problem on our end."),
			e.GetMessage()));
	}
	catch (...) {
		PostErrorEvent(_("An unknown error occurred while checking for updates to Aegisub."));
	}

	VersionCheckLock.Unlock();

	// While Options isn't perfectly thread safe, this should still be okay.
	// Traversing the std::map to find the key-value pair doesn't modify any data as long as
	// the key already exists (which it does at this point), and modifying the value only
	// touches that specific key-value pair and will never cause a rebalancing of the tree,
	// because the tree only depends on the keys.
	// Lastly, writing options to disk only happens when Options.Save() is called.
	time_t new_next_check_time = wxDateTime::GetTimeNow() + 60*60; // in one hour
	OPT_SET("Version/Next Check")->SetInt((int)new_next_check_time);

	return 0;
}
示例#12
0
void layprop::ViewProperties::addlayer(std::string name, word layno, std::string col,
                                                             std::string fill) {
   while (wxMUTEX_NO_ERROR != DBLock.TryLock());
   if ((col != "") && (_drawprop._laycolors.end() == _drawprop._laycolors.find(col))) {
      std::ostringstream ost;
      ost << "Warning! Color \""<<col<<"\" is not defined";
      tell_log(console::MT_WARNING,ost.str());
   }
   if ((fill != "") && (_drawprop._layfill.end() == _drawprop._layfill.find(fill))) {
      std::ostringstream ost;
      ost << "Warning! Fill \""<<fill<<"\" is not defined";
      tell_log(console::MT_WARNING, ost.str());
   }
   if (_drawprop._layset.end() != _drawprop._layset.find(layno)) {
      delete _drawprop._layset[layno];
      std::ostringstream ost;
      ost << "Warning! Layer "<<layno<<" redefined";
      tell_log(console::MT_WARNING, ost.str());
   }   
   _drawprop._layset[layno] = new LayerSettings(name,col,fill);
   DBLock.Unlock();
}
示例#13
0
void DataCenter::GDSparse(std::string filename, std::list<std::string>& topcells) 
{
   if (_GDSDB) 
   {
      std::string news = "Removing existing GDS data from memory...";
      tell_log(console::MT_WARNING,news);
      GDSclose();
   }
   while (wxMUTEX_NO_ERROR != GDSLock.TryLock());
   // parse the GDS file
   _GDSDB = new GDSin::GDSFile(filename.c_str());
   if (!_GDSDB->status()) return;
   // generate the hierarchy tree of cells
   _GDSDB->HierOut();
   // add GDS tab in the browser
   browsers::addGDStab();
   GDSin::GDSHierTree* root = _GDSDB->hierTree()->GetFirstRoot();
   do 
   {
      topcells.push_back(std::string(root->GetItem()->Get_StrName()));
   } while (NULL != (root = root->GetNextRoot()));
   unlockGDS();
}
示例#14
0
void layprop::ViewProperties::settextmarks_hidden(bool hide) {
   while (wxMUTEX_NO_ERROR != DBLock.TryLock());
      _drawprop._textmarks_hidden = hide;
   DBLock.Unlock();
}