Monday, July 28, 2014

How to in Qt *.Pro-file disable: warning: C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Got a compiler error when using sscanf in QT Creator:
warning: C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

To make sure other warnings wont't disappear in the spam like messages caused by the c++ compiler, we wanted to disable the warning.

Tried to do add this at the top of the main.cpp file but got the same error:

Adding this in the *.PRO file did the trick:

#Removes: warning: C4996: 'sscanf': This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Wednesday, July 02, 2014

JSON-RPC with Fiddler

Needed to do a HTTP POST with a JSON RPC payload. Searched the web and there where a good explanation on StackOverflow explaining how to send  JSON string with fiddler:
Is it possible to make JSON requests using Fiddler's Request Builder?

Put the information together and adding the request in Raw and do Execute:

POST /StatusV1 HTTP/1.1
Host: localhost:8080
Content-Type: application/json; charset=utf-8
Content-Length: 81

{"method": "confirmRigModeKeySwitched", "params": ["correctPassword!"], "id": 99}

Worked as a charm!

Wednesday, June 25, 2014

error LNK2019: unresolved external symbol. Problem with linker in C++ is starting to give me gray hair.

Got this error message in the linker when I switched the project from statically linked to dynamically linked in the .Pro file:

StatusFacade.obj : error LNK2019: unresolved external symbol "private: enum mgccis::status::dto::StatusRigMode::Status __thiscall mgccis::status::StatusFacade::RigModeStatusToDto(enum mgccis::status::RigModeReply::Status)" (?RigModeStatusToDto@StatusFacade@status@mgccis@@AAE?AW4Status@StatusRigMode@dto@23@W44RigModeReply@23@@Z) referenced in function "public: class QString __thiscall mgccis::status::StatusFacade::getStatus(void)" (?getStatus@StatusFacade@status@mgccis@@QAE?AVQString@@XZ)

I just uncommented this row:
#CONFIG += staticlib #Nessesary only when running unit tests :(

The solution was easy, I had forgotten to set the class name on the methods in the cpp file, an honest mistake to do:
mgccis::status::dto::StatusOverloadTest::Status OverloadTestStatusToDto(mgccis::status::OverloadTestReply::Status overloadTestStatus)

Should be:
mgccis::status::dto::StatusOverloadTest::Status StatusFacade::OverloadTestStatusToDto(mgccis::status::OverloadTestReply::Status overloadTestStatus)

Strange that the linker did not complain when I statically linked the project. :)

Saturday, May 17, 2014

Solved: Qt Segmentation fault on MainWindow show() on line: inline void show() { setVisible(true); }

Writing this down so I'll remember in the future.

The application worked in Qt Creator in Windows, but in Linux we received Segmentation Fault when trying to run the application in the debugger.

Looking at the stacktrace only showed that it crashed in SetVisible on the main window.

0 __strlen_sse2 strlen.S 99 0x7e9520
1 XSetCommand /usr/lib/ 0xdbbb9f
2 XSetWMProperties /usr/lib/ 0xdc0601
3 QWidgetPrivate::create_sys(unsigned long, bool, bool) /opt/qt-4.8.4/lib/ 0x110db5e
4 QWidget::create(unsigned long, bool, bool) /opt/qt-4.8.4/lib/ 0x10bc73c
5 QWidget::setVisible(bool) /opt/qt-4.8.4/lib/ 0x10c20e5
6 QWidget::show qwidget.h 494 0x804fd0c
7 mgccis::shell::MainApplication::InitializeInterface mainapplication.cpp 29 0x804facc
8 main main.cpp 25 0x804efb0

It stopped on the line below, it made no sense all objects where initialized:

#ifndef Q_WS_WINCE
    inline void show() { setVisible(true); }
    void show();

After some googling of the subject I found this forum post that described a problem that can cause this error message, it's the signature on the MainApplication that can causes the problem:

But our solutionwas the opposite from the resolution in the forum post. We have our own builder class that gets the arguments from the main method and that passes the argument to the MainApplication, so in our case the solution was to send the argc parameter as value instead of a reference:

So the Change was from:
explicit MainApplication(int &argc, char* argv[]);

To this:
explicit MainApplication(int argc, char** argv);

After the change the application can be debugged in Windows and Linux and the error message made sense, we sent a reference to a temporary instance of the argc to the MainWindow that used when window is shown.

Saturday, April 26, 2014

Solved HP Administrator Tools disabled when trying to enable hardware virtualization for Windows phone emulator.

Got this message when trying to run the windows phone emulator on my new computer an hp folio 9470m:

Clicking on "More information" and you end up on this MSDN article:

Following the instruction I tried to log in as administrator in the BIOS but all Administrator Tools settings were disabled, could not find out why, the log in seemed to be ok with the credentials.

After searching the hp support forum I finally gave up and started to googling the problem, right a way I found this post on the hp support forum,

You have to log in as guest and set the BIOS administrator password to get the Administrator Tools enabled, really bad UX, why not prompt the user to set the administrator password the first time?

Wednesday, April 23, 2014

Error: Loading plugin error: Cannot load library /usr/local/SomeLib/ (/usr/local/SomeLib/ undefined symbol: _ZN18SomePluginModuleD1Ev)

Got this annoying error in QPluginLoader when I deployed and tried to run the application. It took a while before i realized what my mistake was.

I accidentally missed to add a implementation for the destructor and that caused the error message, found this forum post that got me in the right direction:

.h with destructor:

.cpp did not have:
   //clean up...

Friday, March 28, 2014

Sogeti Visual Studio 2013 ALM Roadshow2014, Örnsköldsvik

I went to Sogeti Visual Studio 2013 ALM Roadshow2014, Örnsköldsvik today. Interesting to hear what's new in Visual Studio 2013. 
Here is my notes from today:

Application Insight

Tool for collecting data on apps performance, crash, environment, etc.


  • Synchronize settings if you login using live account.
  • Scrollbar that gives meta information about the code.
  • Auto history, keeps track of changes locally, makes it possible to make a diff against older versions. Automatically or by doing snapshots.
  • Peek, Inline navigation between sourcecode files. keeps the code/context during navigating/peeking other files.
  • Code Map (VS Ultimate only), Visualizing the code blocks and how they are related. Also when debugging. (Can be opened in VS Premium)
  • Code Lens (VS Ultimate only), meta data inline in code. Test status, testing, bugs, workitem, code reviews, maintainability etc.
  • Team explorer, some tabs can be made floating and be docked  in other areas in VS.

Agile project management

  • Features can be added on a higher level (New in Team Foundation Server TFS 2013)
  • Easy prioriting items
  • Scrum board, easy to move items.

Microsoft Test Manager

  • Create test plan, connected to sprint.
  • Easy to create test cases
  • Can take a test drive of the product and create test case from the test drive.
  • Test professional (Tester or project manager)
  • VS Premium or Ultimate if developers what the test tools.
  • Using the web tools requires license as above.
  • UI test case using C# can be created from tests.
  • Possible to pause and resume test cases.

Release management

InRelease got bought by Microsoft and was integrated into TFS.
  • Free to use to keep track of releases.
  • But automatic deployment requires license for deployment agent (One deployment agent per VS Ultimate license).

Central, Distributed Versioning

  • Check-out Check-in (TFS 2010)
  • Edit Commit (TFS2012, CVS, Suversion)
  • Comit Push Pull (TFS 2013, GIT)