Permalink
Browse files

Merge branch 'master' into alpha

  • Loading branch information...
2 parents 2ef362f + 996fdc0 commit 31ef00e4896b076685ce7e622ca827ced9dc104e @Lexikos committed Mar 3, 2012
Showing with 23 additions and 16 deletions.
  1. +10 −1 source/application.cpp
  2. +7 −14 source/script_expression.cpp
  3. +6 −1 source/var.h
@@ -363,7 +363,16 @@ bool MsgSleep(int aSleepDuration, MessageMode aMode)
// Otherwise: aSleepDuration is non-zero or we already did the Sleep(0)
if (messages_received == 0 && allow_early_return)
{
- Sleep(5); // Since Peek() didn't find a message, avoid maxing the CPU. This is a somewhat arbitrary value: the intent of a value below 10 is to avoid yielding more than one timeslice on all systems even if they have unusual timeslice sizes / system timers.
+ // Fix for v1.1.05.04: Since Peek() didn't find a message, avoid maxing the CPU.
+ // This specific section is needed for PerformWait() when an underlying thread
+ // is displaying a dialog, and perhaps in other cases.
+ // Fix for v1.1.07.00: Avoid Sleep() if caller specified a duration of zero;
+ // otherwise SendEvent with a key delay of 0 will be slower than expected.
+ // This affects auto-replace hotstrings in SendEvent mode (which is the default
+ // when SendInput is unavailable). Note that if aSleepDuration == 0, Sleep(0)
+ // was already called above or by a prior iteration.
+ if (aSleepDuration > 0)
+ Sleep(5); // This is a somewhat arbitrary value: the intent of a value below 10 is to avoid yielding more than one timeslice on all systems even if they have unusual timeslice sizes / system timers.
++messages_received; // Don't repeat this section.
continue;
}
@@ -146,20 +146,13 @@ LPTSTR Line::ExpandExpression(int aArgIndex, ResultType &aResult, ExprTokenType
this_token.symbol = SYM_STRING; //
if (deref->marker == cp && !cp[deref->length] && (deref+1)->is_function // %soleDeref%()
- && (deref->var->HasObject() // It's an object.
- || !deref->var->HasContents())) // It's an empty string (which may be passed to __Call).
+ && deref->var->HasObject()) // It's an object; implies var->Type() == VAR_NORMAL.
{
- // This dynamic function call deref consists of a single var containing an object
- // or an empty string; both need special handling.
- if (deref->var->HasObject())
- {
- // Push the object, not the var, in case this variable is modified in the
- // parameter list of this function call (which is evaluated prior to SYM_FUNC).
- this_token.symbol = SYM_OBJECT;
- this_token.object = deref->var->Object();
- this_token.object->AddRef();
- }
- // Otherwise, leave it set to the empty string.
+ // Push the object, not the var, in case this variable is modified in the
+ // parameter list of this function call (which is evaluated prior to SYM_FUNC).
+ this_token.symbol = SYM_OBJECT;
+ this_token.object = deref->var->Object();
+ this_token.object->AddRef();
goto push_this_token;
}
// Otherwise, it could still be %var%() where var contains a string which is too
@@ -204,7 +197,7 @@ LPTSTR Line::ExpandExpression(int aArgIndex, ResultType &aResult, ExprTokenType
// Copy any chars that occur after the final deref into the buffer:
for (; *cp && var_name_length < MAX_VAR_NAME_LENGTH; left_buf[var_name_length++] = *cp++);
if (var_name_length >= MAX_VAR_NAME_LENGTH && *cp // The variable name would be too long!
- || !var_name_length) // It resolves to an empty string (e.g. a simple dynamic var like %Var% where Var is blank).
+ || !var_name_length && !deref->is_function) // It resolves to an empty string (e.g. a simple dynamic var like %Var% where Var is blank) but isn't a dynamic function call, which would trigger g_MetaObject.__Call().
goto double_deref_fail; // For simplicity and in keeping with the tradition that expressions generally don't display runtime errors, just treat it as a blank.
// Terminate the buffer, even if nothing was written into it:
View
@@ -262,7 +262,12 @@ class Var
ResultType AssignStringToCodePage(LPCWSTR aBuf, int aLength = -1, UINT aCodePage = CP_ACP, DWORD aFlags = WC_NO_BEST_FIT_CHARS, char aDefChar = '?');
inline ResultType AssignStringW(LPCWSTR aBuf, int aLength = -1)
{
- return UorA(AssignString,AssignStringToCodePage)(aBuf, aLength);
+#ifdef UNICODE
+ // Pass aExactSize=true for consistency with AssignStringTo/FromCodePage/UTF8.
+ return AssignString(aBuf, aLength, true);
+#else
+ return AssignStringToCodePage(aBuf, aLength);
+#endif
}
inline ResultType Assign(DWORD aValueToAssign) // For some reason, this function is actually faster when not __forceinline.

0 comments on commit 31ef00e

Please sign in to comment.