Commit graph

2706 commits

Author SHA1 Message Date
Aurimas Černius
d4a8e21578 Updated Lithuanian translation 2015-09-09 17:35:40 +03:00
Kjartan Maraas
32aba0c39a Updated Norwegian bokmål translation from ProjectX. 2015-09-07 21:59:32 +02:00
Seong-ho Cho
0916a50cbe Updated Korean translation 2015-09-08 02:34:33 +09:00
Piotr Drąg
68a162ab68 Updated Polish translation 2015-09-04 00:18:34 +02:00
Mike Fleetwood
bdbb6729f8 Fix configuration version compare issue affecting libparted from GIT (#753525)
When configuring GParted build with libparted from GIT it may perform
the version compares incorrectly and think the version of libparted is
higher that it actually is.  Libparted uses the number of commits from
the last git tag as the third part of the version number.

For example install libparted from one commit before release 3.1, 142
commits after release 3.0.
    $ git checkout v3.1^
    $ describe
    v3.0-142-g82327a3
    $ ./bootstrap
    $ ./configure --prefix=/tmp/parted-3.0-git
    $ make && make install

Configure GParted:
    $ export CPPFLAGS=-I/tmp/parted-3.0-git/include
    $ export LDFLAGS=-L/tmp/parted-3.0-git/lib
    $ export LD_RUN_PATH=/tmp/parted-3.0-git/lib
    $ export PKG_CONFIG_PATH=/tmp/parted-3.0-git/lib/pkgconfig
    $ ./configure
    ...
    checking for libparted >= 1.7.1 (querying pkg-config)... 3.0.142-8232
    checking for 2.0 <= libparted <= 3.0 (loop table creation doesn't delete old partitions)... (cached) no
    checking for libparted >= 2.2 (improved pt re-read)... (cached) yes
    checking for ped_file_system_resize in -lparted... no
    checking for ped_file_system_resize in -lparted-fs-resize... yes
    checking for libparted >= 3.2 (online resize)... (cached) no
    ...
Libparted is reported as version 3.0.142, but checking of the version
between 2.0 and 3.0 inclusive fails.

The configure script is multiplying components of the version by 100
when adding them together.
    $ echo 3.0.142-8232 | awk -F. '{print $1 * 10000 + $2 * 100 + $3}'
    30142

So it is only allowing up to 99 commits before it is equivalent to the
second minor number increasing by one.  Increase the multiplication
factor to 10000, allowing up to 9999 commits between releases.  An order
of magnitude more commits than so far seen between parted releases.

Bug 753525 - Configuration issues when using non-system location or
             non-released versions of libparted
2015-08-18 10:30:08 -06:00
Mike Fleetwood
050366f691 Fix configuration version mismatch when using custom install of libparted (#753525)
When configuring GParted build with a custom install of libparted the
configure script is using the wrong version number for the version of
libparted.  It uses the version of the system install of libparted,
rather that the version of the specified custom install of libparted.

For example configuring GParted build on CentOS 7 with system provided
libparted 3.1 and custom install of libparted 3.2 from GIT in
/tmp/parted-3.2-git:
    $ export CPPFLAGS=-I/tmp/parted-3.2-git/include
    $ export LDFLAGS=-L/tmp/parted-3.2-git/lib
    $ export LD_RUN_PATH=/tmp/parted-3.2-git/lib
    $ ./configure
    ...
    checking for libparted >= 1.7.1 (querying pkg-config)... 3.1
    checking for 2.0 <= libparted <= 3.0 (loop table creation doesn't delete old partitions)... (cached) no
    checking for libparted >= 2.2 (improved pt re-read)... (cached) yes
    checking for ped_file_system_resize in -lparted... no
    checking for ped_file_system_resize in -lparted-fs-resize... yes
    checking for libparted >= 3.2 (online resize)... (cached) no
    ...
    $ make
    $ ldd src/gpartedbin | fgrep libparted
        libparted-fs-resize.so.0 => /tmp/parted-3.2-git/lib/libparted-fs-resize.so.0 (0x00007f9a460ee000)
        libparted.so.2 => /tmp/parted-3.2-git/lib/libparted.so.2 (0x00007f9a45ea3000)
Configure script used version 3.1 as reported by pkg-config to make most
of the decisions (those version related checks with cached results) but
the executable was still linked with the custom libparted 3.2 install.

Temporarily rename the system libparted pkg-config file out of the way:
    # cd /usr/lib64/pkgconfig
    # mv libparted.pc libparted.pc-NOT
and reconfigure the GParted build:
    $ ./configure
    ...
    checking for libparted >= 1.7.1 (querying pkg-config)... not found
    checking for libparted >= 1.7.1 (querying libparted)... 3.2.25-5a92
    checking for 2.0 <= libparted <= 3.0 (loop table creation doesn't delete old partitions)... (cached) no
    checking for libparted >= 2.2 (improved pt re-read)... (cached) yes
    checking for ped_file_system_resize in -lparted... no
    checking for ped_file_system_resize in -lparted-fs-resize... yes
    checking for libparted >= 3.2 (online resize)... (cached) yes
    ...
Now configure is having to compile a program with the custom install of
libparted and gets the correct version.

Restore libparted pkg-config file:
    # mv libparted.pc-NOT libparted.pc
and this time set environment variable PKG_CONFIG_PATH to inform
pkg-config of the additional directory to search for .pc files before
the default system location:
    $ export PKG_CONFIG_PATH=/tmp/parted-3.2-git/lib/pkgconfig
    $ ./configure
    ...
    checking for libparted >= 1.7.1 (querying pkg-config)... 3.2.25-5a92
    checking for 2.0 <= libparted <= 3.0 (loop table creation doesn't delete old partitions)... (cached) no
    checking for libparted >= 2.2 (improved pt re-read)... (cached) yes
    checking for ped_file_system_resize in -lparted... no
    checking for ped_file_system_resize in -lparted-fs-resize... yes
    checking for libparted >= 3.2 (online resize)... (cached) yes
    ...
Now configure is getting the correct version of the custom install of
libparted when querying pkg-config and thus making the correct
decisions.

Update the README file to reflect the need to also set the
PKG_CONFIG_PATH environment variable when building GParted with a custom
install of libparted.

Bug 753525 - Configuration issues when using non-system location or
             non-released versions of libparted
2015-08-18 10:30:08 -06:00
Daniel Mustieles
39feac8dd3 Updated Spanish translation 2015-08-12 09:03:37 +02:00
Anders Jonsson
ee26d4fffc Updated Swedish translation 2015-08-10 18:23:18 +00:00
Mike Fleetwood
ff3f51ac29 Update names of the ntfs and reiserfs specific packages (#753436)
The ntfs-3g package previously provided the FUSE based NTFS driver to
mount the file system and ntfsprogs provided the user space tools.  In
April 2011 the packages have merged [1] forming ntfs-3g_ntfsprogs.  Arch
Linux / Debian / Slackware / Ubuntu now just have an ntfs-3g package
with everything; where as CentOS / Fedora / openSUSE are sticking with
the original two package names.  Reverse the order of the needed
packages to:

    ntfs-3g / ntfsprogs

[1] Release: NTFS-3G + NTFSPROGS 2011.4.12
    http://www.tuxera.com/release-ntfs-3g-ntfsprogs-2011-4-12/

For reiserfs the upstream package is named reiserfsprogs.  Arch Linux /
Debian / Slackware / Ubuntu use this name; but CentOS / Fedora name it
reiserfs-utils and openSUSE names it just reiserfs.  Update the README
file with all 3 package names.

    reiserfsprogs / reiserfs-utils / reiserfs

In the File System Support dialog just use the first 2 package names as
we don't want to make the dialog too wide with all 3 names and hopefully
on openSUSE it is more obvious that the reiserfs package is needed to
support the reiserfs file system.

NOTE:
Again this slightly increases the width of the File System Support
dialog on my CentOS 6 desktop with default fonts, now from 676 to 707
pixels.  Again still well within the 800 wide target and still narrower
than the main window.

Bug 753436 - Update documentation of GParted software dependencies
2015-08-10 11:34:03 -06:00
Mike Fleetwood
4160ae5018 Update name of the btrfs file system specific package (#753436)
In Fedora bug report:
    Bug 1176108 - Warning shown on BTRFS partition because of missing btrfs-tools package
    https://bugzilla.redhat.com/show_bug.cgi?id=1176108#c0
The user said:
    However there is no btrfs-tools package in the standard Fedora repo.
    There is a btrfs-progs package, which is already installed.  It's
    unclear whether this is a real error or simply a mismatched package
    name.

The upstream software is named btrfs-progs.  Arch Linux / CentOS /
Fedora / Slackware use the upstream name.  Debian / Ubuntu name it
btrfs-tools and openSUSE calls it btrfsprogs (no dash).

Rename the needed software to:

    btrfs-progs / btrfs-tools

Upstream name first separated by slash from alternative names
distributions use.

NOTE:
This slightly increases the width of the File System Support dialog on
my CentOS 6 desktop with default fonts, from 655 to 676 pixels.  Still
well within the 800 wide target and still narrower that the main window.

Bug 753436 - Update documentation of GParted software dependencies
2015-08-10 11:31:31 -06:00
Mike Fleetwood
749a249571 Document blkid command as a mandatory requirement (#753436)
Update the README file to document the blkid command as a mandatory
requirement for GParted.  GParted will run without blkid but it is
needed to detect a number of file systems which libparted doesn't and in
a number of other situations.

Blkid is needed to detect these file systems:
    exfat
    f2fs
    ReFS
    SWRaid
    ZFS

Blkid also detects these file systems (for which GParted has simple
internal detection but libparted, mostly, doesn't detect):
    btrfs      (detected by libparted >= 3.2)
    LVM2 PV
    LUKS
    nilfs2     (detected by libparted >= 2.4)
    reiser4

Blkid is also needed for these commits:

1)  f8faee6377
    Avoid whole disk FAT being detected as MSDOS partition table (#743181)
    (with libparted 1.9.0 to 2.3 inclusive)

2)  9e5e9f5627
    Enhance file system detection to use FS_Info method - blkid
    (Detect file systems with sector sizes other than 512 bytes with
    libparted 2.2)

Other changes to the DISTRIBUTION NOTES section of the README file:
* Drop NOTE about vol_id and blkid being used to read volume labels for
  specific file systems and read the UUIDs.  Vol_id was deprecated in
  May 2009 and is not included in any currently supported distribution.
  Blkid is now mandatory.  List of optional commands at the end of the
  section seems to cover everything that is necessary.
* Indent description of optional commands at the end of the section to
  match the indentation earlier in the section.
* Line wrap the section at column 72 to match the rest of the file.

Bug 753436 - Update documentation of GParted software dependencies
2015-08-10 11:31:31 -06:00
Mike Fleetwood
9f0b5ee633 Remove "Skip setting unsupported partition flag" message
This message would be displayed as part of the details for an operation
to create or format a partition as LVM2 PV on a disk using partition
table types dvh or pc98, which don't have an lvm flag.

 v Format /dev/sdb1 as lvm2 pv
   > calibrate /dev/sdb1
   > clear old file system signatures in /dev/sdb1
   > set partition type on /dev/sdb1
       Skip setting unsupported partition flag: lvm
   > create new lvm2 pv file system

Translators found this message difficult to translate, as reported in
bug 752901 - Add translator comment or fix string.  It is also only
standard practice to set the lvm flag on partitions containing LVM2 PVs,
and not required.  In hindsight reporting that an operation was skipped,
when the operation is not a necessity, is probably bad practice as it
could lead to uncertainty on behalf of the user and questions as to why
the flag isn't supported.  Just remove the message.
2015-08-08 09:55:42 -06:00
Mike Fleetwood
3276951ccd Minor update of colours for LVM2 PVs and ReFS
Correct the colour name comment for NILFS2.

Colour for LVM2 PV was a Medium Brown.  This is close to Face Skin Dark
from the GNOME colour palette.  Use this instead.

Make colour for ReFS a bit darker so it is more distinct from the colour
for NTFS.
2015-08-08 09:55:42 -06:00
Mike Fleetwood
71715a1c29 Add detection of ZFS (#752862)
Requires blkid from util-linux >= 2.15, released May 2009, for
detection of ZFS.

Bug 752862 - ZFS is not recognised
2015-08-08 09:55:42 -06:00
Rūdolfs Mazurs
226f7ee8e8 Updated Latvian translation 2015-08-03 21:07:35 +03:00
Curtis Gedak
e1ba16e167 Append -git to version for continuing development 2015-08-03 10:29:37 -06:00
Curtis Gedak
a10057d837 ========== gparted-0.23.0 ========== 2015-08-03 10:05:57 -06:00
Wolfgang Stöggl
14e6b7639a Updated German translation 2015-07-31 22:14:55 +00:00
Milo Casagrande
48a9d7eec7 Updated Italian translation 2015-07-31 07:13:47 +00:00
A S Alam
574ac285c5 Punjabi Translation updated 2015-07-27 22:59:12 -05:00
Curtis Gedak
0dc05fdf3b Add translation comments for code section setting partition flag (#752901)
Add translation comments to improve the clarity of some translatable
text strings regarding setting partition flags.

Bug 752901 - Add translator comment or fix string
2015-07-27 17:57:52 +01:00
Enrico Nicoletto
b23092ae77 Updated Brazilian Portuguese translation 2015-07-27 16:06:04 +00:00
Josef Andersson
c3f865e10f Updated Swedish translation 2015-07-26 19:01:00 +00:00
Josef Andersson
10de60c851 Updated Swedish translation 2015-07-26 19:00:10 +00:00
Alexandre Franke
8a7b3d23b4 Updated French translation 2015-07-26 17:26:05 +00:00
Baurzhan Muftakhidinov
12b2fc4237 Updated Kazakh translation 2015-07-26 15:42:19 +00:00
Daniel Șerbănescu
1b562ad1dd Updated Romanian Translation 2015-07-26 17:40:36 +02:00
Dušan Kazik
b4084db410 Updated Slovak translation 2015-07-23 18:02:31 +00:00
Curtis Gedak
c7c42f2cc5 Adjust pointers to prevent crash when resizing a logical partition (#752587)
Opening the Resize/Move dialog on a logical partition causes GParted to
crash.  This crash affects current GParted GIT HEAD, but does not affect
GParted 0.22.0.  Git bisect identifies that it was broken with the
following commit:
    Remove Set_Data() from the copy, resize/move and new dialog class APIs
    7a4a375ed6

The problem was trying to treat the reference display_partitions_ref
like a pointer, and in particular on line 1732 trying to make it refer
to the a different vector of partitions, .logicals sub-vector.

  1721  void Win_GParted::activate_resize()
  1722  {
  ...
  1726          std::vector<Partition> & display_partitions_ref = display_partitions;
  1727          if ( selected_partition_ptr->type == TYPE_LOGICAL )
  1728          {
  1729                  unsigned int ext = 0 ;
  1730                  while ( ext < display_partitions.size() && display_partitions[ext].type != TYPE_EXTENDED )
  1731                          ext++;
* 1732                  display_partitions_ref = display_partitions[ext].logicals;
  1733          }
  1734
  1735          Dialog_Partition_Resize_Move dialog( gparted_core.get_fs( selected_partition_ptr->filesystem ),
  1736                                               *selected_partition_ptr,
  1737                                               display_partitions_ref );

What was actually happening was that the .logicals sub-vector was being
copied, replacing the display_partitions vector and freeing the original
sub-vector.  This left selected_partition_ptr pointing to the original
memory where the selected partition use to exist in the .logicals
sub-vector.  At some point in the Dialog_Partition_Resize_Move class
*selected_partition_ptr was referenced, accessing the freed memory.
Crash soon followed.

Fix by using a pointer instead of a reference, which can be assigned to
point to a different object.

Bug 752587 - GParted crashing when opening Resize/Move dialog on
             logical partition
2015-07-22 17:22:08 +01:00
Marek Černocký
8dff5af807 Updated Czech translation 2015-07-21 19:30:27 +02:00
Curtis Gedak
1561d1ae7e Add libparted ped_file_system_resize thread to avoid blocking GUI (#737022)
Since GParted commit 52a2a9b "Reduce threading (#685740)", released in
GParted 0.15.0, application of operations occurs in the main thread
running the UI, therefore long running libparted actions such as
resizing a FAT16 or FAT32 file system hang the UI for as long as it take
to complete the operation.
https://git.gnome.org/browse/gparted/commit/?id=52a2a9b00a32996921ace055e71d0e09fb33c5fe

Though this problem exists for all libparted actions, it is particularly
noticeable when performing a large resize of fat16/fat32/hfs/hfs+ file
systems.

To address this significant cause of an unresponsive GUI, this
enhancement adds threading to the libparted ped_file_system_resize
function call.

Bug 737022 - UI hangs while running libparted operations such as
             FAT16/FAT32 resizing
2015-07-19 21:57:17 +01:00
Anders Jonsson
12e960a61b Add image to Swedish documentation 2015-07-19 01:07:09 +02:00
Balázs Úr
72f9a2a3c8 Updated Hungarian translation 2015-07-17 14:09:29 +00:00
Daniel Mustieles
0adc0a0bda Updated Spanish translation 2015-07-13 14:07:51 +02:00
Stas Solovey
4e19422312 Updated Russian translation 2015-07-13 11:14:04 +00:00
Piotr Drąg
fef569552c Updated Polish translation 2015-07-05 20:28:07 +02:00
Mike Fleetwood
038209a9cf Remember result of searching the PATH for udevadm and udevsettle cmds
GParted was also searching the PATH for the availability of the udevadm
and udevsettle commands for every device with a busy partition during a
refresh and for every applied operation effecting a partition table.  As
with hdparm previously this was wasteful.

Again, remember the result of searching the PATH at startup and refresh
when clicking on the [Rescan For Supported Actions] button in the File
System Support dialog.
2015-07-01 10:22:57 -06:00
Mike Fleetwood
54d0e3d056 Remember result of searching the PATH for the hdparm command (#751251)
Previously on every refresh for every device, GParted was searching the
PATH to discover if the hdparm command existed.  Stracing GParted showed
that calling Glib::find_program_in_path("hdparm") made the following OS
calls:
    access("/usr/lib64/qt-3.3/bin/hdparm", X_OK) = -1 ENOENT (No such file or directory)
    access("/usr/local/sbin/hdparm", X_OK) = -1 ENOENT (No such file or directory)
    access("/usr/local/bin/hdparm", X_OK) = -1 ENOENT (No such file or directory)
    access("/sbin/hdparm", X_OK) = 0
    getuid()                    = 0
    stat("/sbin/hdparm", {st_mode=S_IFREG|0755, st_size=137, ...}) = 0
    stat("/sbin/hdparm", {st_mode=S_IFREG|0755, st_size=137, ...}) = 0

The Linux VFS is very fast but repeatedly doing this is wasteful.
Remember the result of searching the PATH for the hdparm command at
startup and refresh this when the [Rescan For Supported Actions] button
is pressed in the File System Support dialog.  This is the same as
GParted already does for file system specific commands and their
capabilities.

Bug 751251 - Show serial number in device information
2015-07-01 10:22:57 -06:00
Mike Fleetwood
4fce7cd5ee Don't hang reading binary data from command output (#751251)
With a Kobo Touch eReader connected via USB, GParted would hang when
scanning the device with this error written to the terminal:

    $ sudo src/gpartedbin
    ======================
    libparted : 2.3
    ======================

    (gpartedbin:10261): glibmm-CRITICAL **:
    unhandled exception (type Glib::Error) in signal handler:
    domain: g_convert_error
    code  : 1
    what  : Invalid byte sequence in conversion input

The hdparm command was printing binary data as the serial number.
Fragment of the 'hdparm -I /dev/sdf' output:

    # hdparm -I /dev/sdf

    /dev/sdf:
    SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

    ATAPI Optical card reader/writer, with non-removable media
            Model Number:       {BINARY_DATA}
            Serial Number:      {BINARY_DATA}
            Firmware Revision:  {BINARY_DATA}

GParted reads command output using the Glib::IOChannel class.  However
by default an IOChannel performs character set conversion on the data it
reads, so when it came across an invalid byte sequence in the binary
data the above exception was raised and the IOChannel::read() method
never returned.  Hence GParted became stuck reportedly scanning the
same device forever.  Code fragment:

src/PipeCapture.cc
    49  bool PipeCapture::OnReadable( Glib::IOCondition condition )
    50  {
    ...
    58          Glib::ustring str;
>>  59          Glib::IOStatus status = channel->read( str, 512 );
    60          if (status == Glib::IO_STATUS_NORMAL)
    61          {
    62                  for( Glib::ustring::iterator s = str.begin(); s != str.end(); s++ )

Quote from the IOChannel class reference:
    https://developer.gnome.org/glibmm/stable/classGlib_1_1IOChannel.html

    Note that IOChannels implement an automatic implicit character set
    conversion to the data stream, and usually will not pass by default
    binary data unchanged. To set the encoding of the channel, use
    e.g. set_encoding("ISO-8859-15"). To set the channel to no encoding,
    use set_encoding() without any arguments.

Fix by disabling the automatic character set conversion in the IOChannel
used to read output from executed commands.

Bug 751251 - Show serial number in device information
2015-07-01 10:22:57 -06:00
Mike Fleetwood
4b72ecd44e Display device serial numbers (#751251)
Run "hdparm -I /dev/DISK" to get the hard drive serial number of
every device which has one and display it in the Device Information.
The displayed value can either be the actual serial number, "none" or
blank.  "none" means the device doesn't have a hard drive serial number,
such as for Linux software RAID arrays, BIOS fake RAID arrays or USB
flash drives.  Blank means something went wrong getting the serial
number.  Either it couldn't be found in the hdparm output or the hdparm
command wasn't installed.

Example real hard drive:
    # hdparm -I /dev/sda
    ...
    ATA device, with non-removable media
            Model Number:       SAMSUNG HM500JI
            Serial Number:      S1WFJDSZ123732
    ...

Example Linux software RAID array:
    # hdparm -I /dev/md127

    /dev/md127:
     HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device

On my desktop with 4 internal hard drives 2 Linux software RAID arrays
on those hard drives, 2 USB flash drives and 1 USB hard drive attached,
running hdparm 9 times added 0.07 seconds to the device refresh time.

Bug 751251 - Show serial number in device information
2015-07-01 10:22:47 -06:00
Mike Fleetwood
8308ee6051 Support changing the UUID of a btrfs file system (#751337)
Btrfs-progs 4.1, released June 2015, includes support for changing the
UUID of a btrfs file system using the btrfstune command.  Check for
availability by looking for the -u option in the btrfstune help output.
Use btrfstune like this:

    # umount /dev/sdb1
    # btrfstune -f -u /dev/sdb1
    Current fsid: e7ad5dba-d721-4f99-990b-1ba2901c8ad2
    New fsid: 231563d9-e173-410d-b1da-d34c4319a423
    Set superblock flag CHANGING_FSID
    Change fsid in extents
    Change fsid on devices
    Clear superblock flag CHANGING_FSID
    Fsid change finished
    # echo $?
    0

Bug 751337 - btrfstune in btrfs-progs 4.1 supports changing the file
             system UUID
2015-06-28 10:57:58 -06:00
Mike Fleetwood
d405bb2264 Provide comment for btrfs::clear_cache() call
Explain why the implementation uses a clear_cache() call, rather than a
straight load_cache() call.  This commit from 2014-02-17 implemented
incremental loading of the btrfs device cache:
    76e64f2905
    Detect busy status of multi-device btrfs file systems (#723842)
2015-06-13 10:56:31 -06:00
Mike Fleetwood
9be8d37600 Delay loading LVM2_PV_info cache until actually needed (#750582)
The lvm query commands were always run and the cache loaded even if
GParted, actually blkid, didn't identify any LVM2 PVs.  (GParted uses
libparted and blkid to identify partition content and the lvm commands
to provide the needed configuration details).

Now implement complete lazy initialization of the cache.  Never force
loading of the cache.  The cache is only loaded when the first value is
accessed from it.  When there are no LVM2 PVs, the cache is never
queried, so never loaded.  All the needed infrastructure for delayed
loading was previously added by this commit from 2011-12-11:
    ff8ad04120
    Lazy initialize the cache from querying LVM2 PVs (#160787)
Every public member function which access values from the cache already
calls initialize_if_required().  Just need to replace force loading of
the cache with a function which just clears the cache.

On my desktop, only when there are no LVM2 PVs, not loading the cache
and therefore not executing these external commands in
load_lvm2_pv_info_cache() saves 1.0 seconds of the 3.7 seconds it takes
to perform the a refresh in GParted:
    lvm vgscan
    lvm pvs ... -o pv_name,...
    lvm pvs ... -o vg_name,...

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
2015-06-13 10:56:31 -06:00
Mike Fleetwood
e6f7ea01f9 Parse LVM2_PV_Info cache into fields while loading (#750582)
GParted used to cache the results of the "lvm pvs" commands used to query
the state of the Logical Volume Manager as a series of lines of text.
Then every time a particular value was queried GParted would split all
the lines of text into fields until the required value was found.

Stop this repeat splitting of cached lines of text.  Instead parse the
lines of text into separate fields and store in structures of values of
the correct type in the cache.

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
2015-06-13 10:56:15 -06:00
Mike Fleetwood
2c5e7b0d90 Stop needing any LVM2_PV_Info objects (#750582)
The LVM2_PV_Info cache had a pretend multi-object interface, yet all the
data is static.  An LVM2_PV_Info object doesn't contain any member
variables, yet was needed just to call the member functions.

Make all the member functions static removing the need to use any
LVM2_PV_Info objects.

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
2015-06-13 10:56:12 -06:00
Mike Fleetwood
81f0b934bc Stop borrowing the constructor to load the LVM2_PV_Info cache (#750582)
An LVM2_PV_Info object contains no member variables as all the data is
static (exists once in the program and accessed by all objects).  The
constructor did nothing, except when passed true to load the cache.

Provide a separate load_cache() member function and remove the
constructors and destructor which do nothing.  The C++ compiler will
provide a default constructor and destructor, which don't do anything as
there are no member variables to initialise and finalise.

This makes the interface a little easier to understand.  Mostly a step
along the way of refactoring how the LVM2_PV_Info cache module works.

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
2015-06-13 10:55:48 -06:00
Mike Fleetwood
7a4a375ed6 Remove Set_Data() from the copy, resize/move and new dialog class APIs
The copy, resize/move and new dialog classes (Dialog_Partition_Copy,
Dialog_Partition_Resize_Move and Dialog_Partition_New respectively) had
to be used like this:

    construct dialog object passing some parameters
    call Set_Data() to pass more parameters
    run() dialog
    call Get_New_Partition()

There is nothing in the classes which forces Set_Data() to be called,
but it must be called for the dialogs to work and prevent GParted from
crashing.

Make these class APIs safer by making it impossible to program
incorrectly in this regard.  Move all the additional parameters from
each Set_Data() method to each constructor.  The constructors just call
the now private set_data() methods.
2015-06-10 10:44:33 -06:00
Mike Fleetwood
32a5ace156 Rename Dialog_Base_Partition member to new_partition
The member variable was named selected_partition.  It is assigned from
Win_GParted::selected_partition_ptr (which is a pointer to a const
partition object so is never updated).  This gives connotations that it
won't be modified.

However it is updated freely as the new resultant partition object is
prepared before being returned from the dialog, most notable in the
Get_New_Partition() methods.

Therefore rename from selected_partition to new_partition.
2015-06-10 10:44:33 -06:00
Mike Fleetwood
8b96f8409f Stop copying selected_partition back on itself in the copy dialog (#750168)
The code goes like this:

    Dialog_Partition_Copy::Get_New_Partition()
        call Dialog_Base_Partition::Get_New_Partition()
            Update this->selected_partition with results from running
            the dialog.
            return this->selected_partition by value.
        Save value back to this->selected_partition.
        Update this->selected_partition some more.
        return this->selected_partition by value.

So there is an unnecessary copy of the partition object returned from
the base class Get_New_Partition() function back to the same variable in
the derived copy class Get_New_Partition() function.

Need to keep the base class Get_New_Partition() function as derived
class Dialog_Partition_Resize_Move uses that implementation as it
doesn't override it, and it's part of the interface.

Avoid this unnecessary copy by moving base class Get_New_Partition()
code into a new private function, called prepare_new_partition(), which
doesn't return anything.  Then have Get_New_Partition() in both classes
just return the required partition object.  Like this:

    Dialog_Base_Partition::Get_New_Partition()
        call prepare_new_partition()
        return this->selected_partition by value.

    Dialog_Partition_Copy::Get_New_Partition()
        call Dialog_Base_Partition::prepare_new_partition()
        Update this->selected_partition some more.
        return this->selected_partition by value.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:44:33 -06:00
Mike Fleetwood
90e3ed68fc Shallow copy Device object into Operation object (#750168)
When Operation objects are created they take a copy of the Device object
to which the operation is to be applied.  The Device object includes a
vector of all the contained Partition objects currently on the device,
so these get copied too.

These additional deep copied Partition objects in the Operation object
are never accessed.  Therefore don't copy the contained Partition
objects when copying the Device object into the Operation object.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:44:33 -06:00