2012-06-13

NVIDIA Quadro 10000M (Lenovo W520): Updaing to Kubuntu 12.04LTS from 11.10


Problem when update Kubuntu 11.10 to Kubuntu 12.04LTS on Lenovo W520

When I updated the Kubuntu 11.10 to 12.04LTS, there were some problems I encountered.
  • I can not boot Linux anymore (Black screen with the cursor on top).
  • I can not even boot by the Kubuntu install disk (DVD).
There seemed two problems.
  • The install disk problem: it doesn't support NVIDIA Quadro 10000M card.
  • The Linux boot loader's entry address might be changed.

Solution

  • Setup BIOS: Graphics card to Integration Graphics (not Discrete card, not Optimus). Then you can boot from the boot DVD disk. Then do the  http://shitohichiumaya.blogspot.de/2012/01/dualboot-with-wde-whole-disk-encryption.html, "Dual boot set up from Windows 7 partition" section. You may want to delete the old boot loading entry, if so, please see "Delete the boot entry" below.
  • Install the NVIDIA driver from your package manager. There is 295.40 driver is there. This works for Quadro 10000M.
  • Switch back to Graphics card BIOS settings to "discrete graphics card".

Delete the boot entry

  • On Windows 7, open the command prompt. Use "bcdedit /v" command to see which boot entries are there. You can see the boot entry IDs.
  • Type: bcdedit /delete {BootEntryID}
  • Be careful of this command! This is a dangerous command. Don't remove the necessary entries.

2012-06-01

C++: Operator= returns const reference of *this or reference of *this?

Abstract

Recently, I started to use cppcheck. cppcheck suggested me that the return type of operator= should reference of (*this). But I thought this should be const reference of (*this). I thought the reason of this.

Contents

Cppcheck is an static analysis tool for C/C++ code. (http://cppcheck.sourceforge.net/) I found this tool is quite useful since it sometimes finds a memory leak error and so on. However, the following code has some style error at the operator=.

#include 
class OpTest {
public:
    /// constructor
    OpTest(int init_int) : m_int(init_int){
        // empty
    }
    /// operator= with const reference
    OpTest const & operator=(OpTest const & rhs){
        if(this != &rhs){
            m_int = rhs.m_int;
        }
        return *this;
    }
public:
    int m_int;
};

cppcheck said:
[operator_substitute_00.cpp:9]: (style) 'OpTest::operator=' should return 'OpTest &'.
I thought when I finished substitution of an instance, I consider the instance (= *this) should be const. Therefore, I was puzzled when I saw this message. I look up web, but I could not find a page that explains why this should be. Although, many of code returns just a reference of (*this).

I asked several colleagues about this. Then Ali answered me that: maybe you can call the non const method after the substitution. The following code is an example.
OpTest a(0);
OpTest b(1);
(a = b).non_const_method();
I see a point, but personally, I would prefer the following code.
OpTest a(0);
OpTest b(1);
a = b;
a.non_const_method();