QSerialPortInfo isValid() and isBusy() - qt

QSerialPortInfo class has const methods isValid() (deprecated since 5.2) and isBusy() (deprecated since 5.6). They both seem to work but QT documentation does not provide with info whether they should be replaced with isNull() or state of QSerialPortInfo object should be checked some other way.
Can anyone please tell me actual way to check serial port availability?

I am using the same function call and it appears to work, so I was wondering why the function is obsolete. Turns out, the function opens the port in question, see bug report here. This side effect seems to be the reason why it was marked obsolete and deprecated.
If that side effect is okay with you (and the reported "other issues" by the maintainer in the bug report), then that appears to be an okay way to get done what you're asking for.

With reference to the documentation, both isValid() and isBusy() are obsolete and not recommended to be used in new code.
Quote from documentation (emphasis mine):
They are provided to keep old source code working. We strongly advise against using them in new code.
The See also section points to isNull() method so it should be used.
See commit.

Related

Possibility to modify or extend code in D365FO to suppress thrown error

Original class function creates an SQL query and executes it.
Since there is an syntax error in the query it throws an error. What's the correct way to achieve fixation? Class extension does not work, because CoC executes the complete original function.
originalFunction(..)
{
createSomeSQLQueryWithSyntayErrorInIt();
executeQuery();
}
The class in question is ReqDemPlanMissingForecastFiller. In method insertMissingDatesForecastEntries a direct SQL statement string is generated. The date variable nonFrozenForecastStartDate is added to the string, but is not escaped correctly as it seems.
If the SQL statement is executed, a syntax error occurs. If the statement is fixed, it can be executed e.g. in SQL Server Management Studio (SSMS).
In this specific case, based on your comments, you may be able to sidestep.
Create a new class ReqDemPlanMissingForecastFiller_Fix extending ReqDemPlanMissingForecastFiller then copy/paste the erroneous function and correct the mistake.
Create an extension class and change the newParameters static funcion.
[ExtensionOf(classStr(ReqDemPlanMissingForecastFiller))]
class ReqDemPlanMissingForecastFiller_Extention
{
public static ReqDemPlanMissingForecastFiller newParameters(
ReqDemPlanCreateForecastDataContract _dataContract,
ReqDemPlanAllocationKeyFilterTmp _allocationKeyFilter,
ReqDemPlanTaskLoggerInterface _logger = null)
{
ReqDemPlanMissingForecastFiller filler = next newParameters(_dataContract, _allocationKeyFilter, _logger);
filler = new ReqDemPlanMissingForecastFiller_Fix(); //Throw away previous value
filler.parmDataContract(_dataContract);
filler.parmAttributeManager(_dataContract.attributeManager());
filler.parmAllocationKeyFilter(_allocationKeyFilter);
filler.parmLogger(_logger);
filler.init();
return filler;
}
}
Code above was based on AX 2012 code. Stupid solution to a stupid problem.
It goes almost without saying that you should report the problem to Microsoft.
#Jan B. Kjeldsen's answer describes how the specific case can be solved without involving Microsoft.
Since overlayering is no longer possible, the solution involves copying a fair bit of standard code. This brings its own risks, because future changes by Microsoft for that code are not reflected in the copied code.
Though it cannot always be avoided, other options should be evaluated first:
As #Jan B. Kjeldsen mentioned, errors in the standard code should be reported to Microsoft (see Get support for Finance and Operations apps or Lifecycle Services (LCS)). This enables them to fix the error.
Pro: No further work needed.
Con: Microsoft may decline the fix or take a long time to implement it.
If unlike in this specific case the issue is not a downright error, but a lack of extension options, an extensibility request can be created with Microsoft. They will then add an extension option.
Pro: No further work needed.
Con: Microsoft may decline the extensibility request or take a long time to implement it.
For both errors as well as missing extension options, Microsoft also offers the Community Driven Engineering program (CDE). This enables you to develop changes in the standard code directly via a special Microsoft hosted repository where the standard code is not locked for changes.
Pro: Most flexible and fastest of all options involving Microsoft.
Con: You have to do the work yourself. Microsoft may decline the change. It can still take some time before the change is available in a GA version.
You can also consider a hybrid approach: For a quick solution, copy standard code and customize it as required. But also report an error, create an extensibility request or fix it yourself in the CDE program. When the change is available in standard code, you can then remove the copied code again.

Quartz 2D substitude for graphicsPort in SDK 10.10

