Fix inifinite loop while parsing subdirs.

Improved clarity of the original while loop.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 82824eab47)
r14.0.x
Slávek Banko 6 years ago
parent c55c4a99a3
commit a729c2c36c
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -839,8 +839,11 @@ void BatchRenamer::parseSubdirs( data* f )
// create the missing subdir now // create the missing subdir now
int i = 0; int i = 0;
TQString d = ""; TQString d = TQString::null;
while (!(d = dirs.section("/", i, i, TQString::SectionSkipEmpty)).isEmpty()) { // asignment here! for (d = dirs.section("/", i, i, TQString::SectionSkipEmpty);
!d.isEmpty();
i++, d = dirs.section("/", i, i, TQString::SectionSkipEmpty))
{
KURL url = f->dst.url; KURL url = f->dst.url;
// it is important to unescape here // it is important to unescape here
// to support dirnames containing "&" or // to support dirnames containing "&" or
@ -852,7 +855,6 @@ void BatchRenamer::parseSubdirs( data* f )
f->dst.url.addPath( d ); f->dst.url.addPath( d );
f->dst.directory.append( d + "/" ); f->dst.directory.append( d + "/" );
i++;
} }
} }
} }

@ -1171,14 +1171,18 @@ bool KRenameImpl::setupBatchRenamer( BatchRenamer* b, bool preview )
int i = 0; int i = 0;
TQString d = "/"; TQString d = "/";
while (!(d += url.section( "/", i, i, TQString::SectionSkipEmpty)).isEmpty()) { // asignment here! TQString ds = TQString::null;
if (!TDEIO::NetAccess::exists(d, false, parent) && !TDEIO::NetAccess::mkdir(d, parent, -1)) for (ds = url.section("/", i, i, TQString::SectionSkipEmpty);
!ds.isEmpty();
i++, d.append("/"), ds = url.section("/", i, i, TQString::SectionSkipEmpty))
{
d += ds;
if (!TDEIO::NetAccess::exists(d, false, parent) &&
!TDEIO::NetAccess::mkdir(d, parent, -1))
{ {
tqDebug( "Can't create %s", d.latin1() ); tqDebug( "Can't create %s", d.latin1() );
break; break;
} }
d.append( "/" );
i++;
} }
} }

Loading…
Cancel
Save