mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
Changed from a critical section to a mutex for error handling.
show_pending_errors() was being called over and over again from the GUI update system - somehow it managed to have a single thread in two places at once. Also tried recursive mutex, resulted in infinite dialogs until an out-of-memory crash. Also, minor conversion fix. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@998 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -28,7 +28,7 @@ ScriptValueP ScriptValue::next() { throw Intern
|
|||||||
ScriptValueP ScriptValue::makeIterator(const ScriptValueP&) const { return delayError(_ERROR_2_("can't convert", typeName(), _TYPE_("collection"))); }
|
ScriptValueP ScriptValue::makeIterator(const ScriptValueP&) const { return delayError(_ERROR_2_("can't convert", typeName(), _TYPE_("collection"))); }
|
||||||
int ScriptValue::itemCount() const { throw ScriptError(_ERROR_2_("can't convert", typeName(), _TYPE_("collection"))); }
|
int ScriptValue::itemCount() const { throw ScriptError(_ERROR_2_("can't convert", typeName(), _TYPE_("collection"))); }
|
||||||
CompareWhat ScriptValue::compareAs(String& compare_str, void const*& compare_ptr) const {
|
CompareWhat ScriptValue::compareAs(String& compare_str, void const*& compare_ptr) const {
|
||||||
compare_str = (String)(*this);
|
compare_str = toString();
|
||||||
return COMPARE_AS_STRING;
|
return COMPARE_AS_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -61,7 +61,7 @@ vector<String> previous_warnings;
|
|||||||
String pending_errors;
|
String pending_errors;
|
||||||
String pending_warnings;
|
String pending_warnings;
|
||||||
DECLARE_TYPEOF_COLLECTION(String);
|
DECLARE_TYPEOF_COLLECTION(String);
|
||||||
wxCriticalSection crit_error_handling;
|
wxMutex crit_error_handling;
|
||||||
|
|
||||||
void show_pending_errors();
|
void show_pending_errors();
|
||||||
void show_pending_warnings();
|
void show_pending_warnings();
|
||||||
@@ -69,7 +69,7 @@ void show_pending_warnings();
|
|||||||
void handle_error(const String& e, bool allow_duplicate = true, bool now = true) {
|
void handle_error(const String& e, bool allow_duplicate = true, bool now = true) {
|
||||||
{
|
{
|
||||||
// Thread safety
|
// Thread safety
|
||||||
wxCriticalSectionLocker lock(crit_error_handling);
|
wxMutexLocker lock(crit_error_handling);
|
||||||
// Check duplicates
|
// Check duplicates
|
||||||
if (!allow_duplicate) {
|
if (!allow_duplicate) {
|
||||||
FOR_EACH(pe, previous_errors) {
|
FOR_EACH(pe, previous_errors) {
|
||||||
@@ -95,7 +95,7 @@ void handle_error(const Error& e, bool allow_duplicate, bool now) {
|
|||||||
void handle_warning(const String& w, bool now) {
|
void handle_warning(const String& w, bool now) {
|
||||||
{
|
{
|
||||||
// Check duplicates
|
// Check duplicates
|
||||||
wxCriticalSectionLocker lock(crit_error_handling);
|
wxMutexLocker lock(crit_error_handling);
|
||||||
// Check duplicates
|
// Check duplicates
|
||||||
FOR_EACH(pw, previous_warnings) {
|
FOR_EACH(pw, previous_warnings) {
|
||||||
if (w == pw) return;
|
if (w == pw) return;
|
||||||
@@ -119,17 +119,21 @@ void handle_pending_errors() {
|
|||||||
|
|
||||||
void show_pending_errors() {
|
void show_pending_errors() {
|
||||||
assert(wxThread::IsMain());
|
assert(wxThread::IsMain());
|
||||||
wxCriticalSectionLocker lock(crit_error_handling);
|
if (crit_error_handling.TryLock() != wxMUTEX_NO_ERROR)
|
||||||
|
return;
|
||||||
if (!pending_errors.empty()) {
|
if (!pending_errors.empty()) {
|
||||||
wxMessageBox(pending_errors, _("Error"), wxOK | wxICON_ERROR);
|
wxMessageBox(pending_errors, _("Error"), wxOK | wxICON_ERROR);
|
||||||
pending_errors.clear();
|
pending_errors.clear();
|
||||||
}
|
}
|
||||||
|
crit_error_handling.Unlock();
|
||||||
}
|
}
|
||||||
void show_pending_warnings() {
|
void show_pending_warnings() {
|
||||||
assert(wxThread::IsMain());
|
assert(wxThread::IsMain());
|
||||||
wxCriticalSectionLocker lock(crit_error_handling);
|
if (crit_error_handling.TryLock() != wxMUTEX_NO_ERROR)
|
||||||
|
return;
|
||||||
if (!pending_warnings.empty()) {
|
if (!pending_warnings.empty()) {
|
||||||
wxMessageBox(pending_warnings, _("Warning"), wxOK | wxICON_EXCLAMATION);
|
wxMessageBox(pending_warnings, _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||||
pending_warnings.clear();
|
pending_warnings.clear();
|
||||||
}
|
}
|
||||||
|
crit_error_handling.Unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user