The scenario:
I'm editing some CGImages and strangely enough until now I was first creating NSImages from those CGImages before drawing them. So I tried to change the code so that I would draw the CGImages directly in into NSGraphicsContext.currentContext().graphicsPort. As you see I'm using Swing here but the same problem goes for Objective-C I presume.
Having a look into the documentation I saw that graphicsPort will be deprecated in 10.10, but I couldn't find another way to the current CGContext from NSGraphicsContext nor is there a way to create the CGContext from an NSGraphicsContext.
The Question:
Does anybody know what the proper way to retrieve the context would be? If not - Is there a way to cast the graphicsPort's COpaquePointer, which apparently is an initialized NSPipeObject, to a CGContextRef? Although using code that has already been marked deprecated would be quite unsatisfactory I would consider it until there is a better solution.
After spending a half hour digging around for information on this, I realized I should just check out the header file for NSGraphicsContext. Turns out there's a new property on NSGraphicsContext that's apparently not documented yet: CGContext. The header also notes that this should be used instead of graphicsPort.

Undocumented ProcessEventsFlag enums in QT

I noticed that modal dialogs on QT uses a local QEventLoop with the ProcessEventFlags set as "DialogExec"
eventLoop.exec(QEventLoop::DialogExec);
The QT assistant has no information on what this enum means. There is another one called EventLoopExec. Anyone has any idea what they actually mean and why aren't they documented?
Thanks
I did some poking around and this is what I found:
This enum is intentionally omitted from the documentation, along with several other QEventLoop::ProcessEventsFlag enum values (X11ExcludeTimers, ExcludeUserInput, WaitForMore, EventLoopExec) as there is an \omitvalue in front of each one in the comments that generate the docs.
There is only one place in all of Qt that actually uses it, in qeventdispatcher_mac.mm in which it appears to be some kind of mac-specific optimization according to the in-line comments
The intentional omission of these values from the docs leads me to conclude that they're for internal Qt use only, and that you shouldn't need to use them or worry about them.

Documentation of the lesser know AS3 properties

Over the past three weeks, I have lost at least 120 man hours because of some lesser known functionality in ActionScript 3. One of the problems was that, with Internet Explorer, if there are too many messages sent through LocalConnections, it will slow the messages sent through, but in the standalone player and in Firefox, this threshold is significantly higher. Another was that the static values of a class are instantiated even if the member itself is not being used:
import path.to.FooClass;
private function thisIsNeverCalledButItEnsuresThatFooClassIsImported():void
{
var f:FooClass = new FooClass();
}
Since FooClass had a static reference to a Singleton, that Singleton was instantiated so when I loaded a Module which used that Singleton, it would bind to values in an unpredictable way.
Additional cases where things behave in an unexpected way:
MovieClip.addFrameScript
flash.trace.Trace as a class
int is a faster incrementer class, Number is faster for mathematics, and uint is incredibly slow.
PrintDataGrid, if it has only one page, needs to have an empty value appended to the end of its dataProvider
If you use try...catch around two LocalConnections and connect them to the same channel, you will force garbage collection without needing System.gc
So here's the question (and I'm sorry for omitting this in the original post), is there any consolidated documentation for this type of behavior anywhere? Is there any (even non-Adobe) documentation on these issues (websites, forums, books, ANYTHING)? I know that these things are definitely easy enough TO document, but has anyone done so?
If not, am I missing anything? Are there other issues which I should know about?
This kind of useful information is very often not "centralized". Moreover, what you are looking for is something related to the experience of the programmer (more than to official docs).
FYI, there are two other methods for ensuring a class is included.
#1 - This syntax is actually used in the Flex source code:
import path.to.FooClass; FooClass; // note double reference
public class References
{
// No references needed in this class
}
#2 - Use the includes command line argument
-includes path.to.FooClass
You can always submit your experience using the "feedback" section in the help. Unfortunately, this is less obvious than the link that used to be at the bottom of each page in the older help files (which also served the useful function of opening a browser window with the web version of that help page).
Adobe says that it incorporates the comments from previous versions of the help into new versions, but my own observation suggests that there are instances where it does not happen. However, that and the appropriate cookbook are still the best avenue for those who believe that this kind of information should be centralized.
Note that the whole purpose behind modules is to avoid compiling code multiple times, so importing FooClass kind of defeated the purpose. The problems you had in this instance are just one of the many that happen if you use Singletons, and it's unfortunate that the first official Framework, Cairngorm, encouraged their widespread use. Check out http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ .

Alternative to Html.Button<T>?

I know the Html.Button has been moved to the Microsoft.Web.Mvc namespace, but I really miss the generic versions that used to exist in the early Previews.
All I want the Html.Button to do is to hit an action in my controller, but I'd rather not write the JavaScript in the onClickMethod argument.
In my previous project I just snagged the generic Html.Button code from a previous preview release, but that doesn't seem like the best approach as things progress. There were also Html.NavigateButton... where is that and why should I have to recreate it?
How is everybody else doing this?
The problem with the generic versions is that filters are allowed to change the actual name of the action away from the name of the method (like the [ActionName] attribute).
Yes, they really screwed up with Html.Button and Html.CheckBox in CTP5. I hope they return to the previous behaviour.

Resources