Operation classes now internally use pointers to Partition objects and
take on management of their lifetimes. As before, with the
PartitionVector class, when storing pointers in a class the Big 3 of
destructor, copy constructor and copy assignment operator also have to
be considered.
First, all the Partition objects are allocated in the derived Operation*
class parameterised constructors and freed in the associated
destructors. However the Operation classes are never copy constructed
or copy assigned; they are only ever created and destroyed. Only
pointers to the derived Operations are copied into the vector of pending
operations. Therefore the copy construtor and copy assignment operator
aren't needed. To enforce this provide inaccessible private
declarations without any implementation so that the compiler will
enforce this [1][2].
This example code fragment:
1 OperationCheck o1( device, partition );
2 OperationCheck o2 = o1;
3 o2 = o1;
Does these OperationCheck calls:
1 Implemented parameterised construtor,
2 Disallowed copy constructor,
3 Disallowed copy assignment
Trying to compile the above code would fail with errors like these:
../include/OperationCheck.h: In member function 'void GParted::Win_GParted::activate_check()':
../include/OperationCheck.h:36:2: error: 'GParted::OperationCheck::OperationCheck(const GParted::OperationCheck&)' is private
OperationCheck( const OperationCheck & src ); // Not implemented copy constructor
^
test.cc:2:21: error: within this context
OperationCheck o2 = o1;
^
../include/OperationCheck.h:37:19: error: 'GParted::OperationCheck& GParted::OperationCheck::operator=(const GParted::OperationCheck&)' is private
OperationCheck & operator=( const OperationCheck & rhs ); // Not implemented copy assignment operator
^
test.cc:3:4: error: within this context
o2 = o1;
^
[1] Disable copy constructor
http://stackoverflow.com/questions/6077143/disable-copy-constructor
[2] Disable compiler-generated copy-assignment operator [duplicate]
http://stackoverflow.com/questions/7823845/disable-compiler-generated-copy-assignment-operator
Bug 759726 - Implement Partition object polymorphism
The Operation classes contain partition objects which are copied by
value. Need to replace these with pointers to Partition objects instead
and manage their lifetimes so that they can be used polymorphically.
First step is to protect the partition members partition_new,
partition_original, and for OperationCopy class only, partition_copied
within the Operation classes and provide accessor methods.
get_partition_new() and get_partition_original() accessors are
implemented in the Operation base class so all derived classes get an
implementation. get_partition_new() is also virtual so that
OperationCheck and OperationDelete can override the implementation and
assert that they don't use partition_new. get_partition_copied() is
provided for the OperationCopy class only so can only be accessed via an
OperationCopy type variable.
Bug 759726 - Implement Partition object polymorphism
These member variables store no Operation class information and were
being used as local variables. Replace with local variables.
Also indent a code block within an if clause so that the compiler can
confirm that the new local variable isn't used uninitialised. Prevents
this compiler warning:
OperationResizeMove.cc: In member function 'void GParted::OperationResizeMove::apply_normal_to_visual(std::vector<GParted::Partition, std::allocator<GParted::Partition> >&)':
OperationResizeMove.cc:125: warning: 'index' may be used uninitialized in this function
Bug 755214 - Refactor operation merging
Move the code from OperationCreate::apply_to_visual() into new method
Operation::insert_new() in the parent class. This is in preparation for
the following commit.
Bug 755214 - Refactor operation merging
The apply_to_visual() method for the change UUID, format, label file
system and name partition operations duplicated identical code. This
code was just substituting the partition in the disk graphic vector with
the new partition recorded in the operation, as none of these operations
change the partition boundaries. Move this duplicate code into the
parent class in new method Operation::substitute_new().
Bug 755214 - Refactor operation merging
After previous commit "Replace open coded merge of resize/move into
create operation (#755214)" the second created partition would disappear
from the disk graphic in the following sequence: create new #1, create
new #2 leaving space preceding, resize #1 larger. The create new #2
operation still existed and was shown in the operation list. It was
just that it disappeared from the disk graphic.
Remember that when each operation is created it records the partition,
or the unallocated space, to which the operation is applied at the time
the operation is created in the partition_original member variable. In
the above sequence the resize #1 larger operation was merged back into
the create new #1 operation. When visually re-applying the create
new #1 operation to the disk graphic, it left a smaller unallocated
partition following it. This was smaller than the unallocated partition
recorded in the create new #2 operation, hence it failed to visually
re-apply to the disk graphic.
The insight to fix this is that it doesn't matter what size the
unallocated space was when the create new operation was constructed. It
only matters that the new partition to be created fits in the available
unallocated space currently in the disk graphic.
Bug 755214 - Refactor operation merging
Win_GParted::Merge_Operations() method was modifying the internals of
Operation* objects; in particular the partition_new member variable.
This is breaking data hiding and encapsulation tenant of object oriented
programming.
Implement exactly the same operation merge semantics, but hide the
manipulation of the internals of the Operation* objects within the
Operation* classes themselves.
Bug 755214 - Refactor operation merging
Embedded devices (Android) use GPT partition names to identify
partitions, instead of file system labels. Add support for viewing and
changing them.
As partition names are used to provide unique identification they are
never copied when copying the contents of one partition to another.
Note that GNU/Linux uses file system labels, UUIDs or device names for
identification during the boot process and afterwards so while partition
names can be used, they are optional and purely for user information.
Bug 741424 - Add support for GPT partition names
This and the following few commits rename variables, methods, classes,
etc from *label_partition* to *label_filesystem* so that the code also
reflects that it is the label of the file system that is being modified
and to separate it from the name partition operation about to be added.
enum OPERATION_LABEL_PARTITION -> OPERATION_LABEL_FILESYSTEM
Bug 741424 - Add support for GPT partition names
This is part of parent bug:
Bug #721455 - Obsolete info in license text on multiple modules
and GNOME Goal:
https://wiki.gnome.org/Initiatives/GnomeGoals/Proposals
* verify all source files to make sure they have a license and a
copyright, and that both are up-to-date
Bug #721565 - License text contains obsolete FSF postal address
Include guards need to be unique within GParted code and all included
library header files.
http://en.wikipedia.org/wiki/Include_guard#Difficulties
Use this model for all include guards:
#ifndef GPARTED_FILE_NAME_H
#define GPARTED_FILE_NAME_H
...
#endif /* GPARTED_FILE_NAME_H */
Closes Bug #539297 - Make include guards unique
Add the ability to set a new random UUID on file systems that provide
the appropriate tools to perform this action.
Update the help manual to include this new functionality. Also add
reference links to "setting a partition label" and "changing a
partition UUID" in the "copying and pasting a partition" section.
This patch does not include setting the UUID on an NTFS file system.
Bug #667278 - Add support for setting UUID
Bug #608308 - fix documentation - Copying and Pasting a Partition
Restore copyright entries by original author to those of his last
known repository commit titled "released gparted-0.3.4 on
LarryT's request." on Feb 25, 2007.
Add my own copyright entries for files in which I changed source
code. Files in which I only made spelling changes do not have my
copyright entry added.
* include/Makefile.am,
include/Operation.h,
include/Win_GParted.h,
src/GParted_Core.cc,
src/Makefile.am,
src/Win_GParted.cc,
include/OperationCheck.h (new),
src/OperationCheck.cc (new): added 'check' operation. The
functionality was already there, but it was not possible yet to
activate it from the gui.
* include/Dialog_Progress.h,
include/Operation.h,
src/Dialog_Progress.cc,
src/GParted_Core.cc: show warning in progressfeedback if a certain
action is n/a. Of course we only allow these actions if the results
are non-lethal.
* Use ped_device_read and ped_device_write instead of 'dd' to copy
filesystems.
Modified progressdetails to provide more detailed feedback about a
process.
Basicly these were all changes to the infrastructure to make the
incorporation of the 'move-code' a bit easier.
( sorry, not in the mood to list all affected files ;)
* src/Win_GParted.cc: removed warning about busy device. It's not
really needed and it confuses people.
* include/Operation.h: set default status of operationdetails to NONE
* include/Dialog_Progress.h,
src/Dialog_Progress.cc: implemented export of operationdetails to
external file. This can be very usefull for debugging. (#329968)
* added detailed progressfeedback. It still needs some polishing, but
is already far better then the old situation. And what's more, it's
finally threadsafe :p
* happy new year ;)
* src/TreeView_Detail.cc: fixed some alignment issues
* include/GParted_Core.h,
src/GParted_Core.cc,
include/Operation.h,
src/Operation.cc,
include/Win_GParted.h,
src/Win_GParted.cc: removed confirmationdialogs for delete and
convert partitions (#319841).
Also renamed 'convert' to 'format' to reflect the actual
functionality.
* include/GParted_Core.h,
src/GParted_Core.cc: did some cleanups
* include/Operation.h,
src/Operation.cc: added get_index_extended to get the ext_index in a
uniform way instead of calculating it every time ourselves.
* Added cylsize to Device and made Operation contain a Device instead of only the path and lenght.
This way i was able to dump Get_Cyl_Size in the Core. Besides that, i used cylsize in WinGparted and made a lot of
cosmetic changes. Most of them were pretty useless, but hey, i'm bored ;)
* include/GParted_Core.h,
src/GParted_Core.cc: modified layoutscan a bit for improved handling of metadata.
* include/Operation.h,
src/Operation.cc: modified Insert_Unallocated() to prevent potential crasher.
* Again way too many chances to create a detailed entry (i'm glad i'm the only dev atm :P ).
Resizing of ext2/3 works perfect now. I've even tested it on the partition holding my SG seasons =)
Implemented checking of filesystems (only internally used atm).
Done some overall tweaking, finetuning etc.. release 0.0.7 is getting shape.
* Rewrote a large part of gparteds internal code. Filesystemssupport is now much more separated from the rest of gparted and
adding support for other filesystems should be a piece of cake now (hope that's true :P)
It still needs a lot of love, but the foundations are laid =)
* include/Operation.h,
src/Operation.cc: make use of reference arguments instead of return values in some functions.
Also fixed a small bug with deletion of a virtual (new) logical partition.
* include/VBox_VisualDisk.h,
src/VBox_VisualDisk.cc: logical filesystems weren't shown in the legend, fixed.
* src/Frame_Resizer_Base.cc: fixed small bug with custom cursors.
* src/TreeView_Detail.cc: removed obsolete, already commented code.
* src/Win_GParted.cc: make use of reference arguments instead of return values in some functions. (see Operation)
* instead of listing all partition in one list, logical partitions are now stored in a sublist in extended partition object.
This makes partitionhandling in gparted more natural and transparant. It also allowed me to clean up this ugly Operation class ;)
* include/Operation.h,
src/Operation.h: minor (code) change in displaying errormessage. Made Apply_Resize_Move_Extended_To_Visual() a bit more
readable (and thus debugable). This whole class could still use a soft, caring hand though :P
* src/Device.cc: Unallocate space < 1MB wasn't filtered out. fixed.
* src/Partition.cc (Set_Used): Unused wasn't set properly. fixed